Skip to content

Commit 9a4af92

Browse files
add missing file
1 parent 35719b9 commit 9a4af92

File tree

1 file changed

+129
-0
lines changed

1 file changed

+129
-0
lines changed

src/msddrvce/macros.inc

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
; helpful macros for working with structures
2+
3+
macro compare_hl_zero?
4+
add hl,de
5+
or a,a
6+
sbc hl,de
7+
end macro
8+
9+
macro compare_auhl_zero?
10+
compare_hl_zero
11+
jr nz,$+3
12+
or a,a
13+
end macro
14+
15+
macro compare_hl_de?
16+
or a,a
17+
sbc hl,de
18+
add hl,de
19+
end macro
20+
21+
macro compare_bc_zero?
22+
push hl
23+
sbc hl,hl
24+
adc hl,bc
25+
pop hl
26+
end macro
27+
28+
macro ?!
29+
macro assertpo2? value*
30+
local val
31+
val = value
32+
if ~val | val <> 1 shl bsr val
33+
err '"', `value, '" is not a power of two'
34+
end if
35+
end macro
36+
37+
iterate op, bit, res, set
38+
macro op#msk? index*, value
39+
local idx, val, rest
40+
idx = index
41+
assertpo2 idx
42+
match @, value
43+
val equ value
44+
else
45+
val equ
46+
rest equ index
47+
while 1
48+
match car.cdr, rest
49+
match any, val
50+
val equ any.car
51+
else
52+
val equ car
53+
end match
54+
rest equ cdr
55+
else
56+
val equ (val)
57+
break
58+
end match
59+
end while
60+
end match
61+
match v, val
62+
op bsr idx,v
63+
end match
64+
end macro
65+
end iterate
66+
67+
macro struct? name*, parameters&
68+
macro end?.struct?!
69+
end namespace
70+
end struc
71+
iterate <base,prefix>, 0,, ix-name,x, iy-name,y
72+
virtual at base
73+
prefix#name name
74+
end virtual
75+
end iterate
76+
purge end?.struct?
77+
end macro
78+
struc name parameters
79+
namespace .
80+
end macro
81+
82+
; copied from ez80.alm
83+
macro calminstruction?.isindirect? argument*
84+
unique done
85+
local isindirect
86+
match ( isindirect ), argument
87+
bno done
88+
match isindirect, isindirect, ()
89+
label done
90+
end macro
91+
92+
calminstruction ld? lhs*, mhs*, rhs
93+
match , rhs
94+
jyes plain
95+
isindirect lhs
96+
jyes store
97+
isindirect rhs
98+
jno errarguments
99+
load:
100+
execute =ld? mhs, (rhs)
101+
check mhs metadata 1 element 1 eq @ez80.wreg
102+
jyes loadword
103+
loadbyte:
104+
execute =ld? lhs, (rhs + =byte?)
105+
exit
106+
loadword:
107+
execute =ld? lhs, (rhs + =@ez80.=ws)
108+
exit
109+
store:
110+
execute =ld? (lhs), rhs
111+
check rhs metadata 1 element 1 eq @ez80.wreg
112+
jyes storeword
113+
storebyte:
114+
execute =ld? (lhs + =byte?), mhs
115+
exit
116+
storeword:
117+
execute =ld? (lhs + =@ez80.=ws), mhs
118+
exit
119+
plain:
120+
execute =ld? lhs, mhs
121+
exit
122+
errarguments:
123+
err 'invalid arguments'
124+
end calminstruction
125+
126+
purge calminstruction?.isindirect?
127+
128+
purge ?
129+
end macro

0 commit comments

Comments
 (0)