summaryrefslogtreecommitdiff
path: root/ecomp-c/tests/while_statement.easm
blob: 1984c8f73bc930b1d36c983e40d389c1f2389483 (plain)
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
format binary
use32
org $1000000
jmp __global_0
; DECL i -> integer, 0
__global_0:
; LET i <- 0 
mov eax, 0
push eax
pop eax
mov [i], eax
; WHILE i 10 < 
__global_1:
mov eax, [i]
push eax
mov eax, 10
push eax
pop ebx
pop eax
cmp eax, ebx
jb __global_5
mov eax, 0
jmp __global_6
__global_5: mov eax, 1
__global_6:
push eax
pop eax
mov ebx, 0
cmp eax, ebx
je __global_3
jmp __global_4
__global_3: jmp __global_2
__global_4:
; LET i <- i 1 + 
mov eax, [i]
push eax
mov eax, 1
push eax
pop ebx
pop eax
add eax, ebx
push eax
pop eax
mov [i], eax
jmp __global_1
__global_2:
hlt
i: dd $00000000