repositories
/
ccc.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
cleanup imports
[ccc.git]
/
rts.ssm
1
; Power function
2
pow:
3
link 1; pow (x, y) {
4
ldc 1
5
stl 1; var z = 1
6
poww:
7
ldl -2; while (y > 0)
8
ldc 0
9
gt
10
brf powe ; {
11
ldl -3; z = x*z
12
ldl 1
13
mul
14
stl 1
15
ldl -2; y = y-1
16
ldc 1
17
sub
18
stl -2
19
bra poww ; }
20
powe:
21
ldl 1; return z
22
str RR
23
unlink
24
ret
25
26
; Equality of basic types
27
eqInt:
28
link 0
29
ldl -2
30
ldl -3
31
eq
32
unlink
33
ret
34
eqChar:
35
link 0
36
ldl -2
37
ldl -3
38
eq
39
unlink
40
ret
41
eqBool:
42
link 0
43
ldl -2
44
ldl -3
45
eq
46
unlink
47
ret
48
49
; Printing of basic types
50
printInt:
51
link 0
52
ldl -2
53
trap 0
54
unlink
55
ret
56
printChar:
57
link 0
58
ldl -2
59
trap 1
60
unlink
61
ret
62
printBool:
63
link 0
64
ldl -2
65
brf printBoolf
66
ldc 84
67
trap 1
68
bra printBoole
69
printBoolf:
70
ldc 70
71
trap 1
72
printBoole:
73
unlink
74
ret
75
76
; Field selectors
77
fst:
78
link 0
79
ldl -2
80
ldh -1
81
str RR
82
unlink
83
ret
84
snd:
85
link 0
86
ldl -2
87
ldh 0
88
str RR
89
unlink
90
ret
91
hd:
92
link 0
93
ldl -2
94
ldh -1
95
str RR
96
unlink
97
ret
98
tl:
99
link 0
100
ldl -2
101
ldh 0
102
str RR
103
unlink
104
ret
105
106
; List empty check
107
isEmpty:
108
link 0
109
ldl -2
110
ldc 0
111
eq
112
str RR
113
unlink
114
ret