Graphics Programs Reference
In-Depth Information
(gdb) disass main
Dump of assembler code for function main:
0x08048374 <main+0>: push ebp
0x08048375 <main+1>: mov ebp,esp
0x08048377 <main+3>: sub esp,0x8
0x0804837a <main+6>: and esp,0xfffffff0
0x0804837d <main+9>: mov eax,0x0
0x08048382 <main+14>: sub esp,eax
0x08048384 <main+16>: mov DWORD PTR [ebp-4],0x0
0x0804838b <main+23>: cmp DWORD PTR [ebp-4],0x9
0x0804838f <main+27>: jle 0x8048393 <main+31>
0x08048391 <main+29>: jmp 0x80483a6 <main+50>
0x08048393 <main+31>: mov DWORD PTR [esp],0x8048484
0x0804839a <main+38>: call 0x80482a0 <printf@plt>
0x0804839f <main+43>: lea eax,[ebp-4]
0x080483a2 <main+46>: inc DWORD PTR [eax]
0x080483a4 <main+48>: jmp 0x804838b <main+23>
0x080483a6 <main+50>: leave
0x080483a7 <main+51>: ret
End of assembler dump.
(gdb) list
1 #include <stdio.h>
2
3 int main()
4 {
5 int i;
6 for(i=0; i < 10; i++)
7 {
8 printf("Hello, world!\n");
9 }
10 }
(gdb)
The instructions shown in bold make up the for loop, and the instruc-
tions in italics are the printf() call found within the loop. The program exe-
cution will jump back to the compare instruction, continue to execute the
printf() call, and increment the counter variable until it finally equals 10. At
this point the conditional jle instruction won't execute; instead, the instruc-
tion pointer will continue to the unconditional jump instruction, which exits
the loop and ends the program.
0x260
Back to Basics
Now that the idea of programming is less abstract, there are a few other
important concepts to know about C. Assembly language and computer
processors existed before higher-level programming languages, and many
modern programming concepts have evolved through time. In the same way
that knowing a little about Latin can greatly improve one's understanding of
Search WWH ::




Custom Search