Class: Rubyboy::Cpu
- Inherits:
-
Object
- Object
- Rubyboy::Cpu
- Defined in:
- lib/rubyboy/cpu.rb
Instance Method Summary collapse
- #exec ⇒ Object
-
#initialize(bus, interrupt) ⇒ Cpu
constructor
A new instance of Cpu.
Constructor Details
#initialize(bus, interrupt) ⇒ Cpu
Returns a new instance of Cpu.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/rubyboy/cpu.rb', line 7 def initialize(bus, interrupt) @bus = bus @interrupt = interrupt @registers = Registers.new @pc = 0x0100 @sp = 0xfffe @ime = false @ime_delay = false @halted = false end |
Instance Method Details
#exec ⇒ Object
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 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 |
# File 'lib/rubyboy/cpu.rb', line 19 def exec opcode = read_byte(@pc) # print_log(opcode) @halted &= @interrupt.interrupts == 0 return 16 if @halted if @ime && @interrupt.interrupts > 0 pcs = [0x0040, 0x0048, 0x0050, 0x0058, 0x0060] 5.times do |i| next if @interrupt.interrupts[i] == 0 @interrupt.reset_flag(i) @ime = false @sp -= 2 @bus.write_word(@sp, @pc) @pc = pcs[i] break end return 20 else increment_pc end if @ime_delay @ime_delay = false @ime = true end case opcode when 0x00 then 4 # NOP when 0x01 then ld16(:bc, :immediate16, cycles: 12) when 0x02 then ld8(:indirect_bc, :a, cycles: 8) when 0x03 then inc16(:bc, cycles: 8) when 0x04 then inc8(:b, cycles: 4) when 0x05 then dec8(:b, cycles: 4) when 0x06 then ld8(:b, :immediate8, cycles: 8) when 0x07 then rlca(cycles: 4) when 0x08 then ld16(:direct16, :sp, cycles: 20) when 0x09 then add16(:hl, :bc, cycles: 8) when 0x0a then ld8(:a, :indirect_bc, cycles: 8) when 0x0b then dec16(:bc, cycles: 8) when 0x0c then inc8(:c, cycles: 4) when 0x0d then dec8(:c, cycles: 4) when 0x0e then ld8(:c, :immediate8, cycles: 8) when 0x0f then rrca(cycles: 4) when 0x10 then 4 # STOP when 0x11 then ld16(:de, :immediate16, cycles: 12) when 0x12 then ld8(:indirect_de, :a, cycles: 8) when 0x13 then inc16(:de, cycles: 8) when 0x14 then inc8(:d, cycles: 4) when 0x15 then dec8(:d, cycles: 4) when 0x16 then ld8(:d, :immediate8, cycles: 8) when 0x17 then rla(cycles: 4) when 0x18 then jr(condition: true) when 0x19 then add16(:hl, :de, cycles: 8) when 0x1a then ld8(:a, :indirect_de, cycles: 8) when 0x1b then dec16(:de, cycles: 8) when 0x1c then inc8(:e, cycles: 4) when 0x1d then dec8(:e, cycles: 4) when 0x1e then ld8(:e, :immediate8, cycles: 8) when 0x1f then rra(cycles: 4) when 0x20 then jr(condition: !flag_z) when 0x21 then ld16(:hl, :immediate16, cycles: 12) when 0x22 then ld8(:hl_inc, :a, cycles: 8) when 0x23 then inc16(:hl, cycles: 8) when 0x24 then inc8(:h, cycles: 4) when 0x25 then dec8(:h, cycles: 4) when 0x26 then ld8(:h, :immediate8, cycles: 8) when 0x27 then daa(cycles: 4) when 0x28 then jr(condition: flag_z) when 0x29 then add16(:hl, :hl, cycles: 8) when 0x2a then ld8(:a, :hl_inc, cycles: 8) when 0x2b then dec16(:hl, cycles: 8) when 0x2c then inc8(:l, cycles: 4) when 0x2d then dec8(:l, cycles: 4) when 0x2e then ld8(:l, :immediate8, cycles: 8) when 0x2f then cpl(cycles: 4) when 0x30 then jr(condition: !flag_c) when 0x31 then ld16(:sp, :immediate16, cycles: 12) when 0x32 then ld8(:hl_dec, :a, cycles: 8) when 0x33 then inc16(:sp, cycles: 8) when 0x34 then inc8(:indirect_hl, cycles: 12) when 0x35 then dec8(:indirect_hl, cycles: 12) when 0x36 then ld8(:indirect_hl, :immediate8, cycles: 12) when 0x37 then scf(cycles: 4) when 0x38 then jr(condition: flag_c) when 0x39 then add16(:hl, :sp, cycles: 8) when 0x3a then ld8(:a, :hl_dec, cycles: 8) when 0x3b then dec16(:sp, cycles: 8) when 0x3c then inc8(:a, cycles: 4) when 0x3d then dec8(:a, cycles: 4) when 0x3e then ld8(:a, :immediate8, cycles: 8) when 0x3f then ccf(cycles: 4) when 0x40 then ld8(:b, :b, cycles: 4) when 0x41 then ld8(:b, :c, cycles: 4) when 0x42 then ld8(:b, :d, cycles: 4) when 0x43 then ld8(:b, :e, cycles: 4) when 0x44 then ld8(:b, :h, cycles: 4) when 0x45 then ld8(:b, :l, cycles: 4) when 0x46 then ld8(:b, :indirect_hl, cycles: 8) when 0x47 then ld8(:b, :a, cycles: 4) when 0x48 then ld8(:c, :b, cycles: 4) when 0x49 then ld8(:c, :c, cycles: 4) when 0x4a then ld8(:c, :d, cycles: 4) when 0x4b then ld8(:c, :e, cycles: 4) when 0x4c then ld8(:c, :h, cycles: 4) when 0x4d then ld8(:c, :l, cycles: 4) when 0x4e then ld8(:c, :indirect_hl, cycles: 8) when 0x4f then ld8(:c, :a, cycles: 4) when 0x50 then ld8(:d, :b, cycles: 4) when 0x51 then ld8(:d, :c, cycles: 4) when 0x52 then ld8(:d, :d, cycles: 4) when 0x53 then ld8(:d, :e, cycles: 4) when 0x54 then ld8(:d, :h, cycles: 4) when 0x55 then ld8(:d, :l, cycles: 4) when 0x56 then ld8(:d, :indirect_hl, cycles: 8) when 0x57 then ld8(:d, :a, cycles: 4) when 0x58 then ld8(:e, :b, cycles: 4) when 0x59 then ld8(:e, :c, cycles: 4) when 0x5a then ld8(:e, :d, cycles: 4) when 0x5b then ld8(:e, :e, cycles: 4) when 0x5c then ld8(:e, :h, cycles: 4) when 0x5d then ld8(:e, :l, cycles: 4) when 0x5e then ld8(:e, :indirect_hl, cycles: 8) when 0x5f then ld8(:e, :a, cycles: 4) when 0x60 then ld8(:h, :b, cycles: 4) when 0x61 then ld8(:h, :c, cycles: 4) when 0x62 then ld8(:h, :d, cycles: 4) when 0x63 then ld8(:h, :e, cycles: 4) when 0x64 then ld8(:h, :h, cycles: 4) when 0x65 then ld8(:h, :l, cycles: 4) when 0x66 then ld8(:h, :indirect_hl, cycles: 8) when 0x67 then ld8(:h, :a, cycles: 4) when 0x68 then ld8(:l, :b, cycles: 4) when 0x69 then ld8(:l, :c, cycles: 4) when 0x6a then ld8(:l, :d, cycles: 4) when 0x6b then ld8(:l, :e, cycles: 4) when 0x6c then ld8(:l, :h, cycles: 4) when 0x6d then ld8(:l, :l, cycles: 4) when 0x6e then ld8(:l, :indirect_hl, cycles: 8) when 0x6f then ld8(:l, :a, cycles: 4) when 0x70 then ld8(:indirect_hl, :b, cycles: 8) when 0x71 then ld8(:indirect_hl, :c, cycles: 8) when 0x72 then ld8(:indirect_hl, :d, cycles: 8) when 0x73 then ld8(:indirect_hl, :e, cycles: 8) when 0x74 then ld8(:indirect_hl, :h, cycles: 8) when 0x75 then ld8(:indirect_hl, :l, cycles: 8) when 0x76 then halt(cycles: 4) when 0x77 then ld8(:indirect_hl, :a, cycles: 8) when 0x78 then ld8(:a, :b, cycles: 4) when 0x79 then ld8(:a, :c, cycles: 4) when 0x7a then ld8(:a, :d, cycles: 4) when 0x7b then ld8(:a, :e, cycles: 4) when 0x7c then ld8(:a, :h, cycles: 4) when 0x7d then ld8(:a, :l, cycles: 4) when 0x7e then ld8(:a, :indirect_hl, cycles: 8) when 0x7f then ld8(:a, :a, cycles: 4) when 0x80 then add8(:b, cycles: 4) when 0x81 then add8(:c, cycles: 4) when 0x82 then add8(:d, cycles: 4) when 0x83 then add8(:e, cycles: 4) when 0x84 then add8(:h, cycles: 4) when 0x85 then add8(:l, cycles: 4) when 0x86 then add8(:indirect_hl, cycles: 8) when 0x87 then add8(:a, cycles: 4) when 0x88 then adc8(:b, cycles: 4) when 0x89 then adc8(:c, cycles: 4) when 0x8a then adc8(:d, cycles: 4) when 0x8b then adc8(:e, cycles: 4) when 0x8c then adc8(:h, cycles: 4) when 0x8d then adc8(:l, cycles: 4) when 0x8e then adc8(:indirect_hl, cycles: 8) when 0x8f then adc8(:a, cycles: 4) when 0x90 then sub8(:b, cycles: 4) when 0x91 then sub8(:c, cycles: 4) when 0x92 then sub8(:d, cycles: 4) when 0x93 then sub8(:e, cycles: 4) when 0x94 then sub8(:h, cycles: 4) when 0x95 then sub8(:l, cycles: 4) when 0x96 then sub8(:indirect_hl, cycles: 8) when 0x97 then sub8(:a, cycles: 4) when 0x98 then sbc8(:b, cycles: 4) when 0x99 then sbc8(:c, cycles: 4) when 0x9a then sbc8(:d, cycles: 4) when 0x9b then sbc8(:e, cycles: 4) when 0x9c then sbc8(:h, cycles: 4) when 0x9d then sbc8(:l, cycles: 4) when 0x9e then sbc8(:indirect_hl, cycles: 8) when 0x9f then sbc8(:a, cycles: 4) when 0xa0 then and8(:b, cycles: 4) when 0xa1 then and8(:c, cycles: 4) when 0xa2 then and8(:d, cycles: 4) when 0xa3 then and8(:e, cycles: 4) when 0xa4 then and8(:h, cycles: 4) when 0xa5 then and8(:l, cycles: 4) when 0xa6 then and8(:indirect_hl, cycles: 8) when 0xa7 then and8(:a, cycles: 4) when 0xa8 then xor8(:b, cycles: 4) when 0xa9 then xor8(:c, cycles: 4) when 0xaa then xor8(:d, cycles: 4) when 0xab then xor8(:e, cycles: 4) when 0xac then xor8(:h, cycles: 4) when 0xad then xor8(:l, cycles: 4) when 0xae then xor8(:indirect_hl, cycles: 8) when 0xaf then xor8(:a, cycles: 4) when 0xb0 then or8(:b, cycles: 4) when 0xb1 then or8(:c, cycles: 4) when 0xb2 then or8(:d, cycles: 4) when 0xb3 then or8(:e, cycles: 4) when 0xb4 then or8(:h, cycles: 4) when 0xb5 then or8(:l, cycles: 4) when 0xb6 then or8(:indirect_hl, cycles: 8) when 0xb7 then or8(:a, cycles: 4) when 0xb8 then cp8(:b, cycles: 4) when 0xb9 then cp8(:c, cycles: 4) when 0xba then cp8(:d, cycles: 4) when 0xbb then cp8(:e, cycles: 4) when 0xbc then cp8(:h, cycles: 4) when 0xbd then cp8(:l, cycles: 4) when 0xbe then cp8(:indirect_hl, cycles: 8) when 0xbf then cp8(:a, cycles: 4) when 0xc0 then ret_if(condition: !flag_z) when 0xc1 then pop16(:bc, cycles: 12) when 0xc2 then jp(:immediate16, condition: !flag_z) when 0xc3 then jp(:immediate16, condition: true) when 0xc4 then call16(:immediate16, condition: !flag_z) when 0xc5 then push16(:bc, cycles: 16) when 0xc6 then add8(:immediate8, cycles: 8) when 0xc7 then rst(0x00, cycles: 16) when 0xc8 then ret_if(condition: flag_z) when 0xc9 then ret(cycles: 16) when 0xca then jp(:immediate16, condition: flag_z) when 0xcc then call16(:immediate16, condition: flag_z) when 0xcd then call16(:immediate16, condition: true) when 0xce then adc8(:immediate8, cycles: 8) when 0xcf then rst(0x08, cycles: 16) when 0xd0 then ret_if(condition: !flag_c) when 0xd1 then pop16(:de, cycles: 12) when 0xd2 then jp(:immediate16, condition: !flag_c) when 0xd4 then call16(:immediate16, condition: !flag_c) when 0xd5 then push16(:de, cycles: 16) when 0xd6 then sub8(:immediate8, cycles: 8) when 0xd7 then rst(0x10, cycles: 16) when 0xd8 then ret_if(condition: flag_c) when 0xd9 then reti(cycles: 16) when 0xda then jp(:immediate16, condition: flag_c) when 0xdc then call16(:immediate16, condition: flag_c) when 0xde then sbc8(:immediate8, cycles: 8) when 0xdf then rst(0x18, cycles: 16) when 0xe0 then ld8(:ff00, :a, cycles: 12) when 0xe1 then pop16(:hl, cycles: 12) when 0xe2 then ld8(:ff00_c, :a, cycles: 8) when 0xe5 then push16(:hl, cycles: 16) when 0xe6 then and8(:immediate8, cycles: 8) when 0xe7 then rst(0x20, cycles: 16) when 0xe8 then add_sp_r8(cycles: 16) when 0xe9 then jp_hl(cycles: 4) when 0xea then ld8(:direct8, :a, cycles: 16) when 0xee then xor8(:immediate8, cycles: 8) when 0xef then rst(0x28, cycles: 16) when 0xf0 then ld8(:a, :ff00, cycles: 12) when 0xf1 then pop16(:af, cycles: 12) when 0xf2 then ld8(:a, :ff00_c, cycles: 8) when 0xf3 then di(cycles: 4) when 0xf5 then push16(:af, cycles: 16) when 0xf6 then or8(:immediate8, cycles: 8) when 0xf7 then rst(0x30, cycles: 16) when 0xf8 then ld_hl_sp_r8(cycles: 12) when 0xf9 then ld16(:sp, :hl, cycles: 8) when 0xfa then ld8(:a, :direct8, cycles: 16) when 0xfb then ei(cycles: 4) when 0xfe then cp8(:immediate8, cycles: 8) when 0xff then rst(0x38, cycles: 16) when 0xcb # CB prefix opcode = read_byte_and_advance_pc case opcode when 0x00 then rlc8(:b, cycles: 8) when 0x01 then rlc8(:c, cycles: 8) when 0x02 then rlc8(:d, cycles: 8) when 0x03 then rlc8(:e, cycles: 8) when 0x04 then rlc8(:h, cycles: 8) when 0x05 then rlc8(:l, cycles: 8) when 0x06 then rlc8(:indirect_hl, cycles: 16) when 0x07 then rlc8(:a, cycles: 8) when 0x08 then rrc8(:b, cycles: 8) when 0x09 then rrc8(:c, cycles: 8) when 0x0a then rrc8(:d, cycles: 8) when 0x0b then rrc8(:e, cycles: 8) when 0x0c then rrc8(:h, cycles: 8) when 0x0d then rrc8(:l, cycles: 8) when 0x0e then rrc8(:indirect_hl, cycles: 16) when 0x0f then rrc8(:a, cycles: 8) when 0x10 then rl8(:b, cycles: 8) when 0x11 then rl8(:c, cycles: 8) when 0x12 then rl8(:d, cycles: 8) when 0x13 then rl8(:e, cycles: 8) when 0x14 then rl8(:h, cycles: 8) when 0x15 then rl8(:l, cycles: 8) when 0x16 then rl8(:indirect_hl, cycles: 16) when 0x17 then rl8(:a, cycles: 8) when 0x18 then rr8(:b, cycles: 8) when 0x19 then rr8(:c, cycles: 8) when 0x1a then rr8(:d, cycles: 8) when 0x1b then rr8(:e, cycles: 8) when 0x1c then rr8(:h, cycles: 8) when 0x1d then rr8(:l, cycles: 8) when 0x1e then rr8(:indirect_hl, cycles: 16) when 0x1f then rr8(:a, cycles: 8) when 0x20 then sla8(:b, cycles: 8) when 0x21 then sla8(:c, cycles: 8) when 0x22 then sla8(:d, cycles: 8) when 0x23 then sla8(:e, cycles: 8) when 0x24 then sla8(:h, cycles: 8) when 0x25 then sla8(:l, cycles: 8) when 0x26 then sla8(:indirect_hl, cycles: 16) when 0x27 then sla8(:a, cycles: 8) when 0x28 then sra8(:b, cycles: 8) when 0x29 then sra8(:c, cycles: 8) when 0x2a then sra8(:d, cycles: 8) when 0x2b then sra8(:e, cycles: 8) when 0x2c then sra8(:h, cycles: 8) when 0x2d then sra8(:l, cycles: 8) when 0x2e then sra8(:indirect_hl, cycles: 16) when 0x2f then sra8(:a, cycles: 8) when 0x30 then swap8(:b, cycles: 8) when 0x31 then swap8(:c, cycles: 8) when 0x32 then swap8(:d, cycles: 8) when 0x33 then swap8(:e, cycles: 8) when 0x34 then swap8(:h, cycles: 8) when 0x35 then swap8(:l, cycles: 8) when 0x36 then swap8(:indirect_hl, cycles: 16) when 0x37 then swap8(:a, cycles: 8) when 0x38 then srl8(:b, cycles: 8) when 0x39 then srl8(:c, cycles: 8) when 0x3a then srl8(:d, cycles: 8) when 0x3b then srl8(:e, cycles: 8) when 0x3c then srl8(:h, cycles: 8) when 0x3d then srl8(:l, cycles: 8) when 0x3e then srl8(:indirect_hl, cycles: 16) when 0x3f then srl8(:a, cycles: 8) when 0x40 then bit8(0, :b, cycles: 8) when 0x41 then bit8(0, :c, cycles: 8) when 0x42 then bit8(0, :d, cycles: 8) when 0x43 then bit8(0, :e, cycles: 8) when 0x44 then bit8(0, :h, cycles: 8) when 0x45 then bit8(0, :l, cycles: 8) when 0x46 then bit8(0, :indirect_hl, cycles: 12) when 0x47 then bit8(0, :a, cycles: 8) when 0x48 then bit8(1, :b, cycles: 8) when 0x49 then bit8(1, :c, cycles: 8) when 0x4a then bit8(1, :d, cycles: 8) when 0x4b then bit8(1, :e, cycles: 8) when 0x4c then bit8(1, :h, cycles: 8) when 0x4d then bit8(1, :l, cycles: 8) when 0x4e then bit8(1, :indirect_hl, cycles: 12) when 0x4f then bit8(1, :a, cycles: 8) when 0x50 then bit8(2, :b, cycles: 8) when 0x51 then bit8(2, :c, cycles: 8) when 0x52 then bit8(2, :d, cycles: 8) when 0x53 then bit8(2, :e, cycles: 8) when 0x54 then bit8(2, :h, cycles: 8) when 0x55 then bit8(2, :l, cycles: 8) when 0x56 then bit8(2, :indirect_hl, cycles: 12) when 0x57 then bit8(2, :a, cycles: 8) when 0x58 then bit8(3, :b, cycles: 8) when 0x59 then bit8(3, :c, cycles: 8) when 0x5a then bit8(3, :d, cycles: 8) when 0x5b then bit8(3, :e, cycles: 8) when 0x5c then bit8(3, :h, cycles: 8) when 0x5d then bit8(3, :l, cycles: 8) when 0x5e then bit8(3, :indirect_hl, cycles: 12) when 0x5f then bit8(3, :a, cycles: 8) when 0x60 then bit8(4, :b, cycles: 8) when 0x61 then bit8(4, :c, cycles: 8) when 0x62 then bit8(4, :d, cycles: 8) when 0x63 then bit8(4, :e, cycles: 8) when 0x64 then bit8(4, :h, cycles: 8) when 0x65 then bit8(4, :l, cycles: 8) when 0x66 then bit8(4, :indirect_hl, cycles: 12) when 0x67 then bit8(4, :a, cycles: 8) when 0x68 then bit8(5, :b, cycles: 8) when 0x69 then bit8(5, :c, cycles: 8) when 0x6a then bit8(5, :d, cycles: 8) when 0x6b then bit8(5, :e, cycles: 8) when 0x6c then bit8(5, :h, cycles: 8) when 0x6d then bit8(5, :l, cycles: 8) when 0x6e then bit8(5, :indirect_hl, cycles: 12) when 0x6f then bit8(5, :a, cycles: 8) when 0x70 then bit8(6, :b, cycles: 8) when 0x71 then bit8(6, :c, cycles: 8) when 0x72 then bit8(6, :d, cycles: 8) when 0x73 then bit8(6, :e, cycles: 8) when 0x74 then bit8(6, :h, cycles: 8) when 0x75 then bit8(6, :l, cycles: 8) when 0x76 then bit8(6, :indirect_hl, cycles: 12) when 0x77 then bit8(6, :a, cycles: 8) when 0x78 then bit8(7, :b, cycles: 8) when 0x79 then bit8(7, :c, cycles: 8) when 0x7a then bit8(7, :d, cycles: 8) when 0x7b then bit8(7, :e, cycles: 8) when 0x7c then bit8(7, :h, cycles: 8) when 0x7d then bit8(7, :l, cycles: 8) when 0x7e then bit8(7, :indirect_hl, cycles: 12) when 0x7f then bit8(7, :a, cycles: 8) when 0x80 then res8(0, :b, cycles: 8) when 0x81 then res8(0, :c, cycles: 8) when 0x82 then res8(0, :d, cycles: 8) when 0x83 then res8(0, :e, cycles: 8) when 0x84 then res8(0, :h, cycles: 8) when 0x85 then res8(0, :l, cycles: 8) when 0x86 then res8(0, :indirect_hl, cycles: 16) when 0x87 then res8(0, :a, cycles: 8) when 0x88 then res8(1, :b, cycles: 8) when 0x89 then res8(1, :c, cycles: 8) when 0x8a then res8(1, :d, cycles: 8) when 0x8b then res8(1, :e, cycles: 8) when 0x8c then res8(1, :h, cycles: 8) when 0x8d then res8(1, :l, cycles: 8) when 0x8e then res8(1, :indirect_hl, cycles: 16) when 0x8f then res8(1, :a, cycles: 8) when 0x90 then res8(2, :b, cycles: 8) when 0x91 then res8(2, :c, cycles: 8) when 0x92 then res8(2, :d, cycles: 8) when 0x93 then res8(2, :e, cycles: 8) when 0x94 then res8(2, :h, cycles: 8) when 0x95 then res8(2, :l, cycles: 8) when 0x96 then res8(2, :indirect_hl, cycles: 16) when 0x97 then res8(2, :a, cycles: 8) when 0x98 then res8(3, :b, cycles: 8) when 0x99 then res8(3, :c, cycles: 8) when 0x9a then res8(3, :d, cycles: 8) when 0x9b then res8(3, :e, cycles: 8) when 0x9c then res8(3, :h, cycles: 8) when 0x9d then res8(3, :l, cycles: 8) when 0x9e then res8(3, :indirect_hl, cycles: 16) when 0x9f then res8(3, :a, cycles: 8) when 0xa0 then res8(4, :b, cycles: 8) when 0xa1 then res8(4, :c, cycles: 8) when 0xa2 then res8(4, :d, cycles: 8) when 0xa3 then res8(4, :e, cycles: 8) when 0xa4 then res8(4, :h, cycles: 8) when 0xa5 then res8(4, :l, cycles: 8) when 0xa6 then res8(4, :indirect_hl, cycles: 16) when 0xa7 then res8(4, :a, cycles: 8) when 0xa8 then res8(5, :b, cycles: 8) when 0xa9 then res8(5, :c, cycles: 8) when 0xaa then res8(5, :d, cycles: 8) when 0xab then res8(5, :e, cycles: 8) when 0xac then res8(5, :h, cycles: 8) when 0xad then res8(5, :l, cycles: 8) when 0xae then res8(5, :indirect_hl, cycles: 16) when 0xaf then res8(5, :a, cycles: 8) when 0xb0 then res8(6, :b, cycles: 8) when 0xb1 then res8(6, :c, cycles: 8) when 0xb2 then res8(6, :d, cycles: 8) when 0xb3 then res8(6, :e, cycles: 8) when 0xb4 then res8(6, :h, cycles: 8) when 0xb5 then res8(6, :l, cycles: 8) when 0xb6 then res8(6, :indirect_hl, cycles: 16) when 0xb7 then res8(6, :a, cycles: 8) when 0xb8 then res8(7, :b, cycles: 8) when 0xb9 then res8(7, :c, cycles: 8) when 0xba then res8(7, :d, cycles: 8) when 0xbb then res8(7, :e, cycles: 8) when 0xbc then res8(7, :h, cycles: 8) when 0xbd then res8(7, :l, cycles: 8) when 0xbe then res8(7, :indirect_hl, cycles: 16) when 0xbf then res8(7, :a, cycles: 8) when 0xc0 then set8(0, :b, cycles: 8) when 0xc1 then set8(0, :c, cycles: 8) when 0xc2 then set8(0, :d, cycles: 8) when 0xc3 then set8(0, :e, cycles: 8) when 0xc4 then set8(0, :h, cycles: 8) when 0xc5 then set8(0, :l, cycles: 8) when 0xc6 then set8(0, :indirect_hl, cycles: 16) when 0xc7 then set8(0, :a, cycles: 8) when 0xc8 then set8(1, :b, cycles: 8) when 0xc9 then set8(1, :c, cycles: 8) when 0xca then set8(1, :d, cycles: 8) when 0xcb then set8(1, :e, cycles: 8) when 0xcc then set8(1, :h, cycles: 8) when 0xcd then set8(1, :l, cycles: 8) when 0xce then set8(1, :indirect_hl, cycles: 16) when 0xcf then set8(1, :a, cycles: 8) when 0xd0 then set8(2, :b, cycles: 8) when 0xd1 then set8(2, :c, cycles: 8) when 0xd2 then set8(2, :d, cycles: 8) when 0xd3 then set8(2, :e, cycles: 8) when 0xd4 then set8(2, :h, cycles: 8) when 0xd5 then set8(2, :l, cycles: 8) when 0xd6 then set8(2, :indirect_hl, cycles: 16) when 0xd7 then set8(2, :a, cycles: 8) when 0xd8 then set8(3, :b, cycles: 8) when 0xd9 then set8(3, :c, cycles: 8) when 0xda then set8(3, :d, cycles: 8) when 0xdb then set8(3, :e, cycles: 8) when 0xdc then set8(3, :h, cycles: 8) when 0xdd then set8(3, :l, cycles: 8) when 0xde then set8(3, :indirect_hl, cycles: 16) when 0xdf then set8(3, :a, cycles: 8) when 0xe0 then set8(4, :b, cycles: 8) when 0xe1 then set8(4, :c, cycles: 8) when 0xe2 then set8(4, :d, cycles: 8) when 0xe3 then set8(4, :e, cycles: 8) when 0xe4 then set8(4, :h, cycles: 8) when 0xe5 then set8(4, :l, cycles: 8) when 0xe6 then set8(4, :indirect_hl, cycles: 16) when 0xe7 then set8(4, :a, cycles: 8) when 0xe8 then set8(5, :b, cycles: 8) when 0xe9 then set8(5, :c, cycles: 8) when 0xea then set8(5, :d, cycles: 8) when 0xeb then set8(5, :e, cycles: 8) when 0xec then set8(5, :h, cycles: 8) when 0xed then set8(5, :l, cycles: 8) when 0xee then set8(5, :indirect_hl, cycles: 16) when 0xef then set8(5, :a, cycles: 8) when 0xf0 then set8(6, :b, cycles: 8) when 0xf1 then set8(6, :c, cycles: 8) when 0xf2 then set8(6, :d, cycles: 8) when 0xf3 then set8(6, :e, cycles: 8) when 0xf4 then set8(6, :h, cycles: 8) when 0xf5 then set8(6, :l, cycles: 8) when 0xf6 then set8(6, :indirect_hl, cycles: 16) when 0xf7 then set8(6, :a, cycles: 8) when 0xf8 then set8(7, :b, cycles: 8) when 0xf9 then set8(7, :c, cycles: 8) when 0xfa then set8(7, :d, cycles: 8) when 0xfb then set8(7, :e, cycles: 8) when 0xfc then set8(7, :h, cycles: 8) when 0xfd then set8(7, :l, cycles: 8) when 0xfe then set8(7, :indirect_hl, cycles: 16) when 0xff then set8(7, :a, cycles: 8) else raise "unknown opcode: 0xcb 0x#{'%02x' % opcode}" end else raise "unknown opcode: 0x#{'%02x' % opcode}" end end |