-
Notifications
You must be signed in to change notification settings - Fork 3
/
stack.asm
42 lines (31 loc) · 987 Bytes
/
stack.asm
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
%include "io.inc"
struc DATA
.var1: resb 1
.var2: resw 1
.var3: resd 1
endstruc
section .data
data: istruc DATA
endData:
dataSize equ (endData - data)
section .text
global CMAIN
CMAIN:
mov ebp, esp; for correct debugging
push ebp ; save old ebp
sub esp, dataSize ; allocate local variables
mov ebp, esp ; set ebp for variable indexing
; set variables
mov [ebp + DATA.var1], byte 0xAA
mov [ebp + DATA.var3], dword 0xBBBBBBBB
mov [ebp + DATA.var2], word 0xCCCC
; read variables
xor eax, eax
mov al, byte [ebp + DATA.var1]
xor eax, eax
mov ax, word [ebp + DATA.var2]
xor eax, eax
mov eax, dword [ebp + DATA.var3]
add esp, dataSize ; de-allocate local variables
pop ebp ; restore stack
ret