1 .title Test of Z80 / HD64180 assembler
3 offset = 0x55 ;arbitrary constants
8 ; Leading 'a' operand is optional.
9 ; If offset is ommitted 0 is assumed.
11 ;***********************************************************
12 ; add with carry to 'a'
14 adc a,offset(ix) ;DD 8E 55
15 adc a,offset(iy) ;FD 8E 55
24 ;***********************************************************
26 adc offset(ix) ;DD 8E 55
27 adc offset(iy) ;FD 8E 55
36 ;***********************************************************
37 ; add with carry register pair to 'hl'
42 ;***********************************************************
45 add a,offset(ix) ;DD 86 55
46 add a,offset(iy) ;FD 86 55
55 ;***********************************************************
56 ; add register pair to 'hl'
61 ;***********************************************************
62 ; add register pair to 'ix'
67 ;***********************************************************
68 ; add register pair to 'iy'
73 ;***********************************************************
74 ; logical 'and' operand with 'a'
76 and a,offset(ix) ;DD A6 55
77 and a,offset(iy) ;FD A6 55
86 ;***********************************************************
87 ; test bit of location or register
89 bit 0,offset(ix) ;DD CB 55 46
90 bit 0,offset(iy) ;FD CB 55 46
99 bit 1,offset(ix) ;DD CB 55 4E
100 bit 1,offset(iy) ;FD CB 55 4E
109 bit 2,offset(ix) ;DD CB 55 56
110 bit 2,offset(iy) ;FD CB 55 56
119 bit 3,offset(ix) ;DD CB 55 5E
120 bit 3,offset(iy) ;FD CB 55 5E
129 bit 4,offset(ix) ;DD CB 55 66
130 bit 4,offset(iy) ;FD CB 55 66
139 bit 5,offset(ix) ;DD CB 55 6E
140 bit 5,offset(iy) ;FD CB 55 6E
149 bit 6,offset(ix) ;DD CB 55 76
150 bit 6,offset(iy) ;FD CB 55 76
159 bit 7,offset(ix) ;DD CB 55 7E
160 bit 7,offset(iy) ;FD CB 55 7E
168 ;***********************************************************
169 ; call subroutine at nn if condition is true
178 ;***********************************************************
179 ; unconditional call to subroutine at nn
181 ;***********************************************************
182 ; complement carry flag
184 ;***********************************************************
185 ; compare operand with 'a'
187 cp a,offset(ix) ;DD BE 55
188 cp a,offset(iy) ;FD BE 55
197 ;***********************************************************
198 ; compare location (hl) and 'a'
199 ; decrement 'hl' and 'bc'
201 ;***********************************************************
202 ; compare location (hl) and 'a'
203 ; decrement 'hl' and 'bc'
204 ; repeat until 'bc' = 0
206 ;***********************************************************
207 ; compare location (hl) and 'a'
208 ; increment 'hl' and decrement 'bc'
210 ;***********************************************************
211 ; compare location (hl) and 'a'
212 ; increment 'hl' and decrement 'bc'
213 ; repeat until 'bc' = 0
215 ;***********************************************************
216 ; 1's complement of 'a'
218 ;***********************************************************
221 ;***********************************************************
224 dec offset(ix) ;DD 35 55
225 dec offset(iy) ;FD 35 55
239 ;***********************************************************
242 ;***********************************************************
243 ; decrement b and jump relative if b # 0
245 ;***********************************************************
248 ;***********************************************************
249 ; exchange location and (sp)
253 ;***********************************************************
254 ; exchange af and af'
256 ;***********************************************************
259 ;***********************************************************
265 ;***********************************************************
266 ; halt (wait for interrupt or reset)
268 ;***********************************************************
273 ;***********************************************************
274 ; load 'a' with input from device n
276 ;***********************************************************
277 ; load register with input from (c)
285 ;***********************************************************
288 inc offset(ix) ;DD 34 55
289 inc offset(iy) ;FD 34 55
303 ;***********************************************************
304 ; load location (hl) with input
306 ; decrement 'hl' and 'b'
308 ;***********************************************************
309 ; load location (hl) with input
311 ; decrement 'hl' and 'b'
312 ; repeat until 'b' = 0
314 ;***********************************************************
315 ; load location (hl) with input
317 ; increment 'hl' and decrement 'b'
319 ;***********************************************************
320 ; load location (hl) with input
322 ; increment 'hl' and decrement 'b'
323 ; repeat until 'b' = 0
325 ;***********************************************************
326 ; unconditional jump to location nn
331 ;***********************************************************
332 ; jump to location if condition is true
341 ;***********************************************************
342 ; unconditional jump relative to PC+e
344 ;***********************************************************
345 ; jump relative to PC+e if condition is true
346 jr1: jr C,jr2+0x10 ;38 10
347 jr2: jr NC,jr3+0x10 ;30 10
348 jr3: jr NZ,jr4+0x10 ;20 10
349 jr4: jr Z,jr5+0x10 ;28 10
351 ;***********************************************************
352 ; load source to destination
354 ld a,offset(ix) ;DD 7E 55
355 ld a,offset(iy) ;FD 7E 55
365 ld b,offset(ix) ;DD 46 55
366 ld b,offset(iy) ;FD 46 55
376 ld c,offset(ix) ;DD 4E 55
377 ld c,offset(iy) ;FD 4E 55
387 ld d,offset(ix) ;DD 56 55
388 ld d,offset(iy) ;FD 56 55
398 ld e,offset(ix) ;DD 5E 55
399 ld e,offset(iy) ;FD 5E 55
409 ld h,offset(ix) ;DD 66 55
410 ld h,offset(iy) ;FD 66 55
420 ld l,offset(ix) ;DD 6E 55
421 ld l,offset(iy) ;FD 6E 55
430 ;***********************************************************
435 ;***********************************************************
440 ;***********************************************************
449 ;***********************************************************
450 ld offset(ix),a ;DD 77 55
451 ld offset(ix),b ;DD 70 55
452 ld offset(ix),c ;DD 71 55
453 ld offset(ix),d ;DD 72 55
454 ld offset(ix),e ;DD 73 55
455 ld offset(ix),h ;DD 74 55
456 ld offset(ix),l ;DD 75 55
457 ld offset(ix),#n ;DD 36 55 20
458 ;***********************************************************
459 ld offset(iy),a ;FD 77 55
460 ld offset(iy),b ;FD 70 55
461 ld offset(iy),c ;FD 71 55
462 ld offset(iy),d ;FD 72 55
463 ld offset(iy),e ;FD 73 55
464 ld offset(iy),h ;FD 74 55
465 ld offset(iy),l ;FD 75 55
466 ld offset(iy),#n ;FD 36 55 20
467 ;***********************************************************
469 ld (nn),bc ;ED 43 84 05
470 ld (nn),de ;ED 53 84 05
472 ld (nn),sp ;ED 73 84 05
473 ld (nn),ix ;DD 22 84 05
474 ld (nn),iy ;FD 22 84 05
475 ;***********************************************************
477 ld bc,(nn) ;ED 4B 84 05
478 ld de,(nn) ;ED 5B 84 05
480 ld sp,(nn) ;ED 7B 84 05
481 ld ix,(nn) ;DD 2A 84 05
482 ld iy,(nn) ;FD 2A 84 05
483 ;***********************************************************
488 ld ix,#nn ;DD 21 84 05
489 ld iy,#nn ;FD 21 84 05
490 ;***********************************************************
494 ;***********************************************************
500 ;***********************************************************
505 ; repeat until bc = 0
507 ;***********************************************************
513 ;***********************************************************
518 ; repeat until bc = 0
520 ;***********************************************************
521 ; 2's complement of 'a'
523 ;***********************************************************
526 ;***********************************************************
527 ; logical 'or' operand with 'a'
529 or a,offset(ix) ;DD B6 55
530 or a,offset(iy) ;FD B6 55
539 ;***********************************************************
540 ; load output port (c)
542 ; decrement hl and decrement b
545 ;***********************************************************
546 ; load output port (c)
548 ; increment hl and decrement b
551 ;***********************************************************
552 ; load output port (c) with reg
560 ;***********************************************************
561 ; load output port (n) with 'a'
563 ;***********************************************************
564 ; load output port (c)
566 ; decrement hl and decrement b
568 ;***********************************************************
569 ; load output port (c)
571 ; increment hl and decrement b
573 ;***********************************************************
574 ; load destination with top of stack
581 ;***********************************************************
582 ; put source on stack
589 ;***********************************************************
590 ; reset bit of location or register
592 res 0,offset(ix) ;DD CB 55 86
593 res 0,offset(iy) ;FD CB 55 86
602 res 1,offset(ix) ;DD CB 55 8E
603 res 1,offset(iy) ;FD CB 55 8E
612 res 2,offset(ix) ;DD CB 55 96
613 res 2,offset(iy) ;FD CB 55 96
622 res 3,offset(ix) ;DD CB 55 9E
623 res 3,offset(iy) ;FD CB 55 9E
632 res 4,offset(ix) ;DD CB 55 A6
633 res 4,offset(iy) ;FD CB 55 A6
642 res 5,offset(ix) ;DD CB 55 AE
643 res 5,offset(iy) ;FD CB 55 AE
652 res 6,offset(ix) ;DD CB 55 B6
653 res 6,offset(iy) ;FD CB 55 B6
662 res 7,offset(ix) ;DD CB 55 BE
663 res 7,offset(iy) ;FD CB 55 BE
671 ;***********************************************************
672 ; return from subroutine
674 ;***********************************************************
675 ; return from subroutine if condition is true
684 ;***********************************************************
685 ; return from interrupt
687 ;***********************************************************
688 ; return from non-maskable interrupt
690 ;***********************************************************
691 ; rotate left through carry
693 rl a,offset(ix) ;DD CB 55 16
694 rl a,offset(iy) ;FD CB 55 16
702 ;***********************************************************
703 ; rotate left 'a' with carry
705 ;***********************************************************
706 ; rotate left circular
708 rlc a,offset(ix) ;DD CB 55 06
709 rlc a,offset(iy) ;FD CB 55 06
717 ;***********************************************************
718 ; rotate left 'a' circular
720 ;***********************************************************
721 ; rotate digit left and right
722 ; between 'a' and location (hl)
724 ;***********************************************************
725 ; rotate right through carry
727 rr a,offset(ix) ;DD CB 55 1E
728 rr a,offset(iy) ;FD CB 55 1E
736 ;***********************************************************
737 ; rotate 'a' right with carry
739 ;***********************************************************
740 ; rotate right circular
742 rrc a,offset(ix) ;DD CB 55 0E
743 rrc a,offset(iy) ;FD CB 55 0E
751 ;***********************************************************
752 ; rotate 'a' right circular
754 ;***********************************************************
755 ; rotate digit right and left
756 ; between 'a' and location (hl)
758 ;***********************************************************
768 ;***********************************************************
769 ; subtract with carry to 'a'
771 sbc a,offset(ix) ;DD 9E 55
772 sbc a,offset(iy) ;FD 9E 55
781 ;***********************************************************
782 ; add with carry register pair to 'hl'
787 ;***********************************************************
788 ; set carry flag (C=1)
790 ;***********************************************************
791 ; set bit of location or register
793 set 0,offset(ix) ;DD CB 55 C6
794 set 0,offset(iy) ;FD CB 55 C6
803 set 1,offset(ix) ;DD CB 55 CE
804 set 1,offset(iy) ;FD CB 55 CE
813 set 2,offset(ix) ;DD CB 55 D6
814 set 2,offset(iy) ;FD CB 55 D6
823 set 3,offset(ix) ;DD CB 55 DE
824 set 3,offset(iy) ;FD CB 55 DE
833 set 4,offset(ix) ;DD CB 55 E6
834 set 4,offset(iy) ;FD CB 55 E6
843 set 5,offset(ix) ;DD CB 55 EE
844 set 5,offset(iy) ;FD CB 55 EE
853 set 6,offset(ix) ;DD CB 55 F6
854 set 6,offset(iy) ;FD CB 55 F6
863 set 7,offset(ix) ;DD CB 55 FE
864 set 7,offset(iy) ;FD CB 55 FE
872 ;***********************************************************
873 ; shift operand left arithmetic
875 sla a,offset(ix) ;DD CB 55 26
876 sla a,offset(iy) ;FD CB 55 26
884 ;***********************************************************
885 ; shift operand right arithmetic
887 sra a,offset(ix) ;DD CB 55 2E
888 sra a,offset(iy) ;FD CB 55 2E
896 ;***********************************************************
897 ; shift operand right logical
899 srl a,offset(ix) ;DD CB 55 3E
900 srl a,offset(iy) ;FD CB 55 3E
908 ;***********************************************************
909 ; subtract operand from 'a'
911 sub a,offset(ix) ;DD 96 55
912 sub a,offset(iy) ;FD 96 55
921 ;***********************************************************
922 ; logical 'xor' operand with 'a'
924 xor a,offset(ix) ;DD AE 55
925 xor a,offset(iy) ;FD AE 55
936 ;***********************************************************
937 ; Hitachi HD64180 Codes
938 ;***********************************************************
942 ;***********************************************************
943 ; load register with input from port (n)
951 ;***********************************************************
952 ; multiplication of each half
953 ; of the specified register pair
954 ; with the 16-bit result going to
955 ; the specified register pair
960 ;***********************************************************
961 ; load output port (c) with
966 ;***********************************************************
967 ; load output port (c) with
973 ;***********************************************************
974 ; load output port (c) with
979 ;***********************************************************
980 ; load output port (c) with
986 ;***********************************************************
987 ; load output port (n) from register
995 ;***********************************************************
998 ;***********************************************************
999 ; non-destructive'and' with accumulator and specified operand
1009 ;***********************************************************
1010 ; non-destructive 'and' of n and the contents of port (c)
1012 ;***********************************************************