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
65
|
; begin playing around with variables!
section .bss
fart_count: resb 4
section .data
fart_max: db 255
section .text
global _start
dofarts:
push ebp
mov ebp, esp
add ebp, 4
; set the fart_count to zero
mov DWORD [fart_count], 0
; save eax to the stack because we're gonna use it
push eax
jmp dofarts.keepgoing
dofarts.stop:
;clean up and return
pop eax
pop ebp
ret
dofarts.keepgoing:
; put fart_count into a register (i wish i could do mem,mem)
mov eax, [fart_count]
; increment the fart_count
add dword[fart_count], 1
; has fart_count reached fart_max?
jge dofarts.check
; else, stop... this is redundant...
jmp dofarts.stop
dofarts.check:
; is fart_count (eax) fart_max?
cmp eax, [fart_max]
; if so, stop
jge dofarts.stop
; else keep going
jmp dofarts.keepgoing
_start:
push ebp
mov ebp, esp
call dofarts
mov ebx, [fart_count]
add ebx, [fart_max]
mov esp, ebp
pop ebp
mov eax, 1
;mov ebx, 0
int 80h
ret
|