-
Notifications
You must be signed in to change notification settings - Fork 0
/
lab5.lst
24 lines (24 loc) · 1.87 KB
/
lab5.lst
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
1 bits 32 ; assembling for the 32 bits architecture
2
3 ; declare the EntryPoint (a label defining the very first instruction of the program)
4 global start
5
6 ; declare external functions needed by our program
7 extern exit,printf ; tell nasm that exit exists even if we won't be defining it
8 import exit msvcrt.dll ; exit is a function that ends the calling process. It is defined in msvcrt.dll
9 ; msvcrt.dll contains exit, printf and all the other important C-runtime specific functions
10 import printf msvcrt.dll
11 ; our data is declared here (the variables needed by our program)
12 segment data use32 class=data
13 ; ...
14
15 ; our code starts here
16 segment code use32 class=code
17 start:
18 ; ...
19 00000000 6A21 push 33
20 00000002 E8(00000000) call printf
21 00000007 83C404 add esp , 4
22 ; exit(0)
23 0000000A 6A00 push dword 0 ; push the parameter for exit onto the stack
24 0000000C FF15[00000000] call [exit] ; call exit to terminate the program