-
Notifications
You must be signed in to change notification settings - Fork 1
/
asm
76 lines (75 loc) · 1.01 KB
/
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
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
jmp 0x023
mov SP, MBR #function start
mwr 0x9f6
mrd 0x9fb
mov MBR, SP
lco 1
mrd SP
mov MBR, r2
sub SP, SP
mrd SP
mov MBR, r1
sub SP, SP
mrd SP
mov MBR, r0
lco 2
add r0, r0
sub r1, r1
mul r2, r2
lco 1
mov r0, MBR
mwr SP
mwr 0x0
add SP, SP
mov r1, MBR
mwr SP
mwr 0x0
add SP, SP
mov r2, MBR
mwr SP
mwr 0x0
mrd 0x9f6
mov MBR, SP
mrd SP
jmp MBR #function end
lco 0x9fc #load stacks
mov ACC, MBR
mwr 0x9fb
lco 0x9f7
mov ACC, MBR
mwr 0x9f6
lco 3
mrd 0x9fb #prepare vstack access by getting pointer
mov MBR, SP
mov ACC, MBR #prepare a constant
lco 1 #prepare SP increment
mwr SP #write 3 to the stack 3 times
add SP, SP
mwr SP
add SP, SP
mwr SP
mov SP, MBR #place pointer at header
mwr 0x9fb
mrd 0x9f6 #prepare fstack access by getting pointer
mov MBR, SP
lco 3
add PC, MBR #prepare return address on the fstack
mwr SP
jmp 0x002 #jump to function
mrd 0x9f6
mov MBR, SP
lco 3
add PC, MBR
mwr SP
jmp 0x002
mrd 0x9f6
mov MBR, SP
lco 3
add PC, MBR
mwr SP
jmp 0x002
lco 0xff
mov ACC, MBR
mwr 0x0
#fstack @ 0x9f6
#vstack @ 0x9fb