summaryrefslogtreecommitdiff
path: root/ecomp-c/tests/bool_conditions.easm
blob: 266d77cc8e4d1e9890afa6d3e052cd4d72ed3da8 (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
format binary
use32
org $1000000
jmp __global_0
; DECL a -> integer, 0
; DECL b -> integer, 0
; DECL c -> integer, 0
; DECL d -> integer, 0
__global_0:
; LET a <- 2 
mov eax, 2
push eax
pop eax
mov [a], eax
; LET b <- 1 
mov eax, 1
push eax
pop eax
mov [b], eax
; LET c <- 3 
mov eax, 3
push eax
pop eax
mov [c], eax
; TEST a b > a c <= and 
; expr left
mov eax, [a]
push eax
mov eax, [b]
push eax
pop ebx
pop eax
cmp eax, ebx
ja __global_4
mov eax, 0
jmp __global_5
__global_4: mov eax, 1
__global_5:
push eax
pop eax
mov ebx, 0
cmp eax, ebx
je __global_3
; expr right
mov eax, [a]
push eax
mov eax, [c]
push eax
pop ebx
pop eax
cmp eax, ebx
jbe __global_6
mov eax, 0
jmp __global_7
__global_6: mov eax, 1
__global_7:
push eax
pop eax
__global_3:
push eax
pop eax
mov ebx, 0
cmp eax, ebx
je __global_1
; LET d <- 42 
mov eax, 42
push eax
pop eax
mov [d], eax
jmp __global_2
__global_1:
; LET d <- 0 
mov eax, 0
push eax
pop eax
mov [d], eax
__global_2:
hlt
d: dd $00000000
c: dd $00000000
b: dd $00000000
a: dd $00000000