summaryrefslogtreecommitdiff
path: root/projects/11/ConvertToBin/Main.vm
blob: 15d63c06981df2ee6c63998f979a7c40d665dfd9 (plain) (blame)
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
function Main.main 1
push constant 8000
push constant 3827
call Memory.poke 2
pop temp 0
push constant 8001
push constant 16
push constant 1
neg
call Main.fillMemory 3
pop temp 0
push constant 8000
call Memory.peek 1
pop local 0
push local 0
call Main.convert 1
pop temp 0
push constant 0
return
function Main.convert 3
push constant 1
neg
pop local 2
label convert.While0
push local 2
not
if-goto convert.EndWhile0
push local 1
push constant 1
add
pop local 1
push local 0
call Main.nextMask 1
pop local 0
push local 1
push constant 16
gt
not
not
if-goto convert.While0.Else0
push argument 0
push local 0
and
push constant 0
eq
not
not
if-goto convert.While0.Else0.Else0
push constant 8000
push local 1
add
push constant 1
call Memory.poke 2
pop temp 0
goto convert.While0.Else0.Endif0
label convert.While0.Else0.Else0
push constant 8000
push local 1
add
push constant 0
call Memory.poke 2
pop temp 0
label convert.While0.Else0.Endif0
goto convert.While0.Endif0
label convert.While0.Else0
push constant 0
pop local 2
label convert.While0.Endif0
goto convert.While0
label convert.EndWhile0
push constant 0
return
function Main.nextMask 0
push argument 0
push constant 0
eq
not
if-goto nextMask.Else0
push constant 1
return
goto nextMask.Endif0
label nextMask.Else0
push argument 0
push constant 2
call Math.multiply 2
return
label nextMask.Endif0
function Main.fillMemory 0
label fillMemory.While0
push argument 1
push constant 0
gt
not
if-goto fillMemory.EndWhile0
push argument 0
push argument 2
call Memory.poke 2
pop temp 0
push argument 1
push constant 1
sub
pop argument 1
push argument 0
push constant 1
add
pop argument 0
goto fillMemory.While0
label fillMemory.EndWhile0
push constant 0
return