| 303 | } |
| 304 | |
| 305 | func TestOneRegInstructions(t *testing.T) { |
| 306 | var TABLE map[Instruction][]uint16 = map[Instruction][]uint16{ |
| 307 | SHR{REG0}: []uint16{0x90}, |
| 308 | SHR{REG1}: []uint16{0x95}, |
| 309 | SHR{REG2}: []uint16{0x9A}, |
| 310 | SHR{REG3}: []uint16{0x9F}, |
| 311 | |
| 312 | SHL{REG0}: []uint16{0xA0}, |
| 313 | SHL{REG1}: []uint16{0xA5}, |
| 314 | SHL{REG2}: []uint16{0xAA}, |
| 315 | SHL{REG3}: []uint16{0xAF}, |
| 316 | |
| 317 | NOT{REG0}: []uint16{0xB0}, |
| 318 | NOT{REG1}: []uint16{0xB5}, |
| 319 | NOT{REG2}: []uint16{0xBA}, |
| 320 | NOT{REG3}: []uint16{0xBF}, |
| 321 | |
| 322 | JR{REG0}: []uint16{0x30}, |
| 323 | JR{REG1}: []uint16{0x31}, |
| 324 | JR{REG2}: []uint16{0x32}, |
| 325 | JR{REG3}: []uint16{0x33}, |
| 326 | } |
| 327 | |
| 328 | for ins, expected := range TABLE { |
| 329 | if emit, err := ins.Emit(nil, nil); err == nil { |
| 330 | if reflect.DeepEqual(emit, expected) == false { |
| 331 | t.Logf("Expected %v got %v when testing %s", expected, emit, ins) |
| 332 | t.FailNow() |
| 333 | } |
| 334 | } else { |
| 335 | t.Logf("Got error %v when testing %s", err, ins) |
| 336 | t.FailNow() |
| 337 | } |
| 338 | } |
| 339 | } |
| 340 | |
| 341 | func TestDATAInstructionsString(t *testing.T) { |
| 342 | var TABLE map[Instruction]string = map[Instruction]string{ |