![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Sep 2005
Posts: 4
Rep Power: 0
![]() |
Conceptualizing Code
Hello. I'm having a hard time understanding the interaction between code, programming language, and the actual computer.
I've seen tutorials on the net about how to write your own programming language, for example. To do that, aren't they using a programming language? That totally doesn't make sense to me. Then there's the matter of how the code actually interacts with the computer. Can someone out there take me step by step through how code works its way down to the actual hardware and then back onto the screen? And wouldn't this entire process have to go through the windows operating system? It's hard for me to explain what I'm asking, I just don't understand how code works at its most basic level. And how come I never see a command like "draw" in most programming languages? If games are written with these languages how do they get all the flashy stuff onto the screen? As you can see, I'm in a doozy. Any help appreciated. |
|
|
|
|
|
#2 |
|
Professional Programmer
|
This is not really something easily explained in one post, I've taken about 3 classes on this subject.
basically this happens your code is translated into a different code, called assembly language, in assembly language each line is one change little change in memory or disk. ex $a = $a + 1; addi $t1, 1 #add 1 to a temp register add $r1, $t1, $r2 #add the temp register to the variable in register 1 and store the output in register 2 mv $r2, $r1 #move the result back into register 1 what graphics is concerned, when the code is executed, the code is sent video card which handles the operation and draws to the screen. This is a tiny little explaination of the process, but as I said, it's not simple, and just knowing how to check your email on windows, is not going to give you the tools to completely understand the process. There are a whole bunch of books on Computer Design out there that explain this in detail, they are usually about 1000 pages. I've read 3 of those as well and still don't know everything about it. |
|
|
|
|
|
#3 |
|
Expert Programmer
|
I think i understand what you mean by the first question: If a programming language is written in another programming language, how was the first one made?
I don't know ![]() But for the second question: Most languages don't have graphics built in, you need an extra module/header/package (or whatever). Say you wanted to make a game in C++, you would use OpenGL or DirectX as graphics libraries. And in a scripting language it is the same, Python uses PyGame. ![]()
__________________
Join us at #programmingforums @ irc.freenode.net! My software never has bugs. It just develops random features.
|
|
|
|
|
|
#4 |
|
Expert Programmer
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4
![]() |
@Dizzutch: what kind of assembly language is that?
|
|
|
|
|
|
#5 |
|
Professional Programmer
|
some very loose MIPS, it might run in SPIM, i havn't used assembly in 2 years, it's not really my thing..
![]() |
|
|
|
|
|
#6 | |||
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
Quote:
This is rather difficult for humans to follow, and hence the need for programming languages. These go from very low level languages like assembly (which just directly maps machine code commands to easy-to-remember tokens) right up to high level languages like Lisp, Python, or Ruby. Generally speaking, the higher level the language is, the faster it is to design a program in, and the slower the program runs. Quote:
Quote:
This ensures programming environments don't get bloated with unneeded functionality. For instance, If you wanted to create an email client, you wouldn't want all the overhead of a 3D engine, would you? |
|||
|
|
|
|
|
#7 | |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
Quote:
|
|
|
|
|
|
|
#8 |
|
Newbie
Join Date: Sep 2005
Posts: 4
Rep Power: 0
![]() |
OK, I understand about graphics and programming languages now. Thanks everyone! But I still don't get how code interacts with hardware.
For instance, if you use a graphics library in a program, wouldn't the instructions contained in that library have to exist in some form on the hardware somewhere - how else could the computer interpret the code? Would a video card be able to interpret more instructions than integrated graphics, and if so wouldn't that mean some machine code wouldn't work on computers without one? And, how could all these video (or other) card companies maintain compatability? Also, how does the computer know what sequence of 1s and 0s to turn into what output? |
|
|
|
|
|
#9 |
|
Expert Programmer
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4
![]() |
about the video cards... i'll tell you first how text mode works, because that's the only thing i know exactly atm
When you boot the operating system and switch to protected mode, the video memory will be at 0xB8000. Every character on the screen will be 2 bytes. The first byte the actual character, the second byte the color. An example (dunno this is correct, but it is something like this):short *vidmem = (short *) 0xB8000; // pointer to the video memory vidmem[0] = 'H' | 0x07; // print a white H at the upperleft corner vidmem[1] = 'i' | 0x07; // print a white i right to the H about how the cpu executes the 1s and 0s? I have no idea ![]() |
|
|
|
|
|
#10 | |||
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
Quote:
Quote:
Quote:
|
|||
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|