Mercurial > repos > blastem
comparison z80.cpu @ 2441:4435abe5db5e
Sugar for binary operators in CPU DSL
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 11 Feb 2024 20:15:00 -0800 |
parents | 338c78da3fff |
children | 52cfc7b14dd2 |
comparison
equal
deleted
inserted
replaced
2440:338c78da3fff | 2441:4435abe5db5e |
---|---|
195 not last_flag_result invert | 195 not last_flag_result invert |
196 invert &= 0x80 | 196 invert &= 0x80 |
197 | 197 |
198 case 7 | 198 case 7 |
199 meta istrue invert | 199 meta istrue invert |
200 and 0x80 last_flag_result invert | 200 invert = 0x80 & last_flag_result |
201 end | 201 end |
202 | 202 |
203 z80_fetch_hl | 203 z80_fetch_hl |
204 lsl h 8 scratch1 | 204 scratch1 = h << 8 |
205 scratch1 |= l | 205 scratch1 |= l |
206 ocall read_8 | 206 ocall read_8 |
207 | 207 |
208 z80_store_hl | 208 z80_store_hl |
209 lsl h 8 scratch2 | 209 scratch2 = h << 8 |
210 scratch2 |= l | 210 scratch2 |= l |
211 ocall write_8 | 211 ocall write_8 |
212 | 212 |
213 z80_fetch_immed | 213 z80_fetch_immed |
214 scratch1 = pc | 214 scratch1 = pc |
254 01DDDSSS ld_from_reg | 254 01DDDSSS ld_from_reg |
255 main.D = main.S | 255 main.D = main.S |
256 | 256 |
257 dd 01DDD100 ld_from_ixh | 257 dd 01DDD100 ld_from_ixh |
258 invalid D 6 | 258 invalid D 6 |
259 lsr ix 8 main.D | 259 main.D = ix >> 8 |
260 | 260 |
261 dd 01100SSS ld_to_ixh | 261 dd 01100SSS ld_to_ixh |
262 invalid S 6 | 262 invalid S 6 |
263 local tmp 16 | 263 local tmp 16 |
264 ix &= 0xFF | 264 ix &= 0xFF |
265 lsl main.S 8 tmp | 265 tmp = main.S << 8 |
266 ix |= tmp | 266 ix |= tmp |
267 | 267 |
268 dd 0110D10S ld_ixb_to_ixb | 268 dd 0110D10S ld_ixb_to_ixb |
269 | 269 |
270 dd 01DDD101 ld_from_ixl | 270 dd 01DDD101 ld_from_ixl |
276 ix &= 0xFF00 | 276 ix &= 0xFF00 |
277 ix |= main.S | 277 ix |= main.S |
278 | 278 |
279 dd 01100101 ld_ixl_to_ixh | 279 dd 01100101 ld_ixl_to_ixh |
280 local tmp 16 | 280 local tmp 16 |
281 lsl ix 8 tmp | 281 tmp = ix << 8 |
282 ix &= 0xFF | 282 ix &= 0xFF |
283 ix |= tmp | 283 ix |= tmp |
284 | 284 |
285 dd 01101100 ld_ixh_to_ixl | 285 dd 01101100 ld_ixh_to_ixl |
286 local tmp 16 | 286 local tmp 16 |
287 lsr ix 8 tmp | 287 tmp = ix >> 8 |
288 ix &= 0xFF00 | 288 ix &= 0xFF00 |
289 ix |= tmp | 289 ix |= tmp |
290 | 290 |
291 fd 01DDD100 ld_from_iyh | 291 fd 01DDD100 ld_from_iyh |
292 invalid D 6 | 292 invalid D 6 |
293 lsr iy 8 main.D | 293 main.D = iy >> 8 |
294 | 294 |
295 fd 01100SSS ld_to_iyh | 295 fd 01100SSS ld_to_iyh |
296 invalid S 6 | 296 invalid S 6 |
297 local tmp 16 | 297 local tmp 16 |
298 iy &= 0xFF | 298 iy &= 0xFF |
299 lsl main.S 8 tmp | 299 tmp = main.S << 8 |
300 iy |= tmp | 300 iy |= tmp |
301 | 301 |
302 fd 0110D10S ld_iyb_to_iyb | 302 fd 0110D10S ld_iyb_to_iyb |
303 | 303 |
304 fd 01DDD101 ld_from_iyl | 304 fd 01DDD101 ld_from_iyl |
310 iy &= 0xFF00 | 310 iy &= 0xFF00 |
311 iy |= main.S | 311 iy |= main.S |
312 | 312 |
313 fd 01100101 ld_iyl_to_iyh | 313 fd 01100101 ld_iyl_to_iyh |
314 local tmp 16 | 314 local tmp 16 |
315 lsl iy 8 tmp | 315 tmp = iy << 8 |
316 iy &= 0xFF | 316 iy &= 0xFF |
317 iy |= tmp | 317 iy |= tmp |
318 | 318 |
319 fd 01101100 ld_iyh_to_iyl | 319 fd 01101100 ld_iyh_to_iyl |
320 local tmp 16 | 320 local tmp 16 |
321 lsr iy 8 tmp | 321 tmp = iy >> 8 |
322 iy &= 0xFF00 | 322 iy &= 0xFF00 |
323 iy |= tmp | 323 iy |= tmp |
324 | 324 |
325 z80_calc_index | 325 z80_calc_index |
326 arg index 16 | 326 arg index 16 |
409 cycles 2 | 409 cycles 2 |
410 scratch2 = wz | 410 scratch2 = wz |
411 ocall write_8 | 411 ocall write_8 |
412 | 412 |
413 00001010 ld_a_from_bc | 413 00001010 ld_a_from_bc |
414 lsl b 8 wz | 414 wz = b << 8 |
415 wz |= c | 415 wz |= c |
416 scratch1 = wz | 416 scratch1 = wz |
417 wz += 1 | 417 wz += 1 |
418 ocall read_8 | 418 ocall read_8 |
419 a = scratch1 | 419 a = scratch1 |
420 | 420 |
421 00011010 ld_a_from_de | 421 00011010 ld_a_from_de |
422 lsl d 8 wz | 422 wz = d << 8 |
423 wz |= e | 423 wz |= e |
424 scratch1 = wz | 424 scratch1 = wz |
425 wz += 1 | 425 wz += 1 |
426 ocall read_8 | 426 ocall read_8 |
427 a = scratch1 | 427 a = scratch1 |
433 ocall read_8 | 433 ocall read_8 |
434 a = scratch1 | 434 a = scratch1 |
435 | 435 |
436 00000010 ld_a_to_bc | 436 00000010 ld_a_to_bc |
437 local tmp 8 | 437 local tmp 8 |
438 lsl b 8 scratch2 | 438 scratch2 = b << 8 |
439 scratch2 |= c | 439 scratch2 |= c |
440 scratch1 = a | 440 scratch1 = a |
441 add c 1 tmp | 441 tmp = c + 1 |
442 lsl a 8 wz | 442 wz = a << 8 |
443 wz |= tmp | 443 wz |= tmp |
444 ocall write_8 | 444 ocall write_8 |
445 | 445 |
446 00010010 ld_a_to_de | 446 00010010 ld_a_to_de |
447 local tmp 8 | 447 local tmp 8 |
448 lsl d 8 scratch2 | 448 scratch2 = d << 8 |
449 scratch2 |= e | 449 scratch2 |= e |
450 scratch1 = a | 450 scratch1 = a |
451 add e 1 tmp | 451 tmp = e + 1 |
452 lsl a 8 wz | 452 wz = a << 8 |
453 wz |= tmp | 453 wz |= tmp |
454 ocall write_8 | 454 ocall write_8 |
455 | 455 |
456 00110010 ld_a_to_immed | 456 00110010 ld_a_to_immed |
457 local tmp 16 | 457 local tmp 16 |
459 scratch2 = wz | 459 scratch2 = wz |
460 scratch1 = a | 460 scratch1 = a |
461 wz += 1 | 461 wz += 1 |
462 ocall write_8 | 462 ocall write_8 |
463 wz &= 0xFF | 463 wz &= 0xFF |
464 lsl a 8 tmp | 464 tmp = a << 8 |
465 wz |= tmp | 465 wz |= tmp |
466 | 466 |
467 ed 01000111 ld_i_a | 467 ed 01000111 ld_i_a |
468 i = a | 468 i = a |
469 cycles 1 | 469 cycles 1 |
470 | 470 |
471 ed 01001111 ld_r_a | 471 ed 01001111 ld_r_a |
472 r = a | 472 r = a |
473 and 0x80 a rhigh | 473 rhigh = 0x80 & a |
474 cycles 1 | 474 cycles 1 |
475 | 475 |
476 ed 01011111 ld_a_r | 476 ed 01011111 ld_a_r |
477 cycles 1 | 477 cycles 1 |
478 and 0x7F r a | 478 a = 0x7F & r |
479 a |= rhigh | 479 a |= rhigh |
480 update_flags SZYH0XN0 | 480 update_flags SZYH0XN0 |
481 pvflag = iff2 | 481 pvflag = iff2 |
482 | 482 |
483 ed 01010111 ld_a_i | 483 ed 01010111 ld_a_i |
584 scratch2 = wz | 584 scratch2 = wz |
585 scratch1 = ix | 585 scratch1 = ix |
586 ocall write_8 | 586 ocall write_8 |
587 wz += 1 | 587 wz += 1 |
588 scratch2 = wz | 588 scratch2 = wz |
589 lsr ix 8 scratch1 | 589 scratch1 = ix >> 8 |
590 ocall write_8 | 590 ocall write_8 |
591 wz += 1 | 591 wz += 1 |
592 | 592 |
593 fd 00100010 ld_iy_to_immed | 593 fd 00100010 ld_iy_to_immed |
594 z80_fetch_immed16 | 594 z80_fetch_immed16 |
595 scratch2 = wz | 595 scratch2 = wz |
596 scratch1 = iy | 596 scratch1 = iy |
597 ocall write_8 | 597 ocall write_8 |
598 wz += 1 | 598 wz += 1 |
599 scratch2 = wz | 599 scratch2 = wz |
600 lsr iy 8 scratch1 | 600 scratch1 = iy >> 8 |
601 ocall write_8 | 601 ocall write_8 |
602 wz += 1 | 602 wz += 1 |
603 | 603 |
604 z80_regpair_to_immed | 604 z80_regpair_to_immed |
605 z80_fetch_immed16 | 605 z80_fetch_immed16 |
628 z80_regpair_to_immed | 628 z80_regpair_to_immed |
629 | 629 |
630 ed 01110011 ld_sp_to_immed | 630 ed 01110011 ld_sp_to_immed |
631 meta low sp | 631 meta low sp |
632 local sph 8 | 632 local sph 8 |
633 lsr sp 8 sph | 633 sph = sp >> 8 |
634 meta high sph | 634 meta high sph |
635 z80_regpair_to_immed | 635 z80_regpair_to_immed |
636 | 636 |
637 11111001 ld_sp_hl | 637 11111001 ld_sp_hl |
638 cycles 2 | 638 cycles 2 |
639 lsl h 8 sp | 639 sp = h << 8 |
640 sp |= l | 640 sp |= l |
641 | 641 |
642 dd 11111001 ld_sp_ix | 642 dd 11111001 ld_sp_ix |
643 cycles 2 | 643 cycles 2 |
644 sp = ix | 644 sp = ix |
678 meta low f | 678 meta low f |
679 z80_push | 679 z80_push |
680 | 680 |
681 dd 11100101 push_ix | 681 dd 11100101 push_ix |
682 local ixh 8 | 682 local ixh 8 |
683 lsr ix 8 ixh | 683 ixh = ix >> 8 |
684 meta high ixh | 684 meta high ixh |
685 meta low ix | 685 meta low ix |
686 z80_push | 686 z80_push |
687 | 687 |
688 fd 11100101 push_iy | 688 fd 11100101 push_iy |
689 local iyh 8 | 689 local iyh 8 |
690 lsr iy 8 iyh | 690 iyh = iy >> 8 |
691 meta high iyh | 691 meta high iyh |
692 meta low iy | 692 meta low iy |
693 z80_push | 693 z80_push |
694 | 694 |
695 z80_pop | 695 z80_pop |
725 dd 11100001 pop_ix | 725 dd 11100001 pop_ix |
726 local ixh 16 | 726 local ixh 16 |
727 meta high ixh | 727 meta high ixh |
728 meta low ix | 728 meta low ix |
729 z80_pop | 729 z80_pop |
730 lsl ixh 8 ixh | 730 ixh <<= 8 |
731 or ixh ix ix | 731 ix |= ixh |
732 | 732 |
733 fd 11100001 pop_iy | 733 fd 11100001 pop_iy |
734 local iyh 16 | 734 local iyh 16 |
735 meta high iyh | 735 meta high iyh |
736 meta low iy | 736 meta low iy |
759 ocall read_8 | 759 ocall read_8 |
760 xchg l scratch1 | 760 xchg l scratch1 |
761 cycles 1 | 761 cycles 1 |
762 scratch2 = sp | 762 scratch2 = sp |
763 ocall write_8 | 763 ocall write_8 |
764 add 1 sp scratch1 | 764 scratch1 = sp + 1 |
765 ocall read_8 | 765 ocall read_8 |
766 xchg h scratch1 | 766 xchg h scratch1 |
767 cycles 2 | 767 cycles 2 |
768 add 1 sp scratch2 | 768 scratch2 = sp + 1 |
769 ocall write_8 | 769 ocall write_8 |
770 lsl h 8 wz | 770 wz = h << 8 |
771 wz |= l | 771 wz |= l |
772 | 772 |
773 dd 11100011 ex_sp_ix | 773 dd 11100011 ex_sp_ix |
774 scratch1 = sp | 774 scratch1 = sp |
775 ocall read_8 | 775 ocall read_8 |
776 wz = scratch1 | 776 wz = scratch1 |
777 scratch1 = ix | 777 scratch1 = ix |
778 cycles 1 | 778 cycles 1 |
779 scratch2 = sp | 779 scratch2 = sp |
780 ocall write_8 | 780 ocall write_8 |
781 add 1 sp scratch1 | 781 scratch1 = sp + 1 |
782 ocall read_8 | 782 ocall read_8 |
783 scratch1 <<= 8 | 783 scratch1 <<= 8 |
784 wz |= scratch1 | 784 wz |= scratch1 |
785 lsr ix 8 scratch1 | 785 scratch1 = ix >> 8 |
786 cycles 2 | 786 cycles 2 |
787 add 1 sp scratch2 | 787 scratch2 = sp + 1 |
788 ocall write_8 | 788 ocall write_8 |
789 ix = wz | 789 ix = wz |
790 | 790 |
791 fd 11100011 ex_sp_iy | 791 fd 11100011 ex_sp_iy |
792 scratch1 = sp | 792 scratch1 = sp |
794 wz = scratch1 | 794 wz = scratch1 |
795 scratch1 = iy | 795 scratch1 = iy |
796 cycles 1 | 796 cycles 1 |
797 scratch2 = sp | 797 scratch2 = sp |
798 ocall write_8 | 798 ocall write_8 |
799 add 1 sp scratch1 | 799 scratch1 = sp + 1 |
800 ocall read_8 | 800 ocall read_8 |
801 scratch1 <<= 8 | 801 scratch1 <<= 8 |
802 wz |= scratch1 | 802 wz |= scratch1 |
803 lsr iy 8 scratch1 | 803 scratch1 = iy >> 8 |
804 cycles 2 | 804 cycles 2 |
805 add 1 sp scratch2 | 805 scratch2 = sp + 1 |
806 ocall write_8 | 806 ocall write_8 |
807 iy = wz | 807 iy = wz |
808 | 808 |
809 10000RRR add_reg | 809 10000RRR add_reg |
810 add a main.R a | 810 a += main.R |
811 update_flags SZYHVXN0C | 811 update_flags SZYHVXN0C |
812 | 812 |
813 dd 10000100 add_ixh | 813 dd 10000100 add_ixh |
814 lsr ix 8 scratch1 | 814 scratch1 = ix >> 8 |
815 add a scratch1 a | 815 a += scratch1 |
816 update_flags SZYHVXN0C | 816 update_flags SZYHVXN0C |
817 | 817 |
818 dd 10000101 add_ixl | 818 dd 10000101 add_ixl |
819 and ix 0xFF scratch1 | 819 scratch1 = ix & 0xFF |
820 add a scratch1 a | 820 a += scratch1 |
821 update_flags SZYHVXN0C | 821 update_flags SZYHVXN0C |
822 | 822 |
823 fd 10000100 add_iyh | 823 fd 10000100 add_iyh |
824 lsr iy 8 scratch1 | 824 lsr iy 8 scratch1 |
825 add a scratch1 a | 825 add a scratch1 a |