forked from redcode/SpecEmu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
z80edopcodes.asm
168 lines (140 loc) · 6.19 KB
/
z80edopcodes.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
; ********************* ED opcode macros *********************
z80_ldi macro
z80m_storeword 0a0edh
z80_PC = z80_PC + 2
endm
z80_cpi macro
z80m_storeword 0a1edh
z80_PC = z80_PC + 2
endm
z80_ini macro
z80m_storeword 0a2edh
z80_PC = z80_PC + 2
endm
z80_outi macro
z80m_storeword 0a3edh
z80_PC = z80_PC + 2
endm
z80_ldd macro
z80m_storeword 0a8edh
z80_PC = z80_PC + 2
endm
z80_cpd macro
z80m_storeword 0a9edh
z80_PC = z80_PC + 2
endm
z80_ind macro
z80m_storeword 0aaedh
z80_PC = z80_PC + 2
endm
z80_outd macro
z80m_storeword 0abedh
z80_PC = z80_PC + 2
endm
z80_ldir macro
z80m_storeword 0b0edh
z80_PC = z80_PC + 2
endm
z80_cpir macro
z80m_storeword 0b1edh
z80_PC = z80_PC + 2
endm
z80_inir macro
z80m_storeword 0b2edh
z80_PC = z80_PC + 2
endm
z80_otir macro
z80m_storeword 0b3edh
z80_PC = z80_PC + 2
endm
z80_lddr macro
z80m_storeword 0b8edh
z80_PC = z80_PC + 2
endm
z80_cpdr macro
z80m_storeword 0b9edh
z80_PC = z80_PC + 2
endm
z80_indr macro
z80m_storeword 0baedh
z80_PC = z80_PC + 2
endm
z80_otdr macro
z80m_storeword 0bbedh
z80_PC = z80_PC + 2
endm
z80_in macro arg1:req, arg2:req
ifidni <arg2>, <(c)>
; IN r,(C)
t_tmp = @ITEMINLIST (arg1, <b,c,d,e,h,l,f,a>)
if t_tmp eq 0
.err <Illegal destination register for IN opcode>
endif
t_tmp = t_tmp - 1
z80m_storebyte 0EDh
z80m_storebyte 40h + (t_tmp * 8)
z80_PC = z80_PC + 2
exitm
endif
; IN A,(n)
.errdifi <arg1>, <a>, <Illegal destination register for IN opcode>
z80m_decodearg arg2
if argtype eq z80type_bracketimmediate
z80m_storebyte 0DBh
z80m_storeconstbyte argval, argconstreg ; immediate argument
z80_PC = z80_PC + 2
exitm
endif
.err <*** Unknown IN opcode ***>
endm
z80_out macro arg1:req, arg2:req
ifidni <arg1>, <(c)>
; OUT (C),r and OUT (C),0
t_tmp = @ITEMINLIST (arg2, <b,c,d,e,h,l,0,a>)
if t_tmp eq 0
.err <Illegal destination register for OUT opcode>
endif
t_tmp = t_tmp - 1
z80m_storebyte 0EDh
z80m_storebyte 41h + (t_tmp * 8)
z80_PC = z80_PC + 2
exitm
endif
; OUT (n),A
.errdifi <arg2>, <a>, <Illegal source register for OUT opcode>
z80m_decodearg arg1
if argtype eq z80type_bracketimmediate
z80m_storebyte 0D3h
z80m_storeconstbyte argval, argconstreg ; immediate argument
z80_PC = z80_PC + 2
exitm
endif
.err <*** Unknown OUT opcode ***>
endm
z80_neg macro
z80m_storeword 44edh
z80_PC = z80_PC + 2
endm
z80_retn macro
z80m_storeword 45edh
z80_PC = z80_PC + 2
endm
z80_reti macro
z80m_storeword 4dedh
z80_PC = z80_PC + 2
endm
z80_im macro arg1:req
ifidn <arg1>, <0>
t_tmp=46h
elseifidn <arg1>, <1>
t_tmp=56h
elseifidn <arg1>, <2>
t_tmp=5eh
else
.err <Illegal value for IM opcode>
endif
z80m_storebyte 0EDh
z80m_storebyte t_tmp
z80_PC = z80_PC + 2
exitm
endm