-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmacros.inc
81 lines (76 loc) · 1.94 KB
/
macros.inc
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
vector_count? = 0
vector_id? =: 0
vector_start? =: 0
calminstruction start_vector
local vector, tmp
compute tmp, vector_count
take vector_id, tmp
compute vector_count, vector_count + 1
arrange vector, =vector_#vector_id
call encode_u, vector
compute tmp, $
take vector_start, tmp
end calminstruction
calminstruction end_vector
local vector, length
arrange vector, =vector_#vector_id
compute length, $ - vector_start
publish vector:, length
take ,vector_start
take ,vector_id
end calminstruction
calminstruction iteratelist?! param, var
transform var
arrange param, =iterate param, var
assemble param
end calminstruction
calminstruction encode_u number*
local byte
loop:
compute byte, number and 0x7F
compute number, number shr 7
check number > 0
jno emit_byte
compute byte, byte or 1 shl 7
emit_byte:
arrange byte, =db byte
assemble byte
jyes loop
end calminstruction
calminstruction encode_s number*
compute number, (not number) + 1
call encode_u, number
end calminstruction
calminstruction calminstruction?.initsym? variable*,value&
publish variable, value
end calminstruction
calminstruction calminstruction?.asm? line&
local name, i
initsym name, name.0
match name.i, name
compute i, i+1
arrange name, name.i
publish name:, line
arrange line, =assemble name
assemble line
end calminstruction
macro calminstruction?.debug? var*, format
local tmp
arrange tmp, var
stringify tmp
display format
display "'"
display tmp
display "'"
display 10
end macro
macro calminstruction?.checksym? name*
publish name:, name
publish name:, name
end macro
macro calminstruction?.start_virtual? section
asm virtual section
end macro
calminstruction calminstruction?.end_virtual?
asm asm end virtual
end calminstruction