-
Notifications
You must be signed in to change notification settings - Fork 0
/
test4.asm
79 lines (79 loc) · 1.18 KB
/
test4.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
77
78
79
ldc 0x1000
a2sp
adj -1
ldc result
stl 0
ldc count
ldnl 0
call main
adj 1
HALT
;
main: adj -3
stl 1
stl 2
ldc 0 ; zero accumulator
stl 0
loop: adj -1
ldl 3
stl 0
ldl 1
call triangle
adj 1
ldl 3
stnl 0
ldl 3
adc 1
stl 3
ldl 0
adc 1
stl 0
ldl 0 ; reload it
ldl 2
sub
brlz loop
ldl 1 ; get return address
adj 3
return
;
triangle:adj -3
stl 1
stl 2
ldc 1
shl
ldl 3
sub
brlz skip
ldl 3
ldl 2
sub
stl 2
skip: ldl 2
brz one
ldl 3
adc -1
stl 0
adj -1
ldl 1
stl 0
ldl 3
adc -1
call triangle
ldl 1
stl 0
stl 1
ldl 3
call triangle
adj 1
ldl 0
add
ldl 1
adj 3
return
one: ldc 1
ldl 1
adj 3
return
;
count: data 10
result: data 0