-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack.asm
More file actions
64 lines (48 loc) · 819 Bytes
/
stack.asm
File metadata and controls
64 lines (48 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
%include "asm_io.inc"
segment .data
msg1 dd "local_variable1"
msg2 dd "local_variable2"
segment .text
global main
main:
enter 0,0 ; setup stack frame
pusha
push dword 3
push dword 2
push dword 1
call subpr
add esp, 12
popa
mov eax, 0 ; return value
leave ; leave stack frame
ret
subpr:
push ebp
mov ebp, esp
sub esp, 8
mov eax,[ebp+16] ;3
call print_int
call print_nl
mov eax,[ebp+12] ;2
call print_int
call print_nl
mov eax,[ebp+8] ;1
call print_int
call print_nl
mov eax,[ebp+4] ;return address
call print_int
call print_nl
mov eax,[ebp] ;saved ebp
call print_int
call print_nl
mov [ebp-4], dword msg1
mov eax,[ebp-4] ;
call print_string
call print_nl
mov [ebp-8], dword msg2
mov eax,[ebp-8] ;
call print_string
call print_nl
mov esp, ebp
pop ebp
ret