@@ -83,6 +83,7 @@ pub fn decode_instruction_at_address(
83
83
Instruction :: LD_r8_u8 ( R8 :: E , machine. read_u8 ( address + 1 ) ) ,
84
84
2 ,
85
85
) ,
86
+ 0x1F => ( Instruction :: RRA , 1 ) ,
86
87
87
88
0x20 => (
88
89
Instruction :: JR_cc_i8 ( Condition :: NZ , machine. read_u8 ( address + 1 ) as i8 ) ,
@@ -96,6 +97,10 @@ pub fn decode_instruction_at_address(
96
97
0x23 => ( Instruction :: INC_r16 ( R16 :: HL ) , 1 ) ,
97
98
0x24 => ( Instruction :: INC_r8 ( R8 :: H ) , 1 ) ,
98
99
0x25 => ( Instruction :: DEC_r8 ( R8 :: H ) , 1 ) ,
100
+ 0x26 => (
101
+ Instruction :: LD_r8_u8 ( R8 :: H , machine. read_u8 ( address + 1 ) ) ,
102
+ 2 ,
103
+ ) ,
99
104
0x28 => (
100
105
Instruction :: JR_cc_i8 ( Condition :: Z , machine. read_u8 ( address + 1 ) as i8 ) ,
101
106
2 ,
@@ -118,6 +123,7 @@ pub fn decode_instruction_at_address(
118
123
) ,
119
124
0x32 => ( Instruction :: LD_mHLdec_A , 1 ) ,
120
125
0x33 => ( Instruction :: INC_r16 ( R16 :: SP ) , 1 ) ,
126
+ 0x35 => ( Instruction :: DEC_mHL , 1 ) ,
121
127
0x38 => (
122
128
Instruction :: JR_cc_i8 ( Condition :: C , machine. read_u8 ( address + 1 ) as i8 ) ,
123
129
2 ,
@@ -180,9 +186,16 @@ pub fn decode_instruction_at_address(
180
186
0x6E => ( Instruction :: LD_r8_mr16 ( R8 :: L , R16 :: HL ) , 1 ) ,
181
187
0x6F => ( Instruction :: LD_r8_r8 ( R8 :: L , R8 :: A ) , 1 ) ,
182
188
189
+ 0x70 => ( Instruction :: LD_mr16_r8 ( R16 :: HL , R8 :: B ) , 1 ) ,
190
+ 0x71 => ( Instruction :: LD_mr16_r8 ( R16 :: HL , R8 :: C ) , 1 ) ,
191
+ 0x72 => ( Instruction :: LD_mr16_r8 ( R16 :: HL , R8 :: D ) , 1 ) ,
183
192
0x73 => ( Instruction :: LD_mr16_r8 ( R16 :: HL , R8 :: E ) , 1 ) ,
193
+ 0x74 => ( Instruction :: LD_mr16_r8 ( R16 :: HL , R8 :: H ) , 1 ) ,
194
+ 0x75 => ( Instruction :: LD_mr16_r8 ( R16 :: HL , R8 :: L ) , 1 ) ,
184
195
0x77 => ( Instruction :: LD_mr16_r8 ( R16 :: HL , R8 :: A ) , 1 ) ,
185
196
0x78 => ( Instruction :: LD_r8_r8 ( R8 :: A , R8 :: B ) , 1 ) ,
197
+ 0x79 => ( Instruction :: LD_r8_r8 ( R8 :: A , R8 :: C ) , 1 ) ,
198
+ 0x7A => ( Instruction :: LD_r8_r8 ( R8 :: A , R8 :: D ) , 1 ) ,
186
199
0x7B => ( Instruction :: LD_r8_r8 ( R8 :: A , R8 :: E ) , 1 ) ,
187
200
0x7C => ( Instruction :: LD_r8_r8 ( R8 :: A , R8 :: H ) , 1 ) ,
188
201
0x7D => ( Instruction :: LD_r8_r8 ( R8 :: A , R8 :: L ) , 1 ) ,
@@ -197,20 +210,23 @@ pub fn decode_instruction_at_address(
197
210
0x9F => ( Instruction :: SBC_A_A , 1 ) ,
198
211
199
212
0xA5 => ( Instruction :: AND_L , 1 ) ,
200
- 0xA8 => ( Instruction :: XOR_r8 ( R8 :: B ) , 1 ) ,
201
- 0xA9 => ( Instruction :: XOR_r8 ( R8 :: C ) , 1 ) ,
202
- 0xAA => ( Instruction :: XOR_r8 ( R8 :: D ) , 1 ) ,
203
- 0xAB => ( Instruction :: XOR_r8 ( R8 :: E ) , 1 ) ,
204
- 0xAC => ( Instruction :: XOR_r8 ( R8 :: H ) , 1 ) ,
205
- 0xAD => ( Instruction :: XOR_r8 ( R8 :: L ) , 1 ) ,
206
- 0xAF => ( Instruction :: XOR_r8 ( R8 :: A ) , 1 ) ,
213
+ 0xA8 => ( Instruction :: XOR_A_r8 ( R8 :: B ) , 1 ) ,
214
+ 0xA9 => ( Instruction :: XOR_A_r8 ( R8 :: C ) , 1 ) ,
215
+ 0xAA => ( Instruction :: XOR_A_r8 ( R8 :: D ) , 1 ) ,
216
+ 0xAB => ( Instruction :: XOR_A_r8 ( R8 :: E ) , 1 ) ,
217
+ 0xAC => ( Instruction :: XOR_A_r8 ( R8 :: H ) , 1 ) ,
218
+ 0xAD => ( Instruction :: XOR_A_r8 ( R8 :: L ) , 1 ) ,
219
+ 0xAE => ( Instruction :: XOR_A_mHL , 1 ) ,
220
+ 0xAF => ( Instruction :: XOR_A_r8 ( R8 :: A ) , 1 ) ,
207
221
208
222
0xB0 => ( Instruction :: OR_r8 ( R8 :: B ) , 1 ) ,
209
223
0xB1 => ( Instruction :: OR_r8 ( R8 :: C ) , 1 ) ,
210
224
0xB2 => ( Instruction :: OR_r8 ( R8 :: D ) , 1 ) ,
211
225
0xB3 => ( Instruction :: OR_r8 ( R8 :: E ) , 1 ) ,
212
226
0xB4 => ( Instruction :: OR_r8 ( R8 :: H ) , 1 ) ,
213
227
0xB5 => ( Instruction :: OR_r8 ( R8 :: L ) , 1 ) ,
228
+ 0xB6 => ( Instruction :: OR_A_mHL , 1 ) ,
229
+ 0xB7 => ( Instruction :: OR_r8 ( R8 :: A ) , 1 ) ,
214
230
0xB9 => ( Instruction :: CP_A_r8 ( R8 :: C ) , 1 ) ,
215
231
0xBB => ( Instruction :: CP_A_r8 ( R8 :: E ) , 1 ) ,
216
232
0xBE => ( Instruction :: CP_A_mHL , 1 ) ,
@@ -229,7 +245,7 @@ pub fn decode_instruction_at_address(
229
245
3 ,
230
246
) ,
231
247
0xC5 => ( Instruction :: PUSH_r16 ( R16 :: BC ) , 1 ) ,
232
- 0xC6 => ( Instruction :: ADD_A_u8 ( machine. read_u8 ( address + 1 ) ) , 1 ) ,
248
+ 0xC6 => ( Instruction :: ADD_A_u8 ( machine. read_u8 ( address + 1 ) ) , 2 ) ,
233
249
0xC8 => ( Instruction :: RET_cc ( Condition :: Z ) , 1 ) ,
234
250
0xC9 => ( Instruction :: RET , 1 ) ,
235
251
0xCB => match machine. read_u8 ( address + 1 ) {
@@ -239,15 +255,24 @@ pub fn decode_instruction_at_address(
239
255
0x13 => ( Instruction :: RL_r8 ( R8 :: E ) , 2 ) ,
240
256
0x14 => ( Instruction :: RL_r8 ( R8 :: H ) , 2 ) ,
241
257
0x15 => ( Instruction :: RL_r8 ( R8 :: L ) , 2 ) ,
258
+ 0x19 => ( Instruction :: RR_r8 ( R8 :: C ) , 2 ) ,
259
+ 0x1A => ( Instruction :: RR_r8 ( R8 :: D ) , 2 ) ,
260
+ 0x1F => ( Instruction :: RR_r8 ( R8 :: A ) , 2 ) ,
261
+
262
+ 0x38 => ( Instruction :: SRL_r8 ( R8 :: B ) , 2 ) ,
263
+
242
264
0x78 => ( Instruction :: BIT_u3_r8 ( 7 , R8 :: B ) , 2 ) ,
243
265
0x79 => ( Instruction :: BIT_u3_r8 ( 7 , R8 :: C ) , 2 ) ,
244
266
0x7A => ( Instruction :: BIT_u3_r8 ( 7 , R8 :: D ) , 2 ) ,
245
267
0x7B => ( Instruction :: BIT_u3_r8 ( 7 , R8 :: E ) , 2 ) ,
246
268
0x7C => ( Instruction :: BIT_u3_r8 ( 7 , R8 :: H ) , 2 ) ,
269
+
247
270
_ => {
271
+ println ! (
272
+ "TODO: CB-prefixed opcode 0x{:02x}" ,
273
+ machine. read_u8( address + 1 )
274
+ ) ;
248
275
( Instruction :: Prefix , 2 ) // 1 for prefix, 1 for extension?
249
- // println!("TODO: CB-prefixed opcode 0x{:x}", slice[1]);
250
- // todo!()
251
276
}
252
277
} ,
253
278
0xCC => (
@@ -260,8 +285,11 @@ pub fn decode_instruction_at_address(
260
285
) ,
261
286
0xCE => ( Instruction :: ADC_A_u8 ( machine. read_u8 ( address + 1 ) ) , 2 ) ,
262
287
288
+ 0xD0 => ( Instruction :: RET_cc ( Condition :: NC ) , 1 ) ,
289
+ 0xD1 => ( Instruction :: POP_r16 ( R16 :: DE ) , 1 ) ,
263
290
0xD5 => ( Instruction :: PUSH_r16 ( R16 :: DE ) , 1 ) ,
264
- 0xD8 => ( Instruction :: RET_C , 1 ) ,
291
+ 0xD6 => ( Instruction :: SUB_A_u8 ( machine. read_u8 ( address + 1 ) ) , 2 ) ,
292
+ 0xD8 => ( Instruction :: RET_cc ( Condition :: C ) , 1 ) ,
265
293
0xD9 => ( Instruction :: RETI , 1 ) ,
266
294
267
295
0xE0 => ( Instruction :: LD_FFu8_A ( machine. read_u8 ( address + 1 ) ) , 2 ) ,
@@ -273,6 +301,7 @@ pub fn decode_instruction_at_address(
273
301
Instruction :: LD_mu16_A ( Immediate16 :: from_memory ( machine, address + 1 ) ) ,
274
302
3 ,
275
303
) ,
304
+ 0xEE => ( Instruction :: XOR_A_u8 ( machine. read_u8 ( address + 1 ) ) , 2 ) ,
276
305
277
306
0xF0 => ( Instruction :: LD_A_FFu8 ( machine. read_u8 ( address + 1 ) ) , 2 ) ,
278
307
0xF1 => ( Instruction :: POP_r16 ( R16 :: AF ) , 1 ) ,
0 commit comments