]> cloudbase.mooo.com Git - avrcpm.git/blame - avr/Z80int-jmp.asm
* Software-UART works with 2400 and 4800 Baud.
[avrcpm.git] / avr / Z80int-jmp.asm
CommitLineData
e7a0f403 1; 8080/Z80 Interpreter.
fa9059af
L
2; This is part of the Z80-CP/M emulator written by Sprite_tm.
3;
4
5; Copyright (C) 2010 Sprite_tm
6; Copyright (C) 2010 Leo C.
7; Copyright (C) 2010 Horst S.
8
9; This file is part of avrcpm.
10;
11; avrcpm is free software: you can redistribute it and/or modify it
12; under the terms of the GNU General Public License as published by
13; the Free Software Foundation, either version 3 of the License, or
14; (at your option) any later version.
15;
16; avrcpm is distributed in the hope that it will be useful,
17; but WITHOUT ANY WARRANTY; without even the implied warranty of
18; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19; GNU General Public License for more details.
20;
21; You should have received a copy of the GNU General Public License
22; along with avrcpm. If not, see <http://www.gnu.org/licenses/>.
23;
24; $Id$
25;
26
825ecc9d
L
27#if EM_Z80
28
fa9059af 29 .dseg
e7a0f403 30z_regs:
825ecc9d
L
31z_c2:
32 .equ oz_c2 = z_c2 - z_regs
33 .byte 1
34z_b2:
35 .equ oz_b2 = z_b2 - z_regs
36 .byte 1
37z_e2:
38 .equ oz_e2 = z_e2 - z_regs
39 .byte 1
40z_d2:
41 .equ oz_d2 = z_d2 - z_regs
42 .byte 1
43z_l2:
44 .equ oz_l2 = z_l2 - z_regs
45 .byte 1
46z_h2:
47 .equ oz_h2 = z_h2 - z_regs
48 .byte 1
49z_f2:
50 .equ oz_f2 = z_f2 - z_regs
51 .byte 1
52z_a2:
53 .equ oz_a2 = z_a2 - z_regs
54 .byte 1
55
56z_xl:
57 .equ oz_xl = z_xl - z_regs
58 .byte 1
59z_xh:
60 .equ oz_xh = z_xh - z_regs
61 .byte 1
62z_yl:
63 .equ oz_yl = z_yl - z_regs
64 .byte 1
65z_yh:
66 .equ oz_yh = z_yh - z_regs
67 .byte 1
68z_i:
69 .equ oz_i = z_i - z_regs
70 .byte 1
71z_r:
72 .equ oz_r = z_r - z_regs
73 .byte 1
74
75z_istat:
76 .equ oz_istat = z_istat - z_regs
77 .byte 1
4c92af0d
L
78
79 .equ IM_MASK = 0x03 ;Mask IM 0..2
80 .equ IM0 = 0
81 .equ IM1 = 1
82 .equ IM2 = 2
80e1fa71 83
4c92af0d
L
84 .equ IFF1 = 2 ;IFF1 Flag
85 .equ IFF2 = 3 ;IFF2 Flag
fa9059af
L
86#endif
87
88 .cseg
89
90;Init z80
91z80_init:
e7a0f403
L
92 ldiw z_pc,IPLADDR
93 ldiw y,z_regs
fa9059af 94
fa9059af 95 clr intstat
e7a0f403 96
fa9059af 97 printnewline
80e1fa71 98
e7a0f403
L
99.if INS_DEBUG
100 sbr intstat,(1<<i_trace)
101.endif
80e1fa71
L
102
103 printstring "Ok, "CPUSTR"-CPU is live!"
fa9059af
L
104 printnewline
105
106main:
fa9059af
L
107
108.if PRINT_PC
109 cpi z_pch,DBG_TRACE_BOTTOM
110 brlo noprintpc
111 cpi z_pch,DBG_TRACE_TOP
112 brsh noprintpc
113
114 printnewline
115 printstring "PC="
116 movw temp,z_pcl
80e1fa71 117 lcall printhexw
fa9059af
L
118 printstring " "
119noprintpc:
120.endif
121
fa9059af
L
122 ;TODO: hier kommt die Interruptbehandlung rein
123
bca3519f 124 cpse intstat,_0 ; 2 Fast path if no trace, int, break, ...
fa9059af
L
125 rjmp int_test
126
80e1fa71 127int_instr:
bca3519f
L
128 mem_read_ds zl,z_pc ;11 zl = memReadByte(z_pc)
129 adiw z_pcl,1 ; 2 ++z_pc
130 ldi zh,high(opcjmp) ; 1
131 icall ; 3 (+4 ret)
132 rjmp main ; 2
133 ; / 25 cycles minimum (NOP)
fa9059af 134int_test:
80e1fa71
L
135 sbrs intstat,i_trace
136 rjmp int_notrace
a03be84a 137 sbrc intstat,i_halt
825ecc9d 138 rjmp int_notrace
80e1fa71
L
139 cpi z_pch,DBG_TRACE_BOTTOM
140 brlo int_notrace
141 cpi z_pch,DBG_TRACE_TOP
142 brsh int_notrace
143 lcall printregs
144int_notrace:
fa9059af 145 sbrs intstat,i_break
80e1fa71
L
146 rjmp int_nobreak
147 cbr intstat,(1<<i_break)|(1<<i_halt)
fa9059af
L
148 printnewline
149 printstring "Break detected! "
150 mov z_pcl,_0
151 mov z_pch,_0
80e1fa71
L
152int_nobreak:
153
fb050095 154 rjmp int_instr ;Continue with normal instruction interpretation
fa9059af 155
fa9059af
L
156
157;--------------------------------------------------
158; init opcode table
159;
623dd899 160; opctable opc_name, pos
fa9059af 161;
e7a0f403 162
fa9059af
L
163.macro opctable
164
623dd899
L
165
166 .set opcjmp_table_pos_ = (@1 + 255) & -0x100 ;0xff00
167
fa9059af 168 .ifndef opc_tabnext_
623dd899
L
169 .set opc_tabnext_ = opcjmp_table_pos_
170
171 .set opc_tablow_0 = 0
172 .set opc_tablen_0 = 0
173 .set opc_tablow_1 = 0
174 .set opc_tablen_1 = 0
175 .endif
176
177 .if opcjmp_table_pos_ < opc_tabnext_
178 .set opcjmp_table_pos_ = opc_tabnext_
fa9059af
L
179 .endif
180
623dd899
L
181 .if opc_tablow_0 == 0
182 .set opc_tablow_0 = opcjmp_table_pos_
183 .set opc_tablen_0 = 256
184;.message "add tab_0"
185 .elif opc_tablow_1 == 0
186 .if (opc_tablow_0 + opc_tablen_0) == opcjmp_table_pos_
187 .set opc_tablen_0 = opc_tablen_0 + 256
188;.message " tab_0++"
189 .else
190 .set opc_tablow_1 = opcjmp_table_pos_
191 .set opc_tablen_1 = 256
192;.message "add tab_1"
193 .endif
194 .else
195 .if (opc_tablow_1 + opc_tablen_1) == opcjmp_table_pos_
196 .set opc_tablen_1 = opc_tablen_1 + 256
197;.message "tab_1++"
198 .else
199 .error "Tab full_"
200 .endif
201 .endif
fa9059af 202
623dd899 203 .set opc_tabnext_ = opcjmp_table_pos_ + 256
fa9059af
L
204 .equ @0 = opcjmp_table_pos_
205
623dd899 206.endm
e7a0f403 207
623dd899
L
208;--------------------------------------------------
209;
210; checkspace frompos, size
211;
212.macro checkspace
213
214 .ifdef opc_tablow_0
215 .if @0 <= opc_tablow_0
216 .if (@0 + @1) > opc_tablow_0
217 .org opc_tablow_0 + opc_tablen_0
218; .message "skip tab, remove tab_0"
219 .if opc_tablow_1 == 0
220 .set opc_tablow_0 = 0
221 .set opc_tablen_0 = 0
222 .else
223 .set opc_tablow_0 = opc_tablow_1
224 .set opc_tablen_0 = opc_tablen_1
225 .set opc_tablow_1 = 0
226 .set opc_tablen_1 = 0
227; .message "remove tab_1"
228 .endif
229 .endif
230 .endif
231 .endif
fa9059af
L
232.endm
233
fa9059af
L
234;--------------------------------------------------
235; Generate a table entry for one instruction
236;
237; instr fetch, op, store
238;
239.macro instr
240
2217c855
L
241 .set fetch_ = (do_@0 != do_fetch_nop) ; must call or jump to fetch action
242 .set op_ = (do_@1 != do_op_nop) ; must call or jump to op action
243 .set store_ = (do_@2 != do_store_nop) ; must jump to store action
244 .set cnt_ = fetch_ + op_ + store_ ; number of actions for this instruction
245
2217c855 246
623dd899
L
247 .set done_ = 0
248 .set pc_save_ = PC
249
250 .if cnt_ == 0 ; nothing to do (nop)
251 .org opcjmp_table_pos_
252 ret ; go back to main
253 .org pc_save_
254 .set done_ = 1
255 .elif cnt_ == 1 ; jump direct to action
2217c855
L
256 .if fetch_
257 .set action_1_ = do_@0
258 .elif op_
259 .set action_1_ = do_@1
260 .else
261 .set action_1_ = do_@2
262 .endif
623dd899
L
263 .if (opcjmp_table_pos_ - action_1_) <= 2047
264 .org opcjmp_table_pos_
2217c855 265 rjmp action_1_ ; do op and return to main
623dd899
L
266 .org pc_save_
267 .set done_ = 1
2217c855 268 .endif
e7a0f403
L
269 .endif
270
623dd899 271 .if !done_
2217c855 272
2217c855 273 .if defined (l_@0_@1_@2)
e7a0f403 274
623dd899
L
275 .if (opcjmp_table_pos_ - l_@0_@1_@2) <= 2047
276 .org opcjmp_table_pos_
277 rjmp l_@0_@1_@2 ; generate a jump to action table
278 .org pc_save_
279 .else
280 checkspace pc_save_, 2
281 .set pc_save_ = PC
282 .org opcjmp_table_pos_
283 rjmp pc_save_
284 .org pc_save_
e7a0f403 285 jmp l_@0_@1_@2
e7a0f403 286 .endif
fa9059af 287
623dd899
L
288 .else
289
290 checkspace pc_save_, 2*cnt_
291 .set pc_save_ = PC
e7a0f403 292
623dd899
L
293 .org opcjmp_table_pos_
294 .equ l_@0_@1_@2 = pc_save_ ; make a label
e7a0f403
L
295 rjmp l_@0_@1_@2 ; generate a jump to action table
296
297 .org l_@0_@1_@2
fa9059af
L
298
299 .if fetch_ ; must fetch
e7a0f403
L
300 .if op_ || store_
301 .if do_@0 == 0
302 m_do_@0
303 .else
304 lcall do_@0 ; fetch and come back here
305 .endif
306 .else
307 .if do_@0 == 0
308 m_do_@0
309 ret
310 .else
311 ljmp do_@0 ; do op and return to main
312 .endif
fa9059af
L
313 .endif
314 .endif
315 .if op_ ; must exec op
316 .if store_
e7a0f403
L
317 .if do_@1 == 0
318 m_do_@1
319 .else
320 lcall do_@1 ; fetch and come back here
321 .endif
fa9059af 322 .else
e7a0f403
L
323 .if do_@1 == 0
324 m_do_@1
325 ret
326 .else
327 ljmp do_@1 ; do op and return to main
328 .endif
fa9059af
L
329 .endif
330 .endif
e7a0f403
L
331 .if store_ ; must store
332 .if do_@2 == 0
333 m_do_@2
334 ret
335 .else
336 ljmp do_@2 ; store is allways last
337 .endif
fa9059af 338 .endif
e7a0f403 339
fa9059af
L
340 .endif
341 .endif
342
623dd899 343 .set opcjmp_table_pos_ = opcjmp_table_pos_ + 1
fa9059af
L
344
345.endm
346
e7a0f403
L
347
348do_x_nop:
349 ret
350
fa9059af
L
351; ------------ Fetch phase stuff -----------------
352
623dd899 353
fa9059af 354fetch_ops:
e7a0f403
L
355.equ do_fetch_nop = do_x_nop
356
623dd899
L
357do_fetch_rst:
358 movw x,z_pcl
359 sbiw x,1
360 mem_read_d opl
361 andi opl,0x38
362 ldi oph,0
363 ret
fa9059af 364
e7a0f403 365.macro m_do_fetch_a
fa9059af 366 mov opl,z_a
e7a0f403 367.endm
fa9059af 368
e7a0f403
L
369.equ do_fetch_a = 0
370; mov opl,z_a
371; ret
fa9059af 372
e7a0f403 373.macro m_do_fetch_b
825ecc9d 374 mov opl,z_b
e7a0f403 375.endm
fa9059af 376
e7a0f403 377.equ do_fetch_b = 0
825ecc9d 378; mov opl,z_b
e7a0f403
L
379; ldd opl,y+oz_b
380; ret
fa9059af 381
e7a0f403 382.macro m_do_fetch_c
825ecc9d 383 mov opl,z_c
e7a0f403 384.endm
fa9059af 385
e7a0f403 386.equ do_fetch_c = 0
825ecc9d 387; mov opl,z_c
e7a0f403
L
388; ldd opl,y+oz_c
389; ret
fa9059af 390
e7a0f403 391.macro m_do_fetch_d
825ecc9d 392 mov opl,z_d
e7a0f403
L
393.endm
394
395.equ do_fetch_d = 0
396; ldd opl,y+oz_d
397; ret
398
399.macro m_do_fetch_e
825ecc9d 400 mov opl,z_e
e7a0f403
L
401.endm
402
403.equ do_fetch_e = 0
404; ldd opl,y+oz_e
405; ret
406
407.macro m_do_fetch_h
825ecc9d 408 mov opl,z_h
e7a0f403
L
409.endm
410
411.equ do_fetch_h = 0
825ecc9d 412; mov opl,z_h
e7a0f403
L
413; ret
414
415.macro m_do_fetch_l
825ecc9d 416 mov opl,z_l
e7a0f403
L
417.endm
418
419.equ do_fetch_l = 0
825ecc9d 420; mov opl,z_l
e7a0f403 421; ret
fa9059af
L
422
423do_fetch_af:
825ecc9d 424 movw opl,z_flags
fa9059af
L
425 ret
426
825ecc9d
L
427.macro m_do_fetch_bc
428 movw opl,z_c
429.endm
fa9059af 430
825ecc9d
L
431.equ do_fetch_bc = 0
432; movw opl,z_c
433; ret
434
435.macro m_do_fetch_de
436 movw opl,z_e
437.endm
fa9059af 438
825ecc9d
L
439.equ do_fetch_de = 0
440; ldd opl,y+oz_e
441; ldd oph,y+oz_d
fa9059af
L
442 ret
443
825ecc9d
L
444.macro m_do_fetch_hl
445 movw opl,z_l
446.endm
447
448.equ do_fetch_hl = 0
449; movw opl,z_l
450; ret
451
e7a0f403 452.macro m_do_fetch_sp
fa9059af 453 movw opl,z_spl
e7a0f403
L
454.endm
455
456.equ do_fetch_sp = 0
457; movw opl,z_spl
458; ret
fa9059af
L
459
460do_fetch_mbc:
bca3519f
L
461; movw x,z_c
462 mem_read_ds z_a, z_bc
fa9059af
L
463 ret
464
465do_fetch_mde:
bca3519f
L
466; movw x,z_e
467 mem_read_ds z_a, z_de
fa9059af
L
468 ret
469
470do_fetch_mhl:
bca3519f
L
471; movw x,z_l
472 mem_read_ds opl, z_hl
fa9059af
L
473 ret
474
475do_fetch_msp:
476 movw x,z_spl
477 mem_read_d opl
478 adiw x,1
479 mem_read_d oph
480 ret
481
482do_fetch_dir8:
483 mem_read_ds opl, z_pc
484 adiw z_pcl,1
485 ret
486
487do_fetch_dir16:
488 mem_read_ds opl, z_pc
489 adiw z_pcl,1
490 mem_read_ds oph, z_pc
491 adiw z_pcl,1
492 ret
493
fa9059af
L
494; ------------ Store phase stuff -----------------
495
fa9059af 496store_ops:
e7a0f403
L
497.equ do_store_nop = do_x_nop
498
fa9059af
L
499
500do_store_a:
501 mov z_a,opl
502 ret
503
e7a0f403
L
504;.macro m_do_store_b
505; std y+oz_b,opl
506;.endm
507;.equ do_store_b = 0
fa9059af 508do_store_b:
825ecc9d 509 mov z_b,opl
fa9059af
L
510 ret
511
512do_store_c:
825ecc9d 513 mov z_c,opl
fa9059af
L
514 ret
515
516do_store_d:
825ecc9d 517 mov z_d,opl
fa9059af
L
518 ret
519
520do_store_e:
825ecc9d 521 mov z_e,opl
fa9059af
L
522 ret
523
524do_store_h:
825ecc9d 525 mov z_h,opl
fa9059af
L
526 ret
527
528do_store_l:
825ecc9d 529 mov z_l,opl
fa9059af
L
530 ret
531
532do_store_af:
825ecc9d 533 movw z_flags,opl
fa9059af
L
534 ret
535
536do_store_bc:
825ecc9d 537 movw z_c,opl
fa9059af
L
538 ret
539
540do_store_de:
825ecc9d
L
541 movw z_e,opl
542; std y+oz_d,oph
543; std y+oz_e,opl
fa9059af
L
544 ret
545
546do_store_hl:
825ecc9d 547 movw z_l,opl
fa9059af
L
548 ret
549
550do_store_mbc:
bca3519f
L
551; movw x,z_c
552 mem_write_ds z_bc, z_a
fa9059af
L
553 ret
554
555do_store_mde:
bca3519f
L
556; movw x,z_e
557 mem_write_ds z_de, z_a
fa9059af
L
558 ret
559
560do_store_mhl:
bca3519f
L
561; movw x,z_l
562 mem_write_ds z_hl, opl
fa9059af
L
563 ret
564
565do_store_msp:
566 movw xl,z_spl
567 mem_write_s opl
568 adiw xl,1
569 mem_write_s oph
570 ret
571
572do_store_sp:
573 movw z_spl,opl
574 ret
575
576do_store_pc:
577 movw z_pcl,opl
578 ret
579
80e1fa71 580do_store_pcrel: ;add displacement to PC
096f3a91 581#if EM_Z80
80e1fa71
L
582 clr oph
583 tst opl ;sign extend
584 brpl stpcr1
585 com oph
586stpcr1:
587 add z_pcl,opl
588 adc z_pch,oph
589 ret
096f3a91
L
590#else
591 rjmp do_op_inv
592#endif
80e1fa71 593
fa9059af
L
594do_store_ret:
595 movw x,z_spl
596 mem_read_d z_pcl
597 adiw x,1
598 mem_read_d z_pch
599 adiw x,1
600 movw z_spl,x
601
602.if STACK_DBG
603 printnewline
604 printstring "Stack pop "
605 movw temp,z_pcl
606 rcall printhexw
607 printstring ", SP is now "
608 movw temp,z_spl
609 rcall printhexw
610 printstring ". "
611.endif
612 ret
613
614do_store_call:
615 movw xl,z_spl
616 sbiw x,1
617 mem_write_s z_pch
618 sbiw x,1
619 mem_write_s z_pcl
620 movw z_spl,xl
621
622.if STACK_DBG
623 printnewline
624 printstring "Stack push "
625 movw temp,z_pcl
626 rcall printhexw
627 printstring ", SP is now "
628 movw temp,z_spl
629 rcall printhexw
630 printstring ". "
631.endif
632 movw z_pcl,opl
633 ret
634
635
636do_store_am:
637 mem_write_ds op, z_a
638 ret
639
fa9059af
L
640; ------------ Operation phase stuff -----------------
641
642;----------------------------------------------------------------
643;| |
644;| Zilog |
645;| |
646;| ZZZZZZZ 88888 000 |
647;| Z 8 8 0 0 |
648;| Z 8 8 0 0 0 |
649;| Z 88888 0 0 0 |
650;| Z 8 8 0 0 0 |
651;| Z 8 8 0 0 |
652;| ZZZZZZZ 88888 000 |
653;| |
654;| Z80 MICROPROCESSOR Instruction Set Summary |
655;| |
656;----------------------------------------------------------------
657;----------------------------------------------------------------
658;|Mnemonic |SZHPNC|Description |Notes |
659;|----------+------+---------------------+----------------------|
660;|ADC A,s |***V0*|Add with Carry |A=A+s+CY |
661;|ADC HL,ss |**?V0*|Add with Carry |HL=HL+ss+CY |
662;|ADD A,s |***V0*|Add |A=A+s |
80e1fa71
L
663;|ADD HL,ss |--*-0*|Add |HL=HL+ss |
664;|ADD IX,pp |--*-0*|Add |IX=IX+pp |
665;|ADD IY,rr |--*-0*|Add |IY=IY+rr |
fa9059af
L
666;|AND s |**1P00|Logical AND |A=A&s |
667;|BIT b,m |?*1?0-|Test Bit |m&{2^b} |
668;|CALL cc,nn|------|Conditional Call |If cc CALL |
669;|CALL nn |------|Unconditional Call |-[SP]=PC,PC=nn |
670;|CCF |--?-0*|Complement Carry Flag|CY=~CY |
671;|CP s |***V1*|Compare |A-s |
672;|CPD |****1-|Compare and Decrement|A-[HL],HL=HL-1,BC=BC-1|
673;|CPDR |****1-|Compare, Dec., Repeat|CPD till A=[HL]or BC=0|
674;|CPI |****1-|Compare and Increment|A-[HL],HL=HL+1,BC=BC-1|
675;|CPIR |****1-|Compare, Inc., Repeat|CPI till A=[HL]or BC=0|
676;|CPL |--1-1-|Complement |A=~A |
677;|DAA |***P-*|Decimal Adjust Acc. |A=BCD format |
678;|DEC s |***V1-|Decrement |s=s-1 |
679;|DEC xx |------|Decrement |xx=xx-1 |
680;|DEC ss |------|Decrement |ss=ss-1 |
4c92af0d 681;|DI |------|Disable Interrupts |IFF1 = IFF2 = 0 |
fa9059af 682;|DJNZ e |------|Dec., Jump Non-Zero |B=B-1 till B=0 |
4c92af0d 683;|EI |------|Enable Interrupts |IFF1 = IFF2 = 1 |
fa9059af
L
684;|EX [SP],HL|------|Exchange |[SP]<->HL |
685;|EX [SP],xx|------|Exchange |[SP]<->xx |
686;|EX AF,AF' |------|Exchange |AF<->AF' |
687;|EX DE,HL |------|Exchange |DE<->HL |
688;|EXX |------|Exchange |qq<->qq' (except AF)|
689;|HALT |------|Halt | |
690;|IM n |------|Interrupt Mode | (n=0,1,2)|
691;|IN A,[n] |------|Input |A=[n] |
692;|IN r,[C] |***P0-|Input |r=[C] |
693;|INC r |***V0-|Increment |r=r+1 |
694;|INC [HL] |***V0-|Increment |[HL]=[HL]+1 |
695;|INC xx |------|Increment |xx=xx+1 |
696;|INC [xx+d]|***V0-|Increment |[xx+d]=[xx+d]+1 |
697;|INC ss |------|Increment |ss=ss+1 |
698;|IND |?*??1-|Input and Decrement |[HL]=[C],HL=HL-1,B=B-1|
699;|INDR |?1??1-|Input, Dec., Repeat |IND till B=0 |
700;|INI |?*??1-|Input and Increment |[HL]=[C],HL=HL+1,B=B-1|
701;|INIR |?1??1-|Input, Inc., Repeat |INI till B=0 |
702;|JP [HL] |------|Unconditional Jump |PC=[HL] |
703;|JP [xx] |------|Unconditional Jump |PC=[xx] |
704;|JP nn |------|Unconditional Jump |PC=nn |
705;|JP cc,nn |------|Conditional Jump |If cc JP |
706;|JR e |------|Unconditional Jump |PC=PC+e |
707;|JR cc,e |------|Conditional Jump |If cc JR(cc=C,NC,NZ,Z)|
708;|LD dst,src|------|Load |dst=src |
709;|LD A,i |**0*0-|Load |A=i (i=I,R)|
710;|LDD |--0*0-|Load and Decrement |[DE]=[HL],HL=HL-1,# |
711;|LDDR |--000-|Load, Dec., Repeat |LDD till BC=0 |
712;|LDI |--0*0-|Load and Increment |[DE]=[HL],HL=HL+1,# |
713;|LDIR |--000-|Load, Inc., Repeat |LDI till BC=0 |
714;|NEG |***V1*|Negate |A=-A |
715;|NOP |------|No Operation | |
716;|OR s |**0P00|Logical inclusive OR |A=Avs |
717;|OTDR |?1??1-|Output, Dec., Repeat |OUTD till B=0 |
718;|OTIR |?1??1-|Output, Inc., Repeat |OUTI till B=0 |
719;|OUT [C],r |------|Output |[C]=r |
720;|OUT [n],A |------|Output |[n]=A |
721;|OUTD |?*??1-|Output and Decrement |[C]=[HL],HL=HL-1,B=B-1|
722;|OUTI |?*??1-|Output and Increment |[C]=[HL],HL=HL+1,B=B-1|
723;|POP xx |------|Pop |xx=[SP]+ |
724;|POP qq |------|Pop |qq=[SP]+ |
725;|PUSH xx |------|Push |-[SP]=xx |
726;|PUSH qq |------|Push |-[SP]=qq |
727;|RES b,m |------|Reset bit |m=m&{~2^b} |
728;|RET |------|Return |PC=[SP]+ |
729;|RET cc |------|Conditional Return |If cc RET |
730;|RETI |------|Return from Interrupt|PC=[SP]+ |
731;|RETN |------|Return from NMI |PC=[SP]+ |
732;|RL m |**0P0*|Rotate Left |m={CY,m}<- |
733;|RLA |--0-0*|Rotate Left Acc. |A={CY,A}<- |
734;|RLC m |**0P0*|Rotate Left Circular |m=m<- |
735;|RLCA |--0-0*|Rotate Left Circular |A=A<- |
736;|RLD |**0P0-|Rotate Left 4 bits |{A,[HL]}={A,[HL]}<- ##|
737;|RR m |**0P0*|Rotate Right |m=->{CY,m} |
738;|RRA |--0-0*|Rotate Right Acc. |A=->{CY,A} |
739;|RRC m |**0P0*|Rotate Right Circular|m=->m |
740;|RRCA |--0-0*|Rotate Right Circular|A=->A |
741;|RRD |**0P0-|Rotate Right 4 bits |{A,[HL]}=->{A,[HL]} ##|
742;|RST p |------|Restart | (p=0H,8H,10H,...,38H)|
743;|SBC A,s |***V1*|Subtract with Carry |A=A-s-CY |
80e1fa71 744;|SBC HL,ss |***V1*|Subtract with Carry |HL=HL-ss-CY |
fa9059af
L
745;|SCF |--0-01|Set Carry Flag |CY=1 |
746;|SET b,m |------|Set bit |m=mv{2^b} |
747;|SLA m |**0P0*|Shift Left Arithmetic|m=m*2 |
748;|SRA m |**0P0*|Shift Right Arith. |m=m/2 |
749;|SRL m |**0P0*|Shift Right Logical |m=->{0,m,CY} |
750;|SUB s |***V1*|Subtract |A=A-s |
751;|XOR s |**0P00|Logical Exclusive OR |A=Axs |
752;|----------+------+--------------------------------------------|
753;| F |-*01? |Flag unaffected/affected/reset/set/unknown |
754;| S |S |Sign flag (Bit 7) |
755;| Z | Z |Zero flag (Bit 6) |
756;| HC | H |Half Carry flag (Bit 4) |
757;| P/V | P |Parity/Overflow flag (Bit 2, V=overflow) |
758;| N | N |Add/Subtract flag (Bit 1) |
759;| CY | C|Carry flag (Bit 0) |
760;|-----------------+--------------------------------------------|
761;| n |Immediate addressing |
762;| nn |Immediate extended addressing |
763;| e |Relative addressing (PC=PC+2+offset) |
764;| [nn] |Extended addressing |
765;| [xx+d] |Indexed addressing |
766;| r |Register addressing |
767;| [rr] |Register indirect addressing |
768;| |Implied addressing |
769;| b |Bit addressing |
770;| p |Modified page zero addressing (see RST) |
771;|-----------------+--------------------------------------------|
772;|DEFB n(,...) |Define Byte(s) |
773;|DEFB 'str'(,...) |Define Byte ASCII string(s) |
774;|DEFS nn |Define Storage Block |
775;|DEFW nn(,...) |Define Word(s) |
776;|-----------------+--------------------------------------------|
777;| A B C D E |Registers (8-bit) |
778;| AF BC DE HL |Register pairs (16-bit) |
779;| F |Flag register (8-bit) |
780;| I |Interrupt page address register (8-bit) |
781;| IX IY |Index registers (16-bit) |
782;| PC |Program Counter register (16-bit) |
783;| R |Memory Refresh register |
784;| SP |Stack Pointer register (16-bit) |
785;|-----------------+--------------------------------------------|
786;| b |One bit (0 to 7) |
787;| cc |Condition (C,M,NC,NZ,P,PE,PO,Z) |
788;| d |One-byte expression (-128 to +127) |
789;| dst |Destination s, ss, [BC], [DE], [HL], [nn] |
790;| e |One-byte expression (-126 to +129) |
791;| m |Any register r, [HL] or [xx+d] |
792;| n |One-byte expression (0 to 255) |
793;| nn |Two-byte expression (0 to 65535) |
794;| pp |Register pair BC, DE, IX or SP |
795;| qq |Register pair AF, BC, DE or HL |
796;| qq' |Alternative register pair AF, BC, DE or HL |
797;| r |Register A, B, C, D, E, H or L |
798;| rr |Register pair BC, DE, IY or SP |
799;| s |Any register r, value n, [HL] or [xx+d] |
800;| src |Source s, ss, [BC], [DE], [HL], nn, [nn] |
801;| ss |Register pair BC, DE, HL or SP |
802;| xx |Index register IX or IY |
803;|-----------------+--------------------------------------------|
804;| + - * / ^ |Add/subtract/multiply/divide/exponent |
805;| & ~ v x |Logical AND/NOT/inclusive OR/exclusive OR |
806;| <- -> |Rotate left/right |
807;| [ ] |Indirect addressing |
808;| [ ]+ -[ ] |Indirect addressing auto-increment/decrement|
809;| { } |Combination of operands |
810;| # |Also BC=BC-1,DE=DE-1 |
811;| ## |Only lower 4 bits of accumulator A used |
812;----------------------------------------------------------------
813
814;How the flags are supposed to work:
815;7 ZFL_S - Sign flag (=MSBit of result)
816;6 ZFL_Z - Zero flag. Is 1 when the result is 0
817;4 ZFL_H - Half-carry (carry from bit 3 to 4)
818;2 ZFL_P - Parity/2-complement Overflow
819;1 ZFL_N - Subtract - set if last op was a subtract
820;0 ZFL_C - Carry
821;
822;I sure hope I got the mapping between flags and instructions correct...
823
824.equ ZFL_S = 7
825.equ ZFL_Z = 6
826.equ ZFL_H = 4
827.equ ZFL_P = 2
828.equ ZFL_N = 1
829.equ ZFL_C = 0
830
831.equ AVR_T = SREG_T
832.equ AVR_H = SREG_H
833.equ AVR_S = SREG_S
834.equ AVR_V = SREG_V
835.equ AVR_N = SREG_N
836.equ AVR_Z = SREG_Z
837.equ AVR_C = SREG_C
838
839; TODO: check Z80 flag settings
840
841;------------------------------------------------;
842; Load table value from flash indexed by source reg.
843;
844; ldpmx dstreg,tablebase,indexreg
845;
096f3a91 846; (3 words, 5 cycles)
fa9059af
L
847
848.macro ldpmx
849 ldi zh,high(@1*2) ; table must be page aligned
850 mov zl,@2
851 lpm @0,z
852.endm
853
854.macro do_z80_flags_V
855#if EM_Z80
856 bmov z_flags, ZFL_P, temp, AVR_V
857#endif
858.endm
859
80e1fa71
L
860.macro do_z80_flags_H
861#if EM_Z80
862 bmov z_flags, ZFL_H, temp, AVR_H
863#endif
864.endm
865
fa9059af
L
866.macro do_z80_flags_set_N
867#if EM_Z80
868 ori z_flags, (1<<ZFL_N) ; Negation auf 1
869#endif
870.endm
871
872.macro do_z80_flags_set_HN
873#if EM_Z80
874 ori z_flags,(1<<ZFL_N)|(1<<ZFL_H)
875#endif
876.endm
877
878.macro do_z80_flags_clear_N
879#if EM_Z80
880 andi z_flags,~(1<<ZFL_N)
881#endif
882.endm
883
884.macro do_z80_flags_clear_HN
885#if EM_Z80
886 andi z_flags,~((1<<ZFL_H)|(1<<ZFL_N))
887#endif
888.endm
889
890
891.macro do_z80_flags_copy_HC
892#if EM_Z80
096f3a91 893 bmov z_flags, ZFL_H, z_flags, ZFL_C
fa9059af
L
894#endif
895.endm
896
897.macro do_z80_flags_op_rotate
898 ; must not change avr carry flag!
899#if EM_Z80
900 andi z_flags, ~( (1<<ZFL_H) | (1<<ZFL_N) | (1<<ZFL_C) )
901#else
902 andi z_flags, ~( (1<<ZFL_C) )
903#endif
904.endm
905
906.macro do_z80_flags_op_and
907#if EM_Z80
908 ori z_flags,(1<<ZFL_H)
909#endif
910.endm
911
912.macro do_z80_flags_op_or
913#if EM_Z80
914 ;nothing to do
915#endif
916.endm
917
918
919;----------------------------------------------------------------
920
e7a0f403
L
921.equ do_op_nop = do_x_nop
922
fa9059af
L
923do_op_inv:
924 sbiw z_pcl,1
925 lcall printregs
926 printstring "Invalid opcode! "
927
928haltinv:
929 rjmp haltinv
930
80e1fa71
L
931
932;----------------------------------------------------------------
933;|Mnemonic |SZHPNC|Description |Notes |
934;----------------------------------------------------------------
935;|HALT |------|Halt | |
936
937
938do_op_HALT:
939 sbiw z_pcl,1
940 sbrc intstat,i_halt
941 ret
942 sbr intstat,(1<<i_halt)
943 lcall printregs
944 printstring "CPU halted! "
945 ret
946
fa9059af
L
947;----------------------------------------------------------------
948;|Mnemonic |SZHPNC|Description |Notes |
949;----------------------------------------------------------------
950;|OUT [n],A |------|Output |[n]=A |
951;
952;
953;Interface with peripherials goes here :)
954do_op_outa: ; out (opl),a
955.if PORT_DEBUG
956 printnewline
957 printstring "Port write: "
958 mov temp,z_a
80e1fa71 959 lcall printhex
fa9059af
L
960 printstring " -> ("
961 mov temp,opl
80e1fa71 962 lcall printhex
fa9059af
L
963 printstring ") "
964.endif
965 mov temp,z_a
966 mov temp2,opl
e7a0f403 967 lcall portWrite
fa9059af
L
968 ret
969
fa9059af
L
970;----------------------------------------------------------------
971;|Mnemonic |SZHPNC|Description |Notes |
972;----------------------------------------------------------------
973;|IN A,[n] |------|Input |A=[n] |
974;
975;
80e1fa71 976do_op_ina: ; in a,(opl)
fa9059af 977.if PORT_DEBUG
fb050095
L
978 push opl
979 cp opl,_0 ; don't debug port 0 (con stat)
980 breq dbg_op_ina_1
fa9059af
L
981 printnewline
982 printstring "Port read: ("
983 mov temp,opl
80e1fa71 984 lcall printhex
fa9059af 985 printstring ") -> "
fb050095 986dbg_op_ina_1:
fa9059af
L
987.endif
988
989 mov temp2,opl
990 lcall portRead
80e1fa71 991 mov z_a,temp
fa9059af
L
992
993.if PORT_DEBUG
fb050095
L
994 pop temp
995 cp temp,_0
996 breq dbg_op_ina_2
80e1fa71 997 lcall printhex
fa9059af 998 printstring " "
fb050095 999dbg_op_ina_2:
fa9059af
L
1000.endif
1001 ret
1002
1003;----------------------------------------------------------------
1004;|Mnemonic |SZHPNC|Description |Notes |
1005;----------------------------------------------------------------
1006;|INC r |***V0-|Increment |r=r+1 |
1007;|INC [HL] |***V0-|Increment |[HL]=[HL]+1 |
1008;|INC [xx+d]|***V0-|Increment |[xx+d]=[xx+d]+1 |
1009;|----------|SZHP C|---------- 8080 ----------------------------|
1010;|INC r |**-P0-|Increment |r=r+1 |
1011;|INC [HL] |**-P0-|Increment |[HL]=[HL]+1 |
1012;
2217c855 1013
fa9059af 1014do_op_inc:
096f3a91 1015#if EM_Z80
825ecc9d
L
1016#if 1
1017 andi z_flags,(1<<ZFL_C) ; preserve C-, Clear N-flag
1018 subi opl,-1
1019 in temp,sreg
1020 sbrc temp,AVR_N
1021 sbr z_flags,(1<<ZFL_S)
1022 sbrc temp,AVR_Z
1023 sbr z_flags,(1<<ZFL_Z)
1024 sbrs temp,AVR_H
1025 sbr z_flags,(1<<ZFL_H)
1026 sbrc temp,AVR_V
1027 sbr z_flags,(1<<ZFL_P)
1028#else
096f3a91 1029 andi z_flags,(1<<ZFL_C) ; preserve C-, Clear N-flag
fa9059af
L
1030 ldi temp,1
1031 add opl,temp
096f3a91
L
1032 in temp,sreg
1033 bmov z_flags,ZFL_S, temp,AVR_N
1034 bmov z_flags,ZFL_Z, temp,AVR_Z
1035 bmov z_flags,ZFL_H, temp,AVR_H
1036 bmov z_flags,ZFL_P, temp,AVR_V
825ecc9d 1037#endif
2217c855 1038#else /* 8080 */
096f3a91
L
1039 andi z_flags,(1<<ZFL_C)|(1<<ZFL_H) ; preserve C- and H-flag
1040 inc opl
2217c855
L
1041 ldpmx temp,sz53p_tab,opl ;S,Z,P flag
1042 or z_flags,temp
1043#endif
fa9059af
L
1044 ret
1045
825ecc9d
L
1046#if 0
1047 bst z_flags,ZFL_C ; save C flag
1048 subi opl,-1
1049 in temp,sreg
1050 ldpmx z_flags,flagmap_tab,temp
1051 bld z_flags,ZFL_C
1052 ret
1053#endif
1054
fa9059af 1055do_op_inca:
096f3a91
L
1056#if EM_Z80
1057 andi z_flags,(1<<ZFL_C) ; preserve C-, Clear N-flag
825ecc9d 1058 subi z_a,-1
096f3a91
L
1059 in temp,sreg
1060 bmov z_flags,ZFL_S, temp,AVR_N
1061 bmov z_flags,ZFL_Z, temp,AVR_Z
825ecc9d
L
1062 sbrs temp,AVR_H
1063 sbr z_flags,(1<<ZFL_H)
096f3a91 1064 bmov z_flags,ZFL_P, temp,AVR_V
2217c855 1065#else /* 8080 */
096f3a91
L
1066 andi z_flags,(1<<ZFL_C)|(1<<ZFL_H) ; preserve C- and H-flag
1067 inc z_a
1068 ldpmx temp,sz53p_tab,z_a ; S,Z,P flag
2217c855
L
1069 or z_flags,temp
1070#endif
fa9059af
L
1071 ret
1072
1073;----------------------------------------------------------------
1074;|Mnemonic |SZHPNC|Description |Notes |
1075;----------------------------------------------------------------
1076;|DEC r |***V1-|Decrement |s=s-1 |
825ecc9d
L
1077;|DEC [HL] |***V1-|Increment |[HL]=[HL]-1 |
1078;|DEC [xx+d]|***V1-|Increment |[xx+d]=[xx+d]-1 |
fa9059af 1079;|----------|SZHP C|---------- 8080 ----------------------------|
2217c855
L
1080;|DEC r |**-P -|Increment |r=r-1 |
1081;|DEC [HL] |**-P -|Increment |[HL]=[HL]-1 |
fa9059af 1082;
2217c855 1083
fa9059af 1084do_op_dec:
2217c855
L
1085 subi opl,1
1086#if EM_Z80
096f3a91
L
1087 in temp,sreg
1088 bmov z_flags,ZFL_S, temp,AVR_N
1089 bmov z_flags,ZFL_Z, temp,AVR_Z
1090 bmov z_flags,ZFL_H, temp,AVR_H
1091 bmov z_flags,ZFL_P, temp,AVR_V
2217c855
L
1092 ori z_flags,(1<<ZFL_N) ; Set N-flag
1093#else /* 8080 */
096f3a91 1094 andi z_flags,(1<<ZFL_C)|(1<<ZFL_H) ; preserve C- and H-flag
2217c855
L
1095 ldpmx temp,sz53p_tab,opl ; S,Z,P flag
1096 or z_flags,temp
1097#endif
fa9059af
L
1098 ret
1099
2217c855 1100
fa9059af 1101do_op_deca:
2217c855 1102#if EM_Z80
825ecc9d 1103 subi z_a,1
096f3a91
L
1104 in temp,sreg
1105 bmov z_flags,ZFL_S, temp,AVR_N
1106 bmov z_flags,ZFL_Z, temp,AVR_Z
1107 bmov z_flags,ZFL_H, temp,AVR_H
1108 bmov z_flags,ZFL_P, temp,AVR_V
2217c855
L
1109 ori z_flags,(1<<ZFL_N) ; Set N-flag
1110#else /* 8080 */
096f3a91
L
1111 dec z_a
1112 andi z_flags,(1<<ZFL_C)|(1<<ZFL_H) ; preserve C- and H-flag
1113 ldpmx temp,sz53p_tab,z_a ; S,Z,P flag
2217c855
L
1114 or z_flags,temp
1115#endif
fa9059af
L
1116 ret
1117
2217c855 1118
fa9059af
L
1119;----------------------------------------------------------------
1120;|Mnemonic |SZHPNC|Description |Notes |
1121;----------------------------------------------------------------
1122;|INC xx |------|Increment |xx=xx+1 |
1123;|INC ss |------|Increment |ss=ss+1 |
1124;
1125;
1126do_op_inc16:
1127 subi opl,low(-1)
1128 sbci oph,high(-1)
1129 ret
1130
825ecc9d
L
1131do_op_incHL:
1132 sub z_l,_255
1133 sbc z_h,_255
1134 ret
1135
1136do_op_incDE:
1137 sub z_e,_255
1138 sbc z_d,_255
1139 ret
1140
1141do_op_incBC:
1142 sub z_c,_255
1143 sbc z_b,_255
1144 ret
1145
fa9059af
L
1146;----------------------------------------------------------------
1147;|Mnemonic |SZHPNC|Description |Notes |
1148;----------------------------------------------------------------
1149;|DEC xx |------|Decrement |xx=xx-1 |
1150;|DEC ss |------|Decrement |ss=ss-1 |
1151;
1152;
1153do_op_dec16:
1154 subi opl, 1
1155 sbci oph, 0
1156 ret
1157
825ecc9d
L
1158do_op_decHL:
1159 add z_l,_255
1160 adc z_h,_255
1161 ret
1162
1163do_op_decDE:
1164 add z_e,_255
1165 adc z_d,_255
1166 ret
1167
1168do_op_decBC:
1169 add z_c,_255
1170 adc z_b,_255
1171 ret
1172
fa9059af
L
1173;----------------------------------------------------------------
1174;|Mnemonic |SZHPNC|Description |Notes |
1175;----------------------------------------------------------------
1176;|RLCA |--0-0*|Rotate Left Circular |A=A<- |
1177;|----------|SZHP C|---------- 8080 ----------------------------|
1178;|RLCA |---- *|Rotate Left Circular |A=A<- |
1179;
1180;
1181do_op_rlca:
1182 ;Rotate Left Cyclical. All bits move 1 to the
1183 ;left, the msb becomes c and lsb.
1184 do_z80_flags_op_rotate
1185 lsl z_a
1186 brcc do_op_rlc_noc
1187 ldi temp,1
1188 or z_a,temp
1189 ori z_flags, (1<<ZFL_C)
1190do_op_rlc_noc:
1191 ret
1192
1193;----------------------------------------------------------------
1194;|Mnemonic |SZHPNC|Description |Notes |
1195;----------------------------------------------------------------
1196;|RRCA |--0-0*|Rotate Right Circular|A=->A |
1197;|----------|SZHP C|---------- 8080 ----------------------------|
1198;|RRCA |---- *|Rotate Right Circular|A=->A |
1199;
1200;
1201do_op_rrca:
1202 ;Rotate Right Cyclical. All bits move 1 to the
1203 ;right, the lsb becomes c and msb.
1204 do_z80_flags_op_rotate
1205 lsr z_a
1206 brcc do_op_rrc_noc
1207 ldi temp,0x80
1208 or z_a,temp
1209 ori z_flags, (1<<ZFL_C)
1210do_op_rrc_noc:
1211 ret
1212
1213;----------------------------------------------------------------
1214;|Mnemonic |SZHPNC|Description |Notes |
1215;----------------------------------------------------------------
1216;|RRA |--0-0*|Rotate Right Acc. |A=->{CY,A} |
1217;|----------|SZHP C|---------- 8080 ----------------------------|
1218;|RRA |---- *|Rotate Right Acc. |A=->{CY,A} |
1219;
1220;
1221do_op_rra:
1222 ;Rotate Right. All bits move 1 to the right, the lsb
1223 ;becomes c, c becomes msb.
1224 clc ; get z80 carry to avr carry
1225 sbrc z_flags,ZFL_C
1226 sec
1227 do_z80_flags_op_rotate ; (clear ZFL_C, doesn't change AVR_C)
1228 bmov z_flags,ZFL_C, z_a,0 ; Bit 0 --> CY
1229 ror z_a
1230 ret
1231
1232;----------------------------------------------------------------
1233;|Mnemonic |SZHPNC|Description |Notes |
1234;----------------------------------------------------------------
1235;|RLA |--0-0*|Rotate Left Acc. |A={CY,A}<- |
1236;|----------|SZHP C|---------- 8080 ----------------------------|
1237;|RLA |---- *|Rotate Left Acc. |A={CY,A}<- |
1238;
1239;
1240do_op_rla:
1241 ;Rotate Left. All bits move 1 to the left, the msb
1242 ;becomes c, c becomes lsb.
1243 clc
1244 sbrc z_flags,ZFL_C
1245 sec
1246 do_z80_flags_op_rotate ; (clear ZFL_C, doesn't change AVR_C)
1247 bmov z_flags,ZFL_C, z_a,7 ; Bit 7 --> CY
1248 rol z_a
1249 ret
1250
1251;----------------------------------------------------------------
1252;|Mnemonic |SZHPNC|Description |Notes |
1253;----------------------------------------------------------------
1254;|ADD A,s |***V0*|Add |A=A+s |
1255;|----------|SZHP C|---------- 8080 ----------------------------|
1256;|ADD A,s |***P *|Add |A=A+s |
1257;
1258;
1259do_op_adda:
1260 add z_a,opl
1261 in temp,sreg
1262 ldpmx z_flags,sz53p_tab,z_a ;S,Z,P flag
1263 bmov z_flags,ZFL_C, temp,AVR_C
1264 bmov z_flags,ZFL_H, temp,AVR_H
1265 do_z80_flags_V
1266 ret
1267
1268;----------------------------------------------------------------
1269;|Mnemonic |SZHPNC|Description |Notes |
1270;----------------------------------------------------------------
1271;|ADC A,s |***V0*|Add with Carry |A=A+s+CY |
1272;|----------|SZHP C|---------- 8080 ----------------------------|
1273;|ADC A,s |***P *|Add with Carry |A=A+s+CY |
1274;
1275;
1276do_op_adca:
1277 clc
1278 sbrc z_flags,ZFL_C
1279 sec
1280 adc z_a,opl
1281 in temp,sreg
1282 ldpmx z_flags,sz53p_tab,z_a ;S,Z,P
1283 bmov z_flags,ZFL_C, temp,AVR_C
1284 bmov z_flags,ZFL_H, temp,AVR_H
1285 do_z80_flags_V
1286 ret
1287
1288;----------------------------------------------------------------
1289;|Mnemonic |SZHPNC|Description |Notes |
1290;----------------------------------------------------------------
1291;|SUB s |***V1*|Subtract |A=A-s |
1292;|----------|SZHP C|---------- 8080 ----------------------------|
1293;|SUB s |***P *|Subtract |A=A-s |
1294
1295;
1296do_op_subfa:
1297 sub z_a,opl
1298 in temp,sreg
1299 ldpmx z_flags,sz53p_tab,z_a ;S,Z,P
1300 bmov z_flags,ZFL_C, temp,AVR_C
1301 bmov z_flags,ZFL_H, temp,AVR_H
1302 do_z80_flags_V
1303 do_z80_flags_set_N
1304 ret
1305
1306;----------------------------------------------------------------
1307;|Mnemonic |SZHPNC|Description |Notes |
1308;----------------------------------------------------------------
1309;|CP s |***V1*|Compare |A-s |
1310;|----------|SZHP C|---------- 8080 ----------------------------|
1311;|CP s |***P *|Compare |A-s |
1312
1313;
1314do_op_cpfa:
1315 mov temp2,z_a
1316 sub temp2,opl
1317 in temp,sreg
1318 ldpmx z_flags,sz53p_tab,temp2 ;S,Z,P
1319 bmov z_flags,ZFL_C, temp,AVR_C
1320 bmov z_flags,ZFL_H, temp,AVR_H
1321 do_z80_flags_V
1322 do_z80_flags_set_N
1323 ret
1324
1325;----------------------------------------------------------------
1326;|Mnemonic |SZHPNC|Description |Notes |
1327;----------------------------------------------------------------
1328;|SBC A,s |***V1*|Subtract with Carry |A=A-s-CY |
1329;|----------|SZHP C|---------- 8080 ----------------------------|
1330;|SBC A,s |***P *|Subtract with Carry |A=A-s-CY |
1331;
1332;
1333do_op_sbcfa:
1334 clc
1335 sbrc z_flags,ZFL_C
1336 sec
1337 sbc z_a,opl
1338 in temp,sreg
1339 ldpmx z_flags,sz53p_tab,z_a ;S,Z,P
1340 bmov z_flags,ZFL_C, temp,AVR_C
1341 bmov z_flags,ZFL_H, temp,AVR_H
1342 do_z80_flags_V
1343 do_z80_flags_set_N
1344 ret
1345
1346;----------------------------------------------------------------
1347;|Mnemonic |SZHPNC|Description |Notes |
1348;----------------------------------------------------------------
1349;|AND s |**1P00|Logical AND |A=A&s |
1350;|----------|SZHP C|---------- 8080 ----------------------------|
1351;|AND s |**-P 0|Logical AND |A=A&s |
1352;
1353;
1354do_op_anda:
1355 and z_a,opl ;
1356 ldpmx z_flags,sz53p_tab,z_a ;S,Z,P,N,C
1357 do_z80_flags_op_and
1358 ret
1359
1360
1361;----------------------------------------------------------------
1362;|Mnemonic |SZHPNC|Description |Notes |
1363;----------------------------------------------------------------
1364;|OR s |**0P00|Logical inclusive OR |A=Avs |
1365;|----------|SZHP C|---------- 8080 ----------------------------|
1366;|OR s |**-P00|Logical inclusive OR |A=Avs |
1367;
1368;
1369do_op_ora:
1370 or z_a,opl
1371 ldpmx z_flags,sz53p_tab,z_a ;S,Z,H,P,N,C
1372 do_z80_flags_op_or
1373 ret
1374
1375;----------------------------------------------------------------
1376;|Mnemonic |SZHPNC|Description |Notes |
1377;----------------------------------------------------------------
1378;|XOR s |**0P00|Logical Exclusive OR |A=Axs |
1379;|----------|SZHP C|---------- 8080 ----------------------------|
1380;|XOR s |**-P 0|Logical Exclusive OR |A=Axs |
1381;
1382;
1383do_op_xora:
e7a0f403 1384 eor z_a,opl
fa9059af
L
1385 ldpmx z_flags,sz53p_tab,z_a ;S,Z,H,P,N,C
1386 do_z80_flags_op_or
1387 ret
1388
1389;----------------------------------------------------------------
1390;|Mnemonic |SZHPNC|Description |Notes |
1391;----------------------------------------------------------------
80e1fa71 1392;|ADD HL,ss |--*-0*|Add |HL=HL+ss |
fa9059af
L
1393;|----------|SZHP C|---------- 8080 ----------------------------|
1394;|ADD HL,ss |---- *|Add |HL=HL+ss |
1395;
1396;
1397do_op_addhl:
825ecc9d
L
1398 add z_l,opl
1399 adc z_h,oph
e7a0f403 1400 in temp,sreg
fa9059af 1401 bmov z_flags,ZFL_C, temp,AVR_C
80e1fa71 1402 do_z80_flags_H
fa9059af
L
1403 do_z80_flags_clear_N
1404 ret
1405
1406;----------------------------------------------------------------
1407;|Mnemonic |SZHPNC|Description |Notes |
1408;----------------------------------------------------------------
1409;|LD dst,src|------|Load |dst=src |
1410;
1411;
1412do_op_sthl: ;store hl to mem loc in opl:h
e7a0f403 1413 movw xl,opl
825ecc9d 1414 mem_write_s z_l
e7a0f403 1415 adiw xl,1
825ecc9d 1416 mem_write_s z_h
fa9059af
L
1417 ret
1418
1419;----------------------------------------------------------------
1420;|Mnemonic |SZHPNC|Description |Notes |
1421;----------------------------------------------------------------
1422;|LD dst,src|------|Load |dst=src |
1423;
1424;
1425do_op_rmem16:
1426 movw xl,opl
1427 mem_read_d opl
1428 adiw x,1
1429 mem_read_d oph
1430 ret
1431
1432;----------------------------------------------------------------
1433;|Mnemonic |SZHPNC|Description |Notes |
1434;----------------------------------------------------------------
1435;|LD dst,src|------|Load |dst=src |
1436;
1437;
1438do_op_rmem8:
1439 mem_read_ds opl, op
1440 ret
1441
1442;----------------------------------------------------------------
1443;|Mnemonic |SZHPNC|Description |Notes |
1444;----------------------------------------------------------------
1445;|DAA |***P-*|Decimal Adjust Acc. | |
1446;|----------|SZHP C|---------- 8080 ----------------------------|
096f3a91 1447
fa9059af
L
1448
1449; Description (http://www.z80.info/z80syntx.htm#DAA):
1450; This instruction conditionally adjusts the accumulator for BCD addition
1451; and subtraction operations. For addition (ADD, ADC, INC) or subtraction
1452; (SUB, SBC, DEC, NEC), the following table indicates the operation performed:
1453;
1454; -------------------------------------------------------------------
1455; | |C Flag |HEX value in|H Flag |HEX val in | Number |C flag |
1456; | Oper |Before |upper digit |Before |lower digit| added |After |
1457; | |DAA |(bit 7-4) |DAA |(bit 3-0) | to A |DAA |
1458; |-------+-------+------------+-------+-----------+--------+-------|
1459; | | 0 | 0-9 | 0 | 0-9 | 00 | 0 |
1460; | ADD | 0 | 0-8 | 0 | A-F | 06 | 0 |
1461; | | 0 | 0-9 | 1 | 0-3 | 06 | 0 |
1462; | ADC | 0 | A-F | 0 | 0-9 | 60 | 1 |
1463; | | 0 | 9-F | 0 | A-F | 66 | 1 |
1464; | INC | 0 | A-F | 1 | 0-3 | 66 | 1 |
1465; | | 1 | 0-2 | 0 | 0-9 | 60 | 1 |
1466; | | 1 | 0-2 | 0 | A-F | 66 | 1 |
1467; | | 1 | 0-3 | 1 | 0-3 | 66 | 1 |
1468; |-------+-------+------------+-------+-----------+--------+-------|
1469; | SUB | 0 | 0-9 | 0 | 0-9 | 00 | 0 |
1470; | SBC | 0 | 0-8 | 1 | 6-F | FA | 0 |
1471; | DEC | 1 | 7-F | 0 | 0-9 | A0 | 1 |
1472; | NEG | 1 | 6-F | 1 | 6-F | 9A | 1 |
1473; -------------------------------------------------------------------
1474;
1475; The H flag is affected as follows:
1476;
1477; ---------------------
1478; | N | H | low |H' |
1479; | | |nibble | |
1480; |---+---+-------+---|
1481; | 0 | * | 0-9 | 0 |
1482; | 0 | * | a-f | 1 |
1483; | 1 | 0 | * | 0 |
1484; | 1 | 1 | 6-f | 0 |
1485; | 1 | 1 | 0-5 | 1 |
1486; ---------------------
1487;
1488; Ohter flags:
1489; N: Unaffected.
1490; P/V: Set if Acc. is even parity after operation, reset otherwise.
1491; Z: Set if Acc. is Zero after operation, reset otherwise.
1492; S: Set if most significant bit of Acc. is 1 after operation, reset otherwise.
1493
fa9059af 1494
096f3a91
L
1495
1496#if 0
fa9059af
L
1497
1498#if EM_Z80
1499 sbrc z_flags,ZFL_N ;if add-op
1500 rjmp op_da_sub ;then
1501#endif
1502
096f3a91 1503do_op_DAA:
fa9059af 1504op_da_add:
096f3a91 1505 ldi temp2,0 ; new C, H and N flag
fa9059af
L
1506 sbrc z_flags,ZFL_H ; |
1507 rjmp op_da_a01 ; if (H flag ...
1508 mov temp,opl ; |
1509 andi temp,0x0f ; |
1510 cpi temp,0x0a ; or (lower nibble >= 0x0A))
1511 brlo op_da_a10 ; |
1512op_da_a01: ; then
1513 ldi oph,0x06 ; add 6 to lower nibble
1514 add opl,oph ;
1515 brhc op_da_02 ; if
1516 ori temp2,(1<<ZFL_H) ; set new H flag
1517op_da_02: ;
1518 brcc op_da_a10 ; if
1519 ori temp2,(1<<ZFL_C) ; set new H flag
1520op_da_a10: ; endif
1521 sbrc z_flags,ZFL_C ; |
1522 rjmp op_da_a12 ; if (C flag ...
1523 cpi opl,0xA0 ; |... or upper nibble >= 0xA0)
1524 brlo op_da_a13 ;
1525op_da_a12: ;
1526 ldi oph,0x60 ; add 6 to lower nibble
1527 add opl,oph ;
1528 ori temp2,(1<<ZFL_C) ; set new C flag
1529op_da_a13: ;
1530 ldpmx z_flags, sz53p_tab, opl ; get S,Z,P flag
1531 or z_flags,temp2 ; merge new C and H flag
1532 ret
1533
1534#if EM_Z80
1535
fb050095 1536op_da_sub: ;Else (sub-op)
096f3a91
L
1537 ldi temp2,(1<<ZFL_N) ; new C, H and N flag
1538 sbrc z_flags,ZFL_H ; |
1539 rjmp op_da_s01 ; if (H flag ...
1540 mov temp,opl ; |
1541 andi temp,0x0f ; |
1542 cpi temp,0x0a ; or (lower nibble >= 0x0A))
1543 brlo op_da_s10 ; |
1544op_da_s01: ; then
1545 ldi oph,0x06 ; add 6 to lower nibble
1546 sub opl,oph ;
1547 brhc PC+2 ; if
1548 ori temp2,(1<<ZFL_H) ; set new H flag
1549 brcc op_da_s10 ; if
1550 ori temp2,(1<<ZFL_C) ; set new C flag
1551op_da_s10: ; endif
1552 sbrc z_flags,ZFL_C ; |
1553 rjmp op_da_s12 ; if (C flag ...
1554 cpi opl,0x90 ; |... or upper nibble >= 0xA0)
1555 brlo op_da_s13 ;
1556op_da_s12: ;
1557 ldi oph,0x60 ; add 6 to lower nibble
1558 sub opl,oph ;
1559 ori temp2,(1<<ZFL_C) ; set new C flag
1560op_da_s13: ;
1561 ldpmx z_flags, sz53p_tab, opl ; get S,Z,P flag
1562 or z_flags,temp2 ; merge new C and H flag
1563 ret
1564
fa9059af
L
1565#endif
1566
1567#else
1568
096f3a91 1569do_op_DAA:
fa9059af
L
1570 ldi oph,0 ;oph: what to add
1571
096f3a91 1572#if EM_Z80
fa9059af
L
1573 sbrc z_flags,ZFL_N ;if add-op
1574 rjmp op_da_sub ;then
096f3a91
L
1575#endif
1576
fa9059af 1577op_da_add:
096f3a91 1578 ldi temp2,0 ; new C, H and N flag
fa9059af
L
1579 mov temp,opl ; |
1580 andi temp,0x0f ; |
1581 cpi temp,0x0a ; if (lower nibble >= 0x0A)
1582 brlo op_da_a10 ; |
1583 ori oph,0x06 ; add 6
1584 ori temp2,(1<<ZFL_H) ; set new H flag
1585
1586 sbrc z_flags,ZFL_C ; |
1587 rjmp op_da_a02 ; if (C flag ...
1588 cpi opl,0x90 ; |... or upper nibble >= 0x90)
1589 brlo op_da_a03 ; |
1590op_da_a02:
1591 ori oph,0x60 ; add 0x60
1592 ori temp2,(1<<ZFL_C) ; set new C flag
1593op_da_a03: ; endif
1594 rjmp op_da_ae
1595op_da_a10: ; else (lower nibble is 0x09 or lower)
1596 sbrc z_flags,ZFL_C ; |
1597 rjmp op_da_a12 ; if (C flag ...
1598 cpi opl,0xA0 ; |... or upper nibble >= 0xA0)
1599 brlo op_da_a13 ;
1600op_da_a12:
1601 ori oph,0x60 ; add 0x60
1602 ori temp2,(1<<ZFL_C) ; set new C flag
1603op_da_a13:
1604 sbrs z_flags,ZFL_H ; if (H flag)
1605 rjmp op_da_ae ; |
1606 ori oph,0x06 ; add 0x06
1607 mov temp,opl ; |
1608 andi temp,0x0f ; |
096f3a91 1609 cpi temp,0x06 ; if (lower nibble < 0x6)
fa9059af 1610 brsh op_da_ae ; |
096f3a91 1611; ori temp2,(1<<ZFL_H) ; set new H flag
fa9059af
L
1612 ; endif
1613 ; endif
1614op_da_ae:
1615 add opl,oph
1616 ldpmx z_flags, sz53p_tab, opl ; get S,Z,P flag
1617 or z_flags,temp2 ; merge new C and H flag
1618 ret
1619
096f3a91
L
1620#if EM_Z80
1621
fb050095 1622op_da_sub: ;Else (sub-op)
096f3a91
L
1623 ldi temp2,(1<<ZFL_N) ; new C, H and N flag
1624 mov temp,opl ; |
1625 andi temp,0x0f ; |
1626 cpi temp,0x0a ; if (lower nibble >= 0x0A)
1627 brlo op_da_s10 ; |
1628 ori oph,0x06 ; sub 6
1629
1630 sbrc z_flags,ZFL_C ; |
1631 rjmp op_da_s02 ; if (C flag ...
1632 cpi opl,0x90 ; |... or upper nibble >= 0x90)
1633 brlo op_da_s03 ; |
1634op_da_s02:
1635 ori oph,0x60 ; sub 0x60
1636 ori temp2,(1<<ZFL_C) ; set new C flag
1637op_da_s03: ; endif
1638 rjmp op_da_se
1639op_da_s10: ; else (lower nibble is 0x09 or lower)
1640 sbrc z_flags,ZFL_C ; |
1641 rjmp op_da_s12 ; if (C flag ...
1642 cpi opl,0xA0 ; |... or upper nibble >= 0xA0)
1643 brlo op_da_s13 ;
1644op_da_s12:
1645 ori oph,0x60 ; sub 0x60
1646 ori temp2,(1<<ZFL_C) ; set new C flag
1647op_da_s13:
1648 sbrs z_flags,ZFL_H ; if (H flag)
1649 rjmp op_da_se ; |
1650 ori oph,0x06 ; sub 0x06
1651 mov temp,opl ; |
1652 andi temp,0x0f ; |
1653 cpi temp,0x06 ; if (lower nibble < 0x06)
1654 brcc op_da_se ; |
1655 ori temp2,(1<<ZFL_H) ; set new H flag
1656 ; endif
1657 ; endif
1658op_da_se:
1659 sub opl,oph
1660 ldpmx z_flags, sz53p_tab, opl ; get S,Z,P flag
1661 or z_flags,temp2 ; merge new C and H flag
fb050095 1662 ret ;Endif
096f3a91
L
1663
1664#endif /* EM_Z80 */
1665#endif /* alternatives */
fa9059af
L
1666
1667
1668;----------------------------------------------------------------
1669;|Mnemonic |SZHPNC|Description |Notes |
1670;----------------------------------------------------------------
1671;|SCF |--0-01|Set Carry Flag |CY=1 |
1672;|----------|SZHP C|---------- 8080 ----------------------------|
1673;
1674;
1675do_op_scf:
1676 do_z80_flags_clear_HN
1677 ori z_flags,(1<<ZFL_C)
1678 ret
1679
1680;----------------------------------------------------------------
1681;|Mnemonic |SZHPNC|Description |Notes |
1682;----------------------------------------------------------------
1683;|CCF |--?-0*|Complement Carry Flag|CY=~CY, HC=previous CY|
1684;|----------|SZHP C|---------- 8080 ----------------------------|
1685;|CCF |---- 1|Set Carry Flag |CY=1 |
1686;
1687do_op_ccf:
1688 do_z80_flags_clear_N
1689 do_z80_flags_copy_HC
1690 ldi temp,(1<<ZFL_C)
1691 eor z_flags,temp
1692 ret
1693
1694;----------------------------------------------------------------
1695;|Mnemonic |SZHPNC|Description |Notes |
1696;----------------------------------------------------------------
1697;|CPL |--1-1-|Complement |A=~A |
1698;|----------|SZHP C|---------- 8080 ----------------------------|
1699;|CPL |---- -|Complement |A=~A |
1700;
1701;
1702do_op_cpl:
1703 com z_a
1704 do_z80_flags_set_HN
1705 ret
1706
1707
1708;----------------------------------------------------------------
1709;|Mnemonic |SZHPNC|Description |Notes |
1710;----------------------------------------------------------------
1711;|PUSH xx |------|Push |-[SP]=xx |
1712;|PUSH qq |------|Push |-[SP]=qq |
1713;
1714;
1715do_op_push16:
1716 movw xl,z_spl
1717 sbiw x,1
1718 mem_write_s oph
1719 sbiw x,1
1720 mem_write_s opl
1721 movw z_spl,xl
1722
1723.if STACK_DBG
1724 printnewline
1725 printstring "Stack push "
1726 movw temp,opl
1727 rcall printhexw
1728 printstring ", SP is now "
1729 movw temp,z_spl
1730 rcall printhexw
1731 printstring ". "
1732.endif
1733
1734 ret
1735
1736;----------------------------------------------------------------
1737;|Mnemonic |SZHPNC|Description |Notes |
1738;----------------------------------------------------------------
1739;|POP xx |------|Pop |xx=[SP]+ |
1740;|POP qq |------|Pop |qq=[SP]+ |
1741;
1742;
1743do_op_pop16:
1744 movw x,z_spl
1745 mem_read_d opl
1746 adiw x,1
1747 mem_read_d oph
1748 adiw x,1
1749 movw z_spl,x
1750
1751.if STACK_DBG
1752 printnewline
1753 printstring "Stack pop "
1754 movw temp,opl
1755 rcall printhexw
1756 printstring ", SP is now "
1757 movw temp,z_spl
1758 rcall printhexw
1759 printstring ". "
1760.endif
1761 ret
1762
1763;----------------------------------------------------------------
1764;|Mnemonic |SZHPNC|Description |Notes |
1765;----------------------------------------------------------------
1766;|EX [SP],HL|------|Exchange |[SP]<->HL |
1767;|EX DE,HL |------|Exchange |DE<->HL |
1768;-----------------------------Z80--------------------------------
1769;
1770do_op_exhl:
825ecc9d
L
1771 movw temp,z_l
1772 movw z_l,opl
1773 movw opl,temp
fa9059af
L
1774 ret
1775
1776;----------------------------------------------------------------
1777;|Mnemonic |SZHPNC|Description |Notes |
1778;----------------------------------------------------------------
4c92af0d
L
1779;|DI |------|Disable Interrupts |IFF1 = IFF2 = 0 |
1780;|EI |------|Enable Interrupts |IFF1 = IFF2 = 1 |
fa9059af 1781;
4c92af0d
L
1782
1783do_op_DI:
e7a0f403
L
1784#if EM_Z80
1785 ldd temp,y+oz_istat
4c92af0d 1786 andi temp,~((1<<IFF2) | (1<<IFF1))
e7a0f403
L
1787 std y+oz_istat,temp
1788#endif
fa9059af
L
1789 ret
1790
4c92af0d 1791do_op_EI:
e7a0f403
L
1792#if EM_Z80
1793 ldd temp,y+oz_istat
4c92af0d 1794 ori temp,(1<<IFF2) | (1<<IFF1)
e7a0f403
L
1795 std y+oz_istat,temp
1796#endif
fa9059af
L
1797 ret
1798
1799;----------------------------------------------------------------
1800;|Mnemonic |SZHPNC|Description |Notes |
1801;----------------------------------------------------------------
1802;|CALL cc,nn|------|Conditional Call |If cc CALL |
1803;|JP cc,nn |------|Conditional Jump |If cc JP |
1804;|RET cc |------|Conditional Return |If cc RET |
1805;
1806;
1807do_op_ifnz:
1808 sbrs z_flags, ZFL_Z
1809 ret
1810 pop temp ; nix tun
4c92af0d 1811 pop temp ; direkt zurueck zu main
fa9059af
L
1812 ret
1813
1814;----------------------------------------------------------------
1815;|Mnemonic |SZHPNC|Description |Notes |
1816;----------------------------------------------------------------
1817;|CALL cc,nn|------|Conditional Call |If cc CALL |
1818;|JP cc,nn |------|Conditional Jump |If cc JP |
1819;|RET cc |------|Conditional Return |If cc RET |
1820;
1821;
1822do_op_ifz:
1823 sbrc z_flags, ZFL_Z
1824 ret
1825 pop temp ; nix tun
4c92af0d 1826 pop temp ; direkt zurueck zu main
fa9059af
L
1827 ret
1828
1829;----------------------------------------------------------------
1830;|Mnemonic |SZHPNC|Description |Notes |
1831;----------------------------------------------------------------
1832;|CALL cc,nn|------|Conditional Call |If cc CALL |
1833;|JP cc,nn |------|Conditional Jump |If cc JP |
1834;|RET cc |------|Conditional Return |If cc RET |
1835;
1836;
1837do_op_ifnc:
1838 sbrs z_flags, ZFL_C
1839 ret
1840 pop temp ; nix tun
1841 pop temp ; direkt zuruech zu main
1842 ret
1843
1844;----------------------------------------------------------------
1845;|Mnemonic |SZHPNC|Description |Notes |
1846;----------------------------------------------------------------
1847;|CALL cc,nn|------|Conditional Call |If cc CALL |
1848;|JP cc,nn |------|Conditional Jump |If cc JP |
1849;|RET cc |------|Conditional Return |If cc RET |
1850;
1851;
1852do_op_ifc:
1853 sbrc z_flags, ZFL_C
1854 ret
1855 pop temp ; nix tun
1856 pop temp ; direkt zuruech zu main
1857 ret
1858
1859;----------------------------------------------------------------
1860;|Mnemonic |SZHPNC|Description |Notes |
1861;----------------------------------------------------------------
1862;|CALL cc,nn|------|Conditional Call |If cc CALL |
1863;|JP cc,nn |------|Conditional Jump |If cc JP |
1864;|RET cc |------|Conditional Return |If cc RET |
1865;
1866;
1867do_op_ifpo:
1868 sbrs z_flags, ZFL_P
1869 ret
1870 pop temp ; nix tun
1871 pop temp ; direkt zuruech zu main
1872 ret
1873
1874;----------------------------------------------------------------
1875;|Mnemonic |SZHPNC|Description |Notes |
1876;----------------------------------------------------------------
1877;|CALL cc,nn|------|Conditional Call |If cc CALL |
1878;|JP cc,nn |------|Conditional Jump |If cc JP |
1879;|RET cc |------|Conditional Return |If cc RET |
1880;
1881;
1882do_op_ifpe:
1883 sbrc z_flags, ZFL_P
1884 ret
1885 pop temp ; nix tun
1886 pop temp ; direkt zuruech zu main
1887 ret
1888
1889;----------------------------------------------------------------
1890;|Mnemonic |SZHPNC|Description |Notes |
1891;----------------------------------------------------------------
1892;|CALL cc,nn|------|Conditional Call |If cc CALL |
1893;|JP cc,nn |------|Conditional Jump |If cc JP |
1894;|RET cc |------|Conditional Return |If cc RET |
1895;
1896;
1897do_op_ifp: ;sign positive, aka s=0
1898 sbrs z_flags, ZFL_S
1899 ret
1900 pop temp ; nix tun
1901 pop temp ; direkt zuruech zu main
1902 ret
1903
1904;----------------------------------------------------------------
1905;|Mnemonic |SZHPNC|Description |Notes |
1906;----------------------------------------------------------------
1907;|CALL cc,nn|------|Conditional Call |If cc CALL |
1908;|JP cc,nn |------|Conditional Jump |If cc JP |
1909;|RET cc |------|Conditional Return |If cc RET |
1910;
1911;
1912do_op_ifm: ;sign negative, aka s=1
1913 sbrc z_flags, ZFL_S
1914 ret
1915 pop temp ; nix tun
1916 pop temp ; direkt zuruech zu main
1917 ret
1918
80e1fa71 1919;----------------------------------------------------------------
fa9059af 1920
80e1fa71
L
1921#if EM_Z80
1922
1923;----------------------------------------------------------------
1924;|Mnemonic |SZHPNC|Description |Notes |
1925;----------------------------------------------------------------
1926;|DJNZ e |------|Dec., Jump Non-Zero |B=B-1 till B=0 |
1927;
096f3a91
L
1928;The b register is decremented, and if not zero, the signed value e is added to pc.
1929;The jump is measured from the start of the instruction opcode.
1930;e = Relative addressing (PC=PC+2+offset)
1931
1932#if 1
1933
1934 ; (Joe G.)
1935do_op_DJNZ: ; decremt B, jump B=0
825ecc9d 1936 dec z_b ; B decrementieren
096f3a91
L
1937 breq do_op_DJNZ_Z ; bei B=0
1938 subi opl, 0x80 ; z_pc + e im Zweierkomplement
1939 subi z_pcl,0x80
1940 sbc z_pch,_0
1941 add z_pcl,opl
1942 adc z_pch,_0
1943do_op_DJNZ_Z:
1944 ret
1945
1946#else
80e1fa71
L
1947
1948do_op_djnz:
825ecc9d 1949 dec z_b
80e1fa71
L
1950 brne opdjnze
1951 pop temp ; nix tun
096f3a91 1952 pop temp ; direkt zurueck zu main
80e1fa71
L
1953opdjnze:
1954 ret
1955
096f3a91 1956#endif
80e1fa71
L
1957
1958;----------------------------------------------------------------
1959;|Mnemonic |SZHPNC|Description |Notes |
1960;----------------------------------------------------------------
1961;|EX AF,AF' |------|Exchange |AF<->AF' |
1962
1963do_op_EXAF:
e7a0f403
L
1964 ldd temp,y+oz_f2
1965 ldd temp2,y+oz_a2
1966 std y+oz_f2,z_flags
1967 std y+oz_a2,z_a
80e1fa71
L
1968 mov z_flags,temp
1969 mov z_a,temp2
1970 ret
1971
1972
1973;----------------------------------------------------------------
1974;|Mnemonic |SZHPNC|Description |Notes |
fa9059af 1975;----------------------------------------------------------------
80e1fa71
L
1976;|EXX |------|Exchange |qq<->qq' (except AF)|
1977
1978
825ecc9d
L
1979#if 1
1980
1981do_op_EXX:
1982 ldd temp ,y+oz_c2
1983 ldd temp2,y+oz_b2
1984 std y+oz_c2,z_c
1985 std y+oz_b2,z_b
1986 movw z_c,temp
1987
1988 ldd temp ,y+oz_e2
1989 ldd temp2,y+oz_d2
1990 std y+oz_e2,z_e
1991 std y+oz_d2,z_d
1992 movw z_e,temp
1993
1994 ldd temp ,y+oz_l2
1995 ldd temp2,y+oz_h2
1996 std y+oz_l2,z_l
1997 std y+oz_h2,z_h
1998 movw z_l,temp
1999 ret
2000#else
2001
80e1fa71
L
2002do_op_EXX:
2003 ldiw z,z_b
2004 ldi temp3,6
2005opexx_loop:
2006 ld temp,z
2007 ldd temp2,z+r2ofs
2008 std z+r2ofs,temp
2009 st z+,temp2
2010 dec temp3
2011 brne opexx_loop
2012 ret
2013
825ecc9d
L
2014#endif
2015
80e1fa71
L
2016#else
2017do_op_djnz:
2018do_op_EXAF:
2019do_op_EXX:
096f3a91 2020 ljmp do_op_inv
80e1fa71
L
2021 ret
2022#endif
fa9059af
L
2023
2024#if EM_Z80
2025
2026do_op_prefixED:
2027 mem_read_ds zl,z_pc ;zl = memReadByte(z_pc)
2028 adiw z_pcl,1 ;++z_pc
2029 ldi zh,high(EDjmp) ;
2030 ijmp
2031
2032
2033do_op_prefixDD:
80e1fa71 2034 cbi flags,prefixfd
fa9059af
L
2035 mem_read_ds zl,z_pc ;zl = memReadByte(z_pc)
2036 adiw z_pcl,1 ;++z_pc
2037 ldi zh,high(DDFDjmp) ;
2038 ijmp
2039
2040
2041do_op_prefixFD:
80e1fa71 2042 sbi flags,prefixfd
fa9059af
L
2043 mem_read_ds zl,z_pc ;zl = memReadByte(z_pc)
2044 adiw z_pcl,1 ;++z_pc
2045 ldi zh,high(DDFDjmp) ;
2046 ijmp
2047
80e1fa71
L
2048do_op_prefixCB:
2049 mem_read_ds zl,z_pc ;zl = memReadByte(z_pc)
2050 adiw z_pcl,1 ;++z_pc
2051 ldi zh,high(CBjmp) ;
2052 ijmp
2053
2054
2055do_op_prefixDDFDCB:
e7a0f403
L
2056 sbic flags,prefixfd
2057 rjmp opprxcb_fd
2058 ldd xh,y+oz_xh
2059 ldd xl,y+oz_xl
2060 rjmp opprxcb_1
2061opprxcb_fd:
2062 ldd xh,y+oz_yh
2063 ldd xl,y+oz_yl
2064opprxcb_1:
2065 mem_read_s z_pc ;get displacement
2066 adiw z_pcl,1 ;++z_pc
2067 clr temp2 ;sign extend
2068 tst temp
2069 brpl PC+2
2070 com temp2
2071 add xl,temp ;add displacement
2072 adc xh,temp2
2073 mem_read_d opl
2074
80e1fa71
L
2075 mem_read_ds zl,z_pc ;zl = opcode
2076 adiw z_pcl,1 ;++z_pc
e7a0f403
L
2077 ldi zh,high(DDFDCBjmp) ;
2078 icall
2079 mem_write_s opl
2080 ret
80e1fa71
L
2081
2082
fa9059af
L
2083#else ; TODO: geht das so?
2084
2085do_op_prefixED:
2086do_op_prefixDD:
2087do_op_prefixFD:
80e1fa71 2088do_op_prefixCB:
096f3a91 2089 ljmp do_op_inv
fa9059af
L
2090 ret
2091#endif
2092
2093
623dd899 2094
fa9059af
L
2095; ----------------------- Opcode decoding -------------------------
2096
2097; Lookup table for Z80 opcodes. Translates the first byte of the instruction word into three
2098; operations: fetch, do something, store.
2099; The table is made of 256 words.
2100
623dd899 2101 opctable opcjmp, PC ;+3*256
fa9059af
L
2102
2103instr fetch_nop, op_nop, store_nop ;00 ;NOP
2104instr fetch_DIR16, op_nop, store_BC ;01 nn nn ;LD BC,nn
2105instr fetch_nop, op_nop, store_MBC ;02 ;LD (BC),A
825ecc9d
L
2106;instr fetch_BC, op_INC16, store_BC ;03 ;INC BC
2107instr fetch_nop, op_INCBC, store_nop ;03 ;INC BC
fa9059af 2108instr fetch_B, op_INC, store_B ;04 ;INC B
623dd899 2109instr fetch_B, op_DEC, store_B ;05 ;DEC B
fa9059af
L
2110instr fetch_DIR8, op_nop, store_B ;06 ;LD B,n
2111instr fetch_nop, op_RLCA, store_nop ;07 ;RLCA
623dd899 2112instr fetch_nop, op_EXAF, store_nop ;08 ;EX AF,AF'
80e1fa71 2113instr fetch_BC, op_ADDHL, store_nop ;09 ;ADD HL,BC
fa9059af 2114instr fetch_MBC, op_nop, store_nop ;0A ;LD A,(BC)
825ecc9d
L
2115;instr fetch_BC, op_DEC16, store_BC ;0B ;DEC BC
2116instr fetch_nop, op_DECBC, store_nop ;0B ;DEC BC
fa9059af
L
2117instr fetch_C, op_INC, store_C ;0C ;INC C
2118instr fetch_C, op_DEC, store_C ;0D ;DEC C
2119instr fetch_DIR8, op_nop, store_C ;0E nn ;LD C,n
2120instr fetch_nop, op_RRCA, store_nop ;0F ;RRCA
096f3a91 2121instr fetch_DIR8, op_DJNZ, store_nop ;10 oo ;DJNZ o
fa9059af
L
2122instr fetch_DIR16, op_nop, store_DE ;11 nn nn ;LD DE,nn
2123instr fetch_nop, op_nop, store_MDE ;12 ;LD (DE),A
825ecc9d
L
2124;instr fetch_DE, op_INC16, store_DE ;13 ;INC DE
2125instr fetch_nop, op_INCDE, store_nop ;13 ;INC DE
fa9059af 2126instr fetch_D, op_INC, store_D ;14 ;INC D
623dd899 2127instr fetch_D, op_DEC, store_D ;15 ;DEC D
fa9059af
L
2128instr fetch_DIR8, op_nop, store_D ;16 nn ;LD D,n
2129instr fetch_nop, op_RLA, store_nop ;17 ;RLA
80e1fa71
L
2130instr fetch_DIR8, op_nop, store_pcrel ;18 oo ;JR o
2131instr fetch_DE, op_ADDHL, store_nop ;19 ;ADD HL,DE
fa9059af 2132instr fetch_MDE, op_nop, store_nop ;1A ;LD A,(DE)
825ecc9d
L
2133;instr fetch_DE, op_DEC16, store_DE ;1B ;DEC DE
2134instr fetch_nop, op_DECDE, store_nop ;1B ;DEC DE
fa9059af 2135instr fetch_E, op_INC, store_E ;1C ;INC E
623dd899 2136instr fetch_E, op_DEC, store_E ;1D ;DEC E
fa9059af
L
2137instr fetch_DIR8, op_nop, store_E ;1E nn ;LD E,n
2138instr fetch_nop, op_RRA, store_nop ;1F ;RRA
80e1fa71 2139instr fetch_DIR8, op_IFNZ, store_pcrel ;20 oo ;JR NZ,o
fa9059af
L
2140instr fetch_DIR16, op_nop, store_HL ;21 nn nn ;LD HL,nn
2141instr fetch_DIR16, op_STHL, store_nop ;22 nn nn ;LD (nn),HL
825ecc9d
L
2142;instr fetch_HL, op_INC16, store_HL ;23 ;INC HL
2143instr fetch_nop, op_INCHL, store_nop ;23 ;INC HL
623dd899
L
2144instr fetch_H, op_INC, store_H ;24 ;INC H
2145instr fetch_H, op_DEC, store_H ;25 ;DEC H
2146instr fetch_DIR8, op_nop, store_H ;26 nn ;LD H,n
2147instr fetch_A, op_DAA, store_A ;27 ;DAA
80e1fa71
L
2148instr fetch_DIR8, op_IFZ, store_pcrel ;28 oo ;JR Z,o
2149instr fetch_HL, op_ADDHL, store_nop ;29 ;ADD HL,HL
fa9059af 2150instr fetch_DIR16, op_RMEM16, store_HL ;2A nn nn ;LD HL,(nn)
825ecc9d
L
2151;instr fetch_HL, op_DEC16, store_HL ;2B ;DEC HL
2152instr fetch_nop, op_DECHL, store_nop ;2B ;DEC HL
623dd899
L
2153instr fetch_L, op_INC, store_L ;2C ;INC L
2154instr fetch_L, op_DEC, store_L ;2D ;DEC L
2155instr fetch_DIR8, op_nop, store_L ;2E nn ;LD L,n
2156instr fetch_nop, op_CPL, store_nop ;2F ;CPL
80e1fa71 2157instr fetch_DIR8, op_IFNC, store_pcrel ;30 oo ;JR NC,o
fa9059af
L
2158instr fetch_DIR16, op_nop, store_SP ;31 nn nn ;LD SP,nn
2159instr fetch_DIR16, op_nop, store_AM ;32 nn nn ;LD (nn),A
2160instr fetch_SP, op_INC16, store_SP ;33 ;INC SP
2161instr fetch_MHL, op_INC, store_MHL ;34 ;INC (HL)
623dd899 2162instr fetch_MHL, op_DEC, store_MHL ;35 ;DEC (HL)
fa9059af
L
2163instr fetch_DIR8, op_nop, store_MHL ;36 nn ;LD (HL),n
2164instr fetch_nop, op_SCF, store_nop ;37 ;SCF
80e1fa71
L
2165instr fetch_DIR8, op_IFC, store_pcrel ;38 oo ;JR C,o
2166instr fetch_SP, op_ADDHL, store_nop ;39 ;ADD HL,SP
623dd899
L
2167instr fetch_DIR16, op_RMEM8, store_A ;3A nn nn ;LD A,(nn)
2168instr fetch_SP, op_DEC16, store_SP ;3B ;DEC SP
fa9059af 2169instr fetch_nop, op_INCA, store_nop ;3C ;INC A
623dd899
L
2170instr fetch_nop, op_DECA, store_nop ;3D ;DEC A
2171instr fetch_DIR8, op_nop, store_A ;3E nn ;LD A,n
2172instr fetch_nop, op_CCF, store_nop ;3F ;CCF (Complement Carry Flag, gvd)
fa9059af
L
2173instr fetch_nop, op_nop, store_nop ;40 ;LD B,B
2174instr fetch_C, op_nop, store_B ;41 ;LD B,C
2175instr fetch_D, op_nop, store_B ;42 ;LD B,D
2176instr fetch_E, op_nop, store_B ;43 ;LD B,E
2177instr fetch_H, op_nop, store_B ;44 ;LD B,H
2178instr fetch_L, op_nop, store_B ;45 ;LD B,L
2179instr fetch_MHL, op_nop, store_B ;46 ;LD B,(HL)
2180instr fetch_A, op_nop, store_B ;47 ;LD B,A
2181instr fetch_B, op_nop, store_C ;48 ;LD C,B
2182instr fetch_nop, op_nop, store_nop ;49 ;LD C,C
2183instr fetch_D, op_nop, store_C ;4A ;LD C,D
2184instr fetch_E, op_nop, store_C ;4B ;LD C,E
2185instr fetch_H, op_nop, store_C ;4C ;LD C,H
2186instr fetch_L, op_nop, store_C ;4D ;LD C,L
2187instr fetch_MHL, op_nop, store_C ;4E ;LD C,(HL)
2188instr fetch_A, op_nop, store_C ;4F ;LD C,A
2189instr fetch_B, op_nop, store_D ;50 ;LD D,B
2190instr fetch_C, op_nop, store_D ;51 ;LD D,C
2191instr fetch_nop, op_nop, store_nop ;52 ;LD D,D
2192instr fetch_E, op_nop, store_D ;53 ;LD D,E
2193instr fetch_H, op_nop, store_D ;54 ;LD D,H
2194instr fetch_L, op_nop, store_D ;55 ;LD D,L
2195instr fetch_MHL, op_nop, store_D ;56 ;LD D,(HL)
2196instr fetch_A, op_nop, store_D ;57 ;LD D,A
2197instr fetch_B, op_nop, store_E ;58 ;LD E,B
2198instr fetch_C, op_nop, store_E ;59 ;LD E,C
2199instr fetch_D, op_nop, store_E ;5A ;LD E,D
2200instr fetch_nop, op_nop, store_nop ;5B ;LD E,E
2201instr fetch_H, op_nop, store_E ;5C ;LD E,H
2202instr fetch_L, op_nop, store_E ;5D ;LD E,L
2203instr fetch_MHL, op_nop, store_E ;5E ;LD E,(HL)
2204instr fetch_A, op_nop, store_E ;5F ;LD E,A
2205instr fetch_B, op_nop, store_H ;60 ;LD H,B
2206instr fetch_C, op_nop, store_H ;61 ;LD H,C
2207instr fetch_D, op_nop, store_H ;62 ;LD H,D
2208instr fetch_E, op_nop, store_H ;63 ;LD H,E
2209instr fetch_nop, op_nop, store_nop ;64 ;LD H,H
2210instr fetch_L, op_nop, store_H ;65 ;LD H,L
2211instr fetch_MHL, op_nop, store_H ;66 ;LD H,(HL)
2212instr fetch_A, op_nop, store_H ;67 ;LD H,A
2213instr fetch_B, op_nop, store_L ;68 ;LD L,B
2214instr fetch_C, op_nop, store_L ;69 ;LD L,C
2215instr fetch_D, op_nop, store_L ;6A ;LD L,D
2216instr fetch_E, op_nop, store_L ;6B ;LD L,E
2217instr fetch_H, op_nop, store_L ;6C ;LD L,H
2218instr fetch_nop, op_nop, store_nop ;6D ;LD L,L
2219instr fetch_MHL, op_nop, store_L ;6E ;LD L,(HL)
2220instr fetch_A, op_nop, store_L ;6F ;LD L,A
2221instr fetch_B, op_nop, store_MHL ;70 ;LD (HL),B
2222instr fetch_C, op_nop, store_MHL ;71 ;LD (HL),C
2223instr fetch_D, op_nop, store_MHL ;72 ;LD (HL),D
2224instr fetch_E, op_nop, store_MHL ;73 ;LD (HL),E
2225instr fetch_H, op_nop, store_MHL ;74 ;LD (HL),H
2226instr fetch_L, op_nop, store_MHL ;75 ;LD (HL),L
80e1fa71 2227instr fetch_nop, op_HALT, store_nop ;76 ;HALT
fa9059af
L
2228instr fetch_A, op_nop, store_MHL ;77 ;LD (HL),A
2229instr fetch_B, op_nop, store_A ;78 ;LD A,B
2230instr fetch_C, op_nop, store_A ;79 ;LD A,C
2231instr fetch_D, op_nop, store_A ;7A ;LD A,D
2232instr fetch_E, op_nop, store_A ;7B ;LD A,E
2233instr fetch_H, op_nop, store_A ;7C ;LD A,H
2234instr fetch_L, op_nop, store_A ;7D ;LD A,L
2235instr fetch_MHL, op_nop, store_A ;7E ;LD A,(HL)
2236instr fetch_nop, op_nop, store_nop ;7F ;LD A,A
2237instr fetch_B, op_ADDA, store_nop ;80 ;ADD A,B
2238instr fetch_C, op_ADDA, store_nop ;81 ;ADD A,C
2239instr fetch_D, op_ADDA, store_nop ;82 ;ADD A,D
2240instr fetch_E, op_ADDA, store_nop ;83 ;ADD A,E
2241instr fetch_H, op_ADDA, store_nop ;84 ;ADD A,H
2242instr fetch_L, op_ADDA, store_nop ;85 ;ADD A,L
2243instr fetch_MHL, op_ADDA, store_nop ;86 ;ADD A,(HL)
2244instr fetch_A, op_ADDA, store_nop ;87 ;ADD A,A
2245instr fetch_B, op_ADCA, store_nop ;88 ;ADC A,B
2246instr fetch_C, op_ADCA, store_nop ;89 ;ADC A,C
2247instr fetch_D, op_ADCA, store_nop ;8A ;ADC A,D
2248instr fetch_E, op_ADCA, store_nop ;8B ;ADC A,E
2249instr fetch_H, op_ADCA, store_nop ;8C ;ADC A,H
2250instr fetch_L, op_ADCA, store_nop ;8D ;ADC A,L
2251instr fetch_MHL, op_ADCA, store_nop ;8E ;ADC A,(HL)
2252instr fetch_A, op_ADCA, store_nop ;8F ;ADC A,A
2253instr fetch_B, op_SUBFA, store_nop ;90 ;SUB A,B
2254instr fetch_C, op_SUBFA, store_nop ;91 ;SUB A,C
2255instr fetch_D, op_SUBFA, store_nop ;92 ;SUB A,D
2256instr fetch_E, op_SUBFA, store_nop ;93 ;SUB A,E
2257instr fetch_H, op_SUBFA, store_nop ;94 ;SUB A,H
2258instr fetch_L, op_SUBFA, store_nop ;95 ;SUB A,L
2259instr fetch_MHL, op_SUBFA, store_nop ;96 ;SUB A,(HL)
2260instr fetch_A, op_SUBFA, store_nop ;97 ;SUB A,A
2261instr fetch_B, op_SBCFA, store_nop ;98 ;SBC A,B
2262instr fetch_C, op_SBCFA, store_nop ;99 ;SBC A,C
2263instr fetch_D, op_SBCFA, store_nop ;9A ;SBC A,D
2264instr fetch_E, op_SBCFA, store_nop ;9B ;SBC A,E
2265instr fetch_H, op_SBCFA, store_nop ;9C ;SBC A,H
2266instr fetch_L, op_SBCFA, store_nop ;9D ;SBC A,L
2267instr fetch_MHL, op_SBCFA, store_nop ;9E ;SBC A,(HL)
2268instr fetch_A, op_SBCFA, store_nop ;9F ;SBC A,A
2269instr fetch_B, op_ANDA, store_nop ;A0 ;AND A,B
2270instr fetch_C, op_ANDA, store_nop ;A1 ;AND A,C
2271instr fetch_D, op_ANDA, store_nop ;A2 ;AND A,D
2272instr fetch_E, op_ANDA, store_nop ;A3 ;AND A,E
2273instr fetch_H, op_ANDA, store_nop ;A4 ;AND A,H
2274instr fetch_L, op_ANDA, store_nop ;A5 ;AND A,L
2275instr fetch_MHL, op_ANDA, store_nop ;A6 ;AND A,(HL)
2276instr fetch_A, op_ANDA, store_nop ;A7 ;AND A,A
2277instr fetch_B, op_XORA, store_nop ;A8 ;XOR A,B
2278instr fetch_C, op_XORA, store_nop ;A9 ;XOR A,C
2279instr fetch_D, op_XORA, store_nop ;AA ;XOR A,D
2280instr fetch_E, op_XORA, store_nop ;AB ;XOR A,E
2281instr fetch_H, op_XORA, store_nop ;AC ;XOR A,H
2282instr fetch_L, op_XORA, store_nop ;AD ;XOR A,L
2283instr fetch_MHL, op_XORA, store_nop ;AE ;XOR A,(HL)
2284instr fetch_A, op_XORA, store_nop ;AF ;XOR A,A
2285instr fetch_B, op_ORA, store_nop ;B0 ;OR A,B
2286instr fetch_C, op_ORA, store_nop ;B1 ;OR A,C
2287instr fetch_D, op_ORA, store_nop ;B2 ;OR A,D
2288instr fetch_E, op_ORA, store_nop ;B3 ;OR A,E
2289instr fetch_H, op_ORA, store_nop ;B4 ;OR A,H
2290instr fetch_L, op_ORA, store_nop ;B5 ;OR A,L
2291instr fetch_MHL, op_ORA, store_nop ;B6 ;OR A,(HL)
2292instr fetch_A, op_ORA, store_nop ;B7 ;OR A,A
623dd899
L
2293instr fetch_B, op_CPFA, store_nop ;B8 ;CP A,B
2294instr fetch_C, op_CPFA, store_nop ;B9 ;CP A,C
2295instr fetch_D, op_CPFA, store_nop ;BA ;CP A,D
2296instr fetch_E, op_CPFA, store_nop ;BB ;CP A,E
2297instr fetch_H, op_CPFA, store_nop ;BC ;CP A,H
2298instr fetch_L, op_CPFA, store_nop ;BD ;CP A,L
2299instr fetch_MHL, op_CPFA, store_nop ;BE ;CP A,(HL)
2300instr fetch_A, op_CPFA, store_nop ;BF ;CP A,A
fa9059af
L
2301instr fetch_nop, op_IFNZ, store_RET ;C0 ;RET NZ
2302instr fetch_nop, op_POP16, store_BC ;C1 ;POP BC
2303instr fetch_DIR16, op_IFNZ, store_PC ;C2 nn nn ;JP NZ,nn
2304instr fetch_DIR16, op_nop, store_PC ;C3 nn nn ;JP nn
2305instr fetch_DIR16, op_IFNZ, store_CALL ;C4 nn nn ;CALL NZ,nn
2306instr fetch_BC, op_PUSH16, store_nop ;C5 ;PUSH BC
2307instr fetch_DIR8, op_ADDA, store_nop ;C6 nn ;ADD A,n
2308instr fetch_RST, op_nop, store_CALL ;C7 ;RST 0
2309instr fetch_nop, op_IFZ, store_RET ;C8 ;RET Z
2310instr fetch_nop, op_nop, store_RET ;C9 ;RET
2311instr fetch_DIR16, op_IFZ, store_PC ;CA nn nn ;JP Z,nn
80e1fa71 2312instr fetch_nop, op_prefixCB, store_nop ;CB ;(CB opcode prefix)
fa9059af
L
2313instr fetch_DIR16, op_IFZ, store_CALL ;CC nn nn ;CALL Z,nn
2314instr fetch_DIR16, op_nop, store_CALL ;CD nn nn ;CALL nn
2315instr fetch_DIR8, op_ADCA, store_nop ;CE nn ;ADC A,n
2316instr fetch_RST, op_nop, store_CALL ;CF ;RST 8H
2317instr fetch_nop, op_IFNC, store_RET ;D0 ;RET NC
2318instr fetch_nop, op_POP16, store_DE ;D1 ;POP DE
2319instr fetch_DIR16, op_IFNC, store_PC ;D2 nn nn ;JP NC,nn
2320instr fetch_DIR8, op_OUTA, store_nop ;D3 nn ;OUT (n),A
2321instr fetch_DIR16, op_IFNC, store_CALL ;D4 nn nn ;CALL NC,nn
2322instr fetch_DE, op_PUSH16, store_nop ;D5 ;PUSH DE
2323instr fetch_DIR8, op_SUBFA, store_nop ;D6 nn ;SUB n
2324instr fetch_RST, op_nop, store_CALL ;D7 ;RST 10H
2325instr fetch_nop, op_IFC, store_RET ;D8 ;RET C
623dd899 2326instr fetch_nop, op_EXX, store_nop ;D9 ;EXX
fa9059af 2327instr fetch_DIR16, op_IFC, store_PC ;DA nn nn ;JP C,nn
80e1fa71 2328instr fetch_DIR8, op_INA, store_nop ;DB nn ;IN A,(n)
fa9059af 2329instr fetch_DIR16, op_IFC, store_CALL ;DC nn nn ;CALL C,nn
e7a0f403 2330instr fetch_nop, op_prefixDD, store_nop ;DD ;(DD opcode prefix)
fa9059af
L
2331instr fetch_DIR8, op_SBCFA, store_nop ;DE nn ;SBC A,n
2332instr fetch_RST, op_nop, store_CALL ;DF ;RST 18H
2333instr fetch_nop, op_IFPO, store_RET ;E0 ;RET PO
2334instr fetch_nop, op_POP16, store_HL ;E1 ;POP HL
2335instr fetch_DIR16, op_IFPO, store_PC ;E2 nn nn ;JP PO,nn
623dd899 2336instr fetch_MSP, op_EXHL, store_MSP ;E3 ;EX (SP),HL
fa9059af
L
2337instr fetch_DIR16, op_IFPO, store_CALL ;E4 nn nn ;CALL PO,nn
2338instr fetch_HL, op_PUSH16, store_nop ;E5 ;PUSH HL
2339instr fetch_DIR8, op_ANDA, store_nop ;E6 nn ;AND n
2340instr fetch_RST, op_nop, store_CALL ;E7 ;RST 20H
2341instr fetch_nop, op_IFPE, store_RET ;E8 ;RET PE
2342instr fetch_HL, op_nop, store_PC ;E9 ;JP HL
2343instr fetch_DIR16, op_IFPE, store_PC ;EA nn nn ;JP PE,nn
623dd899 2344instr fetch_DE, op_EXHL, store_DE ;EB ;EX DE,HL
fa9059af
L
2345instr fetch_DIR16, op_IFPE, store_CALL ;EC nn nn ;CALL PE,nn
2346instr fetch_nop, op_prefixED, store_nop ;ED ;(ED opcode prefix)
2347instr fetch_DIR8, op_XORA, store_nop ;EE nn ;XOR n
2348instr fetch_RST, op_nop, store_CALL ;EF ;RST 28H
2349instr fetch_nop, op_IFP, store_RET ;F0 ;RET P
2350instr fetch_nop, op_POP16, store_AF ;F1 ;POP AF
2351instr fetch_DIR16, op_IFP, store_PC ;F2 nn nn ;JP P,nn
623dd899 2352instr fetch_nop, op_DI, store_nop ;F3 ;DI
fa9059af
L
2353instr fetch_DIR16, op_IFP, store_CALL ;F4 nn nn ;CALL P,nn
2354instr fetch_AF, op_PUSH16, store_nop ;F5 ;PUSH AF
2355instr fetch_DIR8, op_ORA, store_nop ;F6 nn ;OR n
2356instr fetch_RST, op_nop, store_CALL ;F7 ;RST 30H
2357instr fetch_nop, op_IFM, store_RET ;F8 ;RET M
2358instr fetch_HL, op_nop, store_SP ;F9 ;LD SP,HL
2359instr fetch_DIR16, op_IFM, store_PC ;FA nn nn ;JP M,nn
623dd899 2360instr fetch_nop, op_EI, store_nop ;FB ;EI
fa9059af
L
2361instr fetch_DIR16, op_IFM, store_CALL ;FC nn nn ;CALL M,nn
2362instr fetch_nop, op_prefixFD, store_nop ;FD ;(FD opcode prefix)
623dd899 2363instr fetch_DIR8, op_CPFA, store_nop ;FE nn ;CP n
fa9059af
L
2364instr fetch_RST, op_nop, store_CALL ;FF ;RST 38H
2365
2366
2367#if EM_Z80
2368
e7a0f403
L
2369
2370
623dd899
L
2371 checkspace PC, 2
2372
2373do_op_noni:
2374 sbiw z_pcl,1 ;--z_pc
fa9059af
L
2375 ret
2376
623dd899
L
2377 checkspace PC, 16
2378
096f3a91
L
2379do_fetch_dir8_2:
2380 movw xl,z_pcl
2381 adiw xl,1
2382 mem_read_d opl
2383 ret
2384
623dd899 2385 checkspace PC, 5
80e1fa71 2386
623dd899
L
2387do_fetch_xh:
2388 sbis flags,prefixfd
2389 ldd opl,y+oz_xh
2390 sbic flags,prefixfd
2391 ldd opl,y+oz_yh
2392 ret
80e1fa71 2393
623dd899 2394 checkspace PC, 5
80e1fa71 2395
623dd899
L
2396do_fetch_xl:
2397 sbis flags,prefixfd
2398 ldd opl,y+oz_xl
2399 sbic flags,prefixfd
2400 ldd opl,y+oz_yl
80e1fa71
L
2401 ret
2402
80e1fa71 2403
623dd899 2404 checkspace PC, 41
80e1fa71 2405
623dd899
L
2406do_fetch_mxx:
2407 sbic flags,prefixfd
2408 rjmp fetchmxx_fd
2409 ldd xh,y+oz_xh
2410 ldd xl,y+oz_xl
2411 rjmp fetchmxx1
2412fetchmxx_fd:
2413 ldd xh,y+oz_yh
2414 ldd xl,y+oz_yl
2415fetchmxx1:
2416 mem_read_ds opl, z_pc ;get displacement
2417 adiw z_pcl,1
2418 clr oph ;sign extend
2419 tst opl
2420 brpl fetchmxx2
2421 com oph
2422fetchmxx2:
2423 add xl,opl ;add displacement
2424 adc xh,oph
2425 mem_read_d opl ;get operand
2426 ret ;(Ix+d) still in xl,xh
80e1fa71 2427
623dd899
L
2428
2429 checkspace PC, 8
2430
2431do_fetch_xx:
2432 sbic flags,prefixfd
2433 rjmp fetchxx_fd
2434 ldd opl,y+oz_xl
2435 ldd oph,y+oz_xh
2436 ret
2437fetchxx_fd:
2438 ldd opl,y+oz_yl
2439 ldd oph,y+oz_yh
fa9059af
L
2440 ret
2441
623dd899
L
2442 checkspace PC, 5
2443
2444do_store_xh:
2445 sbis flags,prefixfd
2446 std y+oz_xh,opl
2447 sbic flags,prefixfd
2448 std y+oz_yh,opl
fa9059af
L
2449 ret
2450
623dd899
L
2451 checkspace PC, 5
2452
2453do_store_xl:
2454 sbis flags,prefixfd
2455 std y+oz_xl,opl
2456 sbic flags,prefixfd
2457 std y+oz_yl,opl
fa9059af
L
2458 ret
2459
623dd899 2460 checkspace PC, 37
80e1fa71 2461
80e1fa71
L
2462do_store_mxx:
2463 sbic flags,prefixfd
2464 rjmp storemxx_fd
e7a0f403
L
2465 ldd xh,y+oz_xh
2466 ldd xl,y+oz_xl
80e1fa71
L
2467 rjmp storemxx1
2468storemxx_fd:
e7a0f403
L
2469 ldd xh,y+oz_yh
2470 ldd xl,y+oz_yl
80e1fa71
L
2471storemxx1:
2472 mem_read_s z_pc ;get displacement
2473 adiw z_pcl,1
2474 clr temp2 ;sign extend
2475 tst temp
2476 brpl storemxx2
2477 com temp2
2478storemxx2:
2479 add xl,temp ;add displacement
2480 adc xh,temp2
e7a0f403 2481 mem_write_s opl ;store operand
80e1fa71
L
2482 ret
2483
623dd899
L
2484 checkspace PC, 10
2485
096f3a91
L
2486do_store_mxx_0:
2487 mem_write_s opl ;store operand
2488 ret
2489
623dd899
L
2490 checkspace PC, 38
2491
8fec4e62
L
2492do_store_mxx_2:
2493 sbic flags,prefixfd
2494 rjmp storemxx2_fd
2495 ldd xh,y+oz_xh
2496 ldd xl,y+oz_xl
2497 rjmp storemxx21
2498storemxx2_fd:
2499 ldd xh,y+oz_yh
2500 ldd xl,y+oz_yl
2501storemxx21:
2502 mem_read_s z_pc ;get displacement
2503 adiw z_pcl,1
2504 adiw z_pcl,1
2505 clr temp2 ;sign extend
2506 tst temp
2507 brpl storemxx22
2508 com temp2
2509storemxx22:
2510 add xl,temp ;add displacement
2511 adc xh,temp2
2512 mem_write_s opl ;store operand
2513 ret
2514
623dd899
L
2515 checkspace PC, 8
2516
80e1fa71
L
2517do_store_xx:
2518 sbic flags,prefixfd
2519 rjmp storexx_fd
e7a0f403
L
2520 std y+oz_xl,opl
2521 std y+oz_xh,oph
80e1fa71
L
2522 ret
2523storexx_fd:
e7a0f403
L
2524 std y+oz_yl,opl
2525 std y+oz_yh,oph
80e1fa71
L
2526 ret
2527
fa9059af
L
2528;----------------------------------------------------------------
2529;|Mnemonic |SZHPNC|Description |Notes |
2530;----------------------------------------------------------------
80e1fa71
L
2531;|LD dst,src|------|Load |dst=src |
2532;
623dd899
L
2533
2534 checkspace PC, 30
2535
80e1fa71
L
2536do_op_stxx: ;store xx to mem loc in opl:h
2537
623dd899 2538 movw xl,opl
80e1fa71 2539 sbis flags,prefixfd
e7a0f403 2540 ldd temp,y+oz_xl
80e1fa71 2541 sbic flags,prefixfd
e7a0f403 2542 ldd temp,y+oz_yl
80e1fa71
L
2543 mem_write
2544 adiw xl,1
2545 sbis flags,prefixfd
e7a0f403 2546 ldd temp,y+oz_xh
80e1fa71 2547 sbic flags,prefixfd
e7a0f403 2548 ldd temp,y+oz_yh
80e1fa71
L
2549 mem_write
2550 ret
2551
2552
2553;----------------------------------------------------------------
2554;|Mnemonic |SZHPNC|Description |Notes |
2555;----------------------------------------------------------------
2556;|EX [SP],IX|------|Exchange |[SP]<->IX |
2557;|EX [SP],IY|------|Exchange |[SP]<->IY |
2558;
623dd899
L
2559 checkspace PC, 13
2560
80e1fa71
L
2561do_op_EXxx:
2562 sbic flags,prefixfd
2563 rjmp opexxx_fd
e7a0f403
L
2564 ldd temp,y+oz_xl
2565 ldd temp2,y+oz_xh
2566 std y+oz_xl,opl
2567 std y+oz_xh,oph
80e1fa71
L
2568 rjmp opexxxe
2569opexxx_fd:
e7a0f403
L
2570 ldd temp,y+oz_yl
2571 ldd temp2,y+oz_yh
2572 std y+oz_yl,opl
2573 std y+oz_yh,oph
80e1fa71
L
2574opexxxe:
2575 movw opl,temp
2576 ret
2577
2578;----------------------------------------------------------------
2579;|Mnemonic |SZHPNC|Description |Notes |
2580;----------------------------------------------------------------
2581;|ADD IX,pp |--*-0*|Add |IX=IX+pp |
2582;|ADD IY,rr |--*-0*|Add |IY=IY+rr |
fa9059af 2583;
623dd899
L
2584
2585 checkspace PC, 25
2586
fa9059af 2587do_op_addxx:
80e1fa71
L
2588 sbic flags,prefixfd
2589 rjmp opadx_fd
e7a0f403
L
2590 ldd temp,y+oz_xl
2591 ldd temp2,y+oz_xh
2592 add opl,temp
2593 adc oph,temp2
2594 std y+oz_xl,opl
2595 std y+oz_xh,oph
80e1fa71
L
2596 rjmp opadx_e
2597opadx_fd:
e7a0f403
L
2598 ldd temp,y+oz_yl
2599 ldd temp2,y+oz_yh
2600 add opl,temp
2601 adc oph,temp2
2602 std y+oz_yl,opl
2603 std y+oz_yh,oph
80e1fa71 2604opadx_e:
e7a0f403 2605 in temp,sreg
80e1fa71
L
2606 bmov z_flags,ZFL_C, temp,AVR_C
2607 do_z80_flags_H
fa9059af
L
2608 do_z80_flags_clear_N
2609 ret
2610
80e1fa71 2611
623dd899 2612 opctable DDFDjmp, PC ;+256
e7a0f403 2613
623dd899
L
2614instr fetch_nop, op_noni, store_nop ;00 ;
2615instr fetch_nop, op_noni, store_nop ;01 ;
2616instr fetch_nop, op_noni, store_nop ;02 ;
2617instr fetch_nop, op_noni, store_nop ;03 ;
2618instr fetch_nop, op_noni, store_nop ;04 ;
2619instr fetch_nop, op_noni, store_nop ;05 ;
2620instr fetch_nop, op_noni, store_nop ;06 ;
2621instr fetch_nop, op_noni, store_nop ;07 ;
2622instr fetch_nop, op_noni, store_nop ;08 ;
2623instr fetch_BC, op_ADDxx, store_nop ;09 ;ADD xx,BC
2624instr fetch_nop, op_noni, store_nop ;0A ;
2625instr fetch_nop, op_noni, store_nop ;0B ;
2626instr fetch_nop, op_noni, store_nop ;0C ;
2627instr fetch_nop, op_noni, store_nop ;0D ;
2628instr fetch_nop, op_noni, store_nop ;0E ;
2629instr fetch_nop, op_noni, store_nop ;0F ;
2630instr fetch_nop, op_noni, store_nop ;10 ;
2631instr fetch_nop, op_noni, store_nop ;11 ;
2632instr fetch_nop, op_noni, store_nop ;12 ;
2633instr fetch_nop, op_noni, store_nop ;13 ;
2634instr fetch_nop, op_noni, store_nop ;14 ;
2635instr fetch_nop, op_noni, store_nop ;15 ;
2636instr fetch_nop, op_noni, store_nop ;16 ;
2637instr fetch_nop, op_noni, store_nop ;17 ;
2638instr fetch_nop, op_noni, store_nop ;18 ;
2639instr fetch_DE, op_ADDxx, store_nop ;19 ;ADD xx,DE
2640instr fetch_nop, op_noni, store_nop ;1A ;
2641instr fetch_nop, op_noni, store_nop ;1B ;
2642instr fetch_nop, op_noni, store_nop ;1C ;
2643instr fetch_nop, op_noni, store_nop ;1D ;
2644instr fetch_nop, op_noni, store_nop ;1E ;
2645instr fetch_nop, op_noni, store_nop ;1F ;
2646instr fetch_nop, op_noni, store_nop ;20 ;
2647instr fetch_DIR16, op_nop, store_xx ;21 ;LD xx,nn
2648instr fetch_DIR16, op_STxx, store_nop ;22 ;LD (nn),xx
2649instr fetch_xx, op_INC16, store_xx ;23 ;INC xx
2650instr fetch_xH, op_INC, store_xH ;24 ;INC xh
2651instr fetch_xH, op_DEC, store_xH ;25 ;DEC xh
2652instr fetch_DIR8, op_nop, store_xH ;26 ;LD xh,n
2653instr fetch_nop, op_noni, store_nop ;27 ;
2654instr fetch_nop, op_noni, store_nop ;28 ;
2655instr fetch_xx, op_ADDxx, store_nop ;29 ;ADD xx,xx
2656instr fetch_DIR16, op_RMEM16, store_xx ;2A ;LD xx,(nn)
2657instr fetch_xx, op_DEC16, store_xx ;2B ;DEC xx
2658instr fetch_xL, op_INC, store_xL ;2C ;INC xl
2659instr fetch_xL, op_DEC, store_xL ;2D ;DEC xl
2660instr fetch_DIR8, op_nop, store_xL ;2E ;LD xl,n
2661instr fetch_nop, op_noni, store_nop ;2F ;
2662instr fetch_nop, op_noni, store_nop ;30 ;
2663instr fetch_nop, op_noni, store_nop ;31 ;
2664instr fetch_nop, op_noni, store_nop ;32 ;
2665instr fetch_nop, op_noni, store_nop ;33 ;
2666instr fetch_MXX, op_INC, store_MXX_0 ;34 ;INC (xx+d)
2667instr fetch_MXX, op_DEC, store_MXX_0 ;35 ;DEC (xx+d)
2668instr fetch_DIR8_2, op_nop, store_MXX_2 ;36 ;LD (xx+d),n
2669instr fetch_nop, op_noni, store_nop ;37 ;
2670instr fetch_nop, op_noni, store_nop ;38 ;
2671instr fetch_SP, op_ADDxx, store_nop ;39 ;ADD xx,SP
2672instr fetch_nop, op_noni, store_nop ;3A ;
2673instr fetch_nop, op_noni, store_nop ;3B ;
2674instr fetch_nop, op_noni, store_nop ;3C ;
2675instr fetch_nop, op_noni, store_nop ;3D ;
2676instr fetch_nop, op_noni, store_nop ;3E ;
2677instr fetch_nop, op_noni, store_nop ;3F ;
2678instr fetch_nop, op_noni, store_nop ;40 ;
2679instr fetch_nop, op_noni, store_nop ;41 ;
2680instr fetch_nop, op_noni, store_nop ;42 ;
2681instr fetch_nop, op_noni, store_nop ;43 ;
2682instr fetch_xH, op_nop, store_B ;44 ;LD B,xh
2683instr fetch_xL, op_nop, store_B ;45 ;LD B,xl
2684instr fetch_MXX, op_nop, store_B ;46 ;LD B,(xx+d)
2685instr fetch_nop, op_noni, store_nop ;47 ;
2686instr fetch_nop, op_noni, store_nop ;48 ;
2687instr fetch_nop, op_noni, store_nop ;49 ;
2688instr fetch_nop, op_noni, store_nop ;4A ;
2689instr fetch_nop, op_noni, store_nop ;4B ;
2690instr fetch_xH, op_nop, store_C ;4C ;LD C,xh
2691instr fetch_xL, op_nop, store_C ;4D ;LD C,xl
2692instr fetch_MXX, op_nop, store_C ;4E ;LD C,(xx+d)
2693instr fetch_nop, op_noni, store_nop ;4F ;
2694instr fetch_nop, op_noni, store_nop ;50 ;
2695instr fetch_nop, op_noni, store_nop ;51 ;
2696instr fetch_nop, op_noni, store_nop ;52 ;
2697instr fetch_nop, op_noni, store_nop ;53 ;
2698instr fetch_xH, op_nop, store_D ;54 ;LD D,xh
2699instr fetch_xL, op_nop, store_D ;55 ;LD D,xl
2700instr fetch_MXX, op_nop, store_D ;56 ;LD D,(xx+d)
2701instr fetch_nop, op_noni, store_nop ;57 ;
2702instr fetch_nop, op_noni, store_nop ;58 ;
2703instr fetch_nop, op_noni, store_nop ;59 ;
2704instr fetch_nop, op_noni, store_nop ;5A ;
2705instr fetch_nop, op_noni, store_nop ;5B ;
2706instr fetch_xH, op_nop, store_E ;5C ;LD E,xh
2707instr fetch_xL, op_nop, store_E ;5D ;LD E,xl
2708instr fetch_MXX, op_nop, store_E ;5E ;LD E,(xx+d)
2709instr fetch_nop, op_noni, store_nop ;5F ;
2710instr fetch_B, op_nop, store_xH ;60 ;LD xh,B
2711instr fetch_C, op_nop, store_xH ;61 ;LD xh,C
2712instr fetch_D, op_nop, store_xH ;62 ;LD xh,D
2713instr fetch_E, op_nop, store_xH ;63 ;LD xh,E
2714instr fetch_nop, op_noni, store_nop ;64 ;LD xh,xh
2715instr fetch_xL, op_nop, store_xH ;65 ;LD xh,xl
2716instr fetch_MXX, op_nop, store_H ;66 ;LD H,(xx+d)
2717instr fetch_A, op_nop, store_xH ;67 ;LD xh,A
2718instr fetch_B, op_nop, store_xL ;68 ;LD xl,B
2719instr fetch_C, op_nop, store_xL ;69 ;LD xl,C
2720instr fetch_D, op_nop, store_xL ;6A ;LD xl,D
2721instr fetch_E, op_nop, store_xL ;6B ;LD xl,E
2722instr fetch_xH, op_nop, store_xL ;6C ;LD xl,xh
2723instr fetch_nop, op_noni, store_nop ;6D ;LD xl,xl
2724instr fetch_MXX, op_nop, store_L ;6E ;LD L,(xx+d)
2725instr fetch_A, op_nop, store_xL ;6F ;LD xl,A
2726instr fetch_B, op_nop, store_MXX ;70 ;LD (xx+d),B
2727instr fetch_C, op_nop, store_MXX ;71 ;LD (xx+d),C
2728instr fetch_D, op_nop, store_MXX ;72 ;LD (xx+d),D
2729instr fetch_E, op_nop, store_MXX ;73 ;LD (xx+d),E
2730instr fetch_H, op_nop, store_MXX ;74 ;LD (xx+d),H
2731instr fetch_L, op_nop, store_MXX ;75 ;LD (xx+d),L
2732instr fetch_nop, op_noni, store_nop ;76 ;
2733instr fetch_A, op_nop, store_MXX ;77 ;LD (xx+d),A
2734instr fetch_nop, op_noni, store_nop ;78 ;
2735instr fetch_nop, op_noni, store_nop ;79 ;
2736instr fetch_nop, op_noni, store_nop ;7A ;
2737instr fetch_nop, op_noni, store_nop ;7B ;
2738instr fetch_xH, op_nop, store_A ;7C ;LD A,xh
2739instr fetch_xL, op_nop, store_A ;7D ;LD A,xl
2740instr fetch_MXX, op_nop, store_A ;7E ;LD A,(xx+d)
2741instr fetch_nop, op_noni, store_nop ;7F ;
2742instr fetch_nop, op_noni, store_nop ;80 ;
2743instr fetch_nop, op_noni, store_nop ;81 ;
2744instr fetch_nop, op_noni, store_nop ;82 ;
2745instr fetch_nop, op_noni, store_nop ;83 ;
2746instr fetch_xH, op_ADDA, store_nop ;84 ;ADD A,xh
2747instr fetch_xL, op_ADDA, store_nop ;85 ;ADD A,xl
2748instr fetch_MXX, op_ADDA, store_nop ;86 ;ADD A,(xx)
2749instr fetch_nop, op_noni, store_nop ;87 ;
2750instr fetch_nop, op_noni, store_nop ;88 ;
2751instr fetch_nop, op_noni, store_nop ;89 ;
2752instr fetch_nop, op_noni, store_nop ;8A ;
2753instr fetch_nop, op_noni, store_nop ;8B ;
2754instr fetch_xH, op_ADCA, store_nop ;8C ;ADC A,xh
2755instr fetch_xL, op_ADCA, store_nop ;8D ;ADC A,xl
2756instr fetch_MXX, op_ADCA, store_nop ;8E ;ADC A,(xx)
2757instr fetch_nop, op_noni, store_nop ;8F ;
2758instr fetch_nop, op_noni, store_nop ;90 ;
2759instr fetch_nop, op_noni, store_nop ;91 ;
2760instr fetch_nop, op_noni, store_nop ;92 ;
2761instr fetch_nop, op_noni, store_nop ;93 ;
2762instr fetch_xH, op_SUBFA, store_nop ;94 ;SUB A,xh
2763instr fetch_xL, op_SUBFA, store_nop ;95 ;SUB A,xl
2764instr fetch_MXX, op_SUBFA, store_nop ;96 ;SUB A,(xx)
2765instr fetch_nop, op_noni, store_nop ;97 ;
2766instr fetch_nop, op_noni, store_nop ;98 ;
2767instr fetch_nop, op_noni, store_nop ;99 ;
2768instr fetch_nop, op_noni, store_nop ;9A ;
2769instr fetch_nop, op_noni, store_nop ;9B ;
2770instr fetch_xH, op_SBCFA, store_nop ;9C ;SBC A,xh
2771instr fetch_xL, op_SBCFA, store_nop ;9D ;SBC A,xl
2772instr fetch_MXX, op_SBCFA, store_nop ;9E ;SBC A,(xx)
2773instr fetch_nop, op_noni, store_nop ;9F ;
2774instr fetch_nop, op_noni, store_nop ;A0 ;
2775instr fetch_nop, op_noni, store_nop ;A1 ;
2776instr fetch_nop, op_noni, store_nop ;A2 ;
2777instr fetch_nop, op_noni, store_nop ;A3 ;
2778instr fetch_xH, op_ANDA, store_nop ;A4 ;AND A,xh
2779instr fetch_xL, op_ANDA, store_nop ;A5 ;AND A,xl
2780instr fetch_MXX, op_ANDA, store_nop ;A6 ;AND A,(xx)
2781instr fetch_nop, op_noni, store_nop ;A7 ;
2782instr fetch_nop, op_noni, store_nop ;A8 ;
2783instr fetch_nop, op_noni, store_nop ;A9 ;
2784instr fetch_nop, op_noni, store_nop ;AA ;
2785instr fetch_nop, op_noni, store_nop ;AB ;
2786instr fetch_xH, op_XORA, store_nop ;AC ;XOR A,xh
2787instr fetch_xL, op_XORA, store_nop ;AD ;XOR A,xl
2788instr fetch_MXX, op_XORA, store_nop ;AE ;XOR A,(xx)
2789instr fetch_nop, op_noni, store_nop ;AF ;
2790instr fetch_nop, op_noni, store_nop ;B0 ;
2791instr fetch_nop, op_noni, store_nop ;B1 ;
2792instr fetch_nop, op_noni, store_nop ;B2 ;
2793instr fetch_nop, op_noni, store_nop ;B3 ;
2794instr fetch_xH, op_ORA, store_nop ;B4 ;OR A,xh
2795instr fetch_xL, op_ORA, store_nop ;B5 ;OR A,xl
2796instr fetch_MXX, op_ORA, store_nop ;B6 ;OR A,(xx)
2797instr fetch_nop, op_noni, store_nop ;B7 ;
2798instr fetch_nop, op_noni, store_nop ;B8 ;
2799instr fetch_nop, op_noni, store_nop ;B9 ;
2800instr fetch_nop, op_noni, store_nop ;BA ;
2801instr fetch_nop, op_noni, store_nop ;BB ;
2802instr fetch_xH, op_CPFA, store_nop ;BC ;CP A,xh
2803instr fetch_xL, op_CPFA, store_nop ;BD ;CP A,xl
2804instr fetch_MXX, op_CPFA, store_nop ;BE ;CP A,(xx)
2805instr fetch_nop, op_noni, store_nop ;BF ;
2806instr fetch_nop, op_noni, store_nop ;C0 ;
2807instr fetch_nop, op_noni, store_nop ;C1 ;
2808instr fetch_nop, op_noni, store_nop ;C2 ;
2809instr fetch_nop, op_noni, store_nop ;C3 ;
2810instr fetch_nop, op_noni, store_nop ;C4 ;
2811instr fetch_nop, op_noni, store_nop ;C5 ;
2812instr fetch_nop, op_noni, store_nop ;C6 ;
2813instr fetch_nop, op_noni, store_nop ;C7 ;
2814instr fetch_nop, op_noni, store_nop ;C8 ;
2815instr fetch_nop, op_noni, store_nop ;C9 ;
2816instr fetch_nop, op_noni, store_nop ;CA ;
2817instr fetch_nop, op_prefixDDFDCB,store_nop ;CB ;
2818instr fetch_nop, op_noni, store_nop ;CC ;
2819instr fetch_nop, op_noni, store_nop ;CD ;
2820instr fetch_nop, op_noni, store_nop ;CE ;
2821instr fetch_nop, op_noni, store_nop ;CF ;
2822instr fetch_nop, op_noni, store_nop ;D0 ;
2823instr fetch_nop, op_noni, store_nop ;D1 ;
2824instr fetch_nop, op_noni, store_nop ;D2 ;
2825instr fetch_nop, op_noni, store_nop ;D3 ;
2826instr fetch_nop, op_noni, store_nop ;D4 ;
2827instr fetch_nop, op_noni, store_nop ;D5 ;
2828instr fetch_nop, op_noni, store_nop ;D6 ;
2829instr fetch_nop, op_noni, store_nop ;D7 ;
2830instr fetch_nop, op_noni, store_nop ;D8 ;
2831instr fetch_nop, op_noni, store_nop ;D9 ;
2832instr fetch_nop, op_noni, store_nop ;DA ;
2833instr fetch_nop, op_noni, store_nop ;DB ;
2834instr fetch_nop, op_noni, store_nop ;DC ;
2835instr fetch_nop, op_noni, store_nop ;DD ;
2836instr fetch_nop, op_noni, store_nop ;DE ;
2837instr fetch_nop, op_noni, store_nop ;DF ;
2838instr fetch_nop, op_noni, store_nop ;E0 ;
2839instr fetch_nop, op_POP16, store_xx ;E1 ;POP xx
2840instr fetch_nop, op_noni, store_nop ;E2 ;
2841instr fetch_MSP, op_EXxx, store_MSP ;E3 ;EX (SP),xx
2842instr fetch_nop, op_noni, store_nop ;E4 ;
2843instr fetch_xx, op_PUSH16, store_nop ;E5 ;PUSH xx
2844instr fetch_nop, op_noni, store_nop ;E6 ;
2845instr fetch_nop, op_noni, store_nop ;E7 ;
2846instr fetch_nop, op_noni, store_nop ;E8 ;
2847instr fetch_xx, op_nop, store_PC ;E9 ;JP xx
2848instr fetch_nop, op_noni, store_nop ;EA ;
2849instr fetch_nop, op_noni, store_nop ;EB ;
2850instr fetch_nop, op_noni, store_nop ;EC ;
2851instr fetch_nop, op_noni, store_nop ;ED ;
2852instr fetch_nop, op_noni, store_nop ;EE ;
2853instr fetch_nop, op_noni, store_nop ;EF ;
2854instr fetch_nop, op_noni, store_nop ;F0 ;
2855instr fetch_nop, op_noni, store_nop ;F1 ;
2856instr fetch_nop, op_noni, store_nop ;F2 ;
2857instr fetch_nop, op_noni, store_nop ;F3 ;
2858instr fetch_nop, op_noni, store_nop ;F4 ;
2859instr fetch_nop, op_noni, store_nop ;F5 ;
2860instr fetch_nop, op_noni, store_nop ;F6 ;
2861instr fetch_nop, op_noni, store_nop ;F7 ;
2862instr fetch_nop, op_noni, store_nop ;F8 ;
2863instr fetch_xx, op_nop, store_SP ;F9 ;LD SP,xx
2864instr fetch_nop, op_noni, store_nop ;FA ;
2865instr fetch_nop, op_noni, store_nop ;FB ;
2866instr fetch_nop, op_noni, store_nop ;FC ;
2867instr fetch_nop, op_noni, store_nop ;FD ;
2868instr fetch_nop, op_noni, store_nop ;FE ;
2869instr fetch_nop, op_noni, store_nop ;FF ;
2217c855 2870
2217c855 2871
e7a0f403
L
2872
2873;----------------------------------------------------------------
2874;|Mnemonic |SZHPNC|Description |Notes |
2875;----------------------------------------------------------------
623dd899
L
2876;|RLC m |**0P0*|Rotate Left Circular |m=m<- |
2877;|RRC m |**0P0*|Rotate Right Circular|m=->m |
2878;|RL m |**0P0*|Rotate Left |m={CY,m}<- |
2879;|RR m |**0P0*|Rotate Right |m=->{CY,m} |
2880;|SLA m |**0P0*|Shift Left Arithmetic|m=m*2 |
2881;|SRA m |**0P0*|Shift Right Arith. |m=m/2 |
2882;|SLL m |**0P0*|Shift Right Logical |
2883;|SRL m |**0P0*|Shift Right Logical |m=->{0,m,CY} |
e7a0f403 2884
2217c855 2885
623dd899 2886 checkspace PC, 9
2217c855 2887
623dd899
L
2888do_op_rlc:
2889 ;Rotate Left Cyclical. All bits move 1 to the
2890 ;left, the msb becomes c and lsb.
2891 clr temp
2892 lsl opl
2893 adc temp,_0
2894 or opl,temp
2895 ldpmx z_flags,sz53p_tab,opl ;S,Z,H,P,N
2896 or z_flags,temp
2217c855
L
2897 ret
2898
623dd899
L
2899 checkspace PC, 9
2900
2901do_op_rrc:
2902 ;Rotate Right Cyclical. All bits move 1 to the
2903 ;right, the lsb becomes c and msb.
2904 lsr opl
2905 brcc PC+2
2906 ori opl,0x80
2907 ldpmx z_flags,sz53p_tab,opl ;S,Z,H,P,N
2908 bmov z_flags,ZFL_C, opl,7
e7a0f403
L
2909 ret
2910
2217c855 2911
623dd899 2912 checkspace PC, 11
e7a0f403 2913
623dd899
L
2914do_op_rl:
2915 ;Rotate Left. All bits move 1 to the left, the msb
2916 ;becomes c, c becomes lsb.
2917 clc
2918 sbrc z_flags,ZFL_C
2919 sec
2920 rol opl
2921 in temp,sreg
2922 ldpmx z_flags,sz53p_tab,opl ;S,Z,H,P,N
2923 bmov z_flags,ZFL_C, temp,AVR_C
e7a0f403
L
2924 ret
2925
e7a0f403 2926
5c8bb361 2927 checkspace PC, 10
99034156 2928
623dd899
L
2929do_op_rr:
2930 ;Rotate Right. All bits move 1 to the right, the lsb
2931 ;becomes c, c becomes msb.
2932
2933 ror opl
2934 in temp,sreg ;CY
2935 bmov opl,7, z_flags,ZFL_C ;old CY --> Bit 7
2936 ldpmx z_flags,sz53p_tab,opl ;S,Z,H,P,N
2937 bmov z_flags,ZFL_C, temp,AVR_C ;
99034156
L
2938 ret
2939
5c8bb361 2940 checkspace PC, 9
623dd899
L
2941
2942do_op_sla:
2943 lsl opl
2944 in temp,sreg
2945 ldpmx z_flags,sz53p_tab,opl ;S,Z,H,P,N
2946 bmov z_flags,ZFL_C, temp,AVR_C ;
99034156
L
2947 ret
2948
5c8bb361 2949 checkspace PC, 11
623dd899
L
2950
2951do_op_sra:
2952 lsr opl
2953 in temp,sreg
2954 bmov opl,7, opl,6 ;old CY --> Bit 7
2955 ldpmx z_flags,sz53p_tab,opl ;S,Z,H,P,N
2956 bmov z_flags,ZFL_C, temp,AVR_C ;
99034156
L
2957 ret
2958
623dd899
L
2959 checkspace PC, 9
2960
2961do_op_sll:
2962 sec
2963 rol opl
2964 in temp,sreg
2965 ldpmx z_flags,sz53p_tab,opl ;S,Z,H,P,N
2966 bmov z_flags,ZFL_C, temp,AVR_C ;
99034156
L
2967 ret
2968
623dd899
L
2969 checkspace PC, 8
2970
2971do_op_srl:
2972 lsr opl
2973 in temp,sreg
2974 ldpmx z_flags,sz53p_tab,opl ;S,Z,H,P,N
2975 bmov z_flags,ZFL_C, temp,AVR_C ;
99034156
L
2976 ret
2977
2978;----------------------------------------------------------------
2979;|Mnemonic |SZHPNC|Description |Notes |
2980;----------------------------------------------------------------
623dd899
L
2981;|BIT b,m |?*1?0-|Test Bit |m&{2^b} |
2982;|RES b,m |------|Reset bit |m=m&{~2^b} |
2983;|SET b,m |------|Set bit |m=mv{2^b} |
99034156 2984
99034156 2985
5c8bb361 2986 checkspace PC, 2
623dd899
L
2987do_op_BIT7:
2988 ldi temp,0x80
2989 rjmp opbit
5c8bb361 2990 checkspace PC, 2
623dd899
L
2991do_op_BIT6:
2992 ldi temp,0x40
2993 rjmp opbit
5c8bb361 2994 checkspace PC, 2
623dd899
L
2995do_op_BIT5:
2996 ldi temp,0x20
2997 rjmp opbit
5c8bb361 2998 checkspace PC, 2
623dd899
L
2999do_op_BIT4:
3000 ldi temp,0x10
3001 rjmp opbit
5c8bb361 3002 checkspace PC, 2
623dd899
L
3003do_op_BIT3:
3004 ldi temp,0x08
3005 rjmp opbit
5c8bb361 3006 checkspace PC, 2
623dd899
L
3007do_op_BIT2:
3008 ldi temp,0x04
3009 rjmp opbit
5c8bb361 3010 checkspace PC, 2
623dd899
L
3011do_op_BIT1:
3012 ldi temp,0x02
3013 rjmp opbit
825ecc9d
L
3014
3015 checkspace PC, 7
623dd899
L
3016do_op_BIT0:
3017 ldi temp,0x01
3018opbit:
825ecc9d 3019 andi z_flags,~((1<<ZFL_N)|(1<<ZFL_Z))
623dd899 3020 ori z_flags,(1<<ZFL_H)
825ecc9d
L
3021 and temp,opl
3022 brne opbite
3023 ori z_flags,(1<<ZFL_Z)
3024opbite:
99034156
L
3025 ret
3026
99034156 3027
623dd899
L
3028.macro m_do_op_RES7
3029 andi opl,~0x80
3030.endm
3031.equ do_op_RES7 = 0
3032; andi opl,~0x80
3033; ret
99034156 3034
623dd899
L
3035.macro m_do_op_RES6
3036 andi opl,~0x40
3037.endm
3038.equ do_op_RES6 = 0
3039; andi opl,~0x40
3040; ret
3041
3042.macro m_do_op_RES5
3043 andi opl,~0x20
3044.endm
3045.equ do_op_RES5 = 0
3046; andi opl,~0x20
3047; ret
3048
3049.macro m_do_op_RES4
3050 andi opl,~0x10
3051.endm
3052.equ do_op_RES4 = 0
3053; andi opl,~0x10
3054; ret
3055
3056.macro m_do_op_RES3
3057 andi opl,~0x08
3058.endm
3059.equ do_op_RES3 = 0
3060; andi opl,~0x08
3061; ret
3062
3063.macro m_do_op_RES2
3064 andi opl,~0x04
3065.endm
3066.equ do_op_RES2 = 0
3067; andi opl,~0x04
3068; ret
3069
3070.macro m_do_op_RES1
3071 andi opl,~0x02
3072.endm
3073.equ do_op_RES1 = 0
3074; andi opl,~0x02
3075; ret
3076
3077.macro m_do_op_RES0
3078 andi opl,~0x01
3079.endm
3080.equ do_op_RES0 = 0
3081; andi opl,~0x01
3082; ret
3083
3084.macro m_do_op_SET7
3085 ori opl,0x80
3086.endm
3087.equ do_op_SET7 = 0
3088; ori opl,0x80
3089; ret
3090
3091.macro m_do_op_SET6
3092 ori opl,0x40
3093.endm
3094.equ do_op_SET6 = 0
3095; ori opl,0x40
3096; ret
3097
3098.macro m_do_op_SET5
3099 ori opl,0x20
3100.endm
3101.equ do_op_SET5 = 0
3102; ori opl,0x20
3103; ret
3104
3105.macro m_do_op_SET4
3106 ori opl,0x10
3107.endm
3108.equ do_op_SET4 = 0
3109; ori opl,0x10
3110; ret
3111
3112.macro m_do_op_SET3
3113 ori opl,0x08
3114.endm
3115.equ do_op_SET3 = 0
3116; ori opl,0x08
3117; ret
3118
3119.macro m_do_op_SET2
3120 ori opl,0x04
3121.endm
3122.equ do_op_SET2 = 0
3123; ori opl,0x04
3124; ret
3125
3126.macro m_do_op_SET1
3127 ori opl,0x02
3128.endm
3129.equ do_op_SET1 = 0
3130; ori opl,0x02
3131; ret
3132
3133.macro m_do_op_SET0
3134 ori opl,0x01
3135.endm
3136.equ do_op_SET0 = 0
3137; ori opl,0x01
3138; ret
3139
3140
3141;.macro m_do_store_b
3142; std y+oz_b,opl
3143;.endm
3144;.equ do_store_b = 0
5c8bb361 3145 checkspace PC, 2
623dd899 3146do_store2_b:
825ecc9d 3147 mov z_b,opl
99034156
L
3148 ret
3149
5c8bb361 3150 checkspace PC, 2
623dd899 3151do_store2_c:
825ecc9d 3152 mov z_c,opl
623dd899 3153 ret
e7a0f403 3154
5c8bb361 3155 checkspace PC, 2
623dd899 3156do_store2_d:
825ecc9d 3157 mov z_d,opl
623dd899 3158 ret
fa9059af 3159
5c8bb361 3160 checkspace PC, 2
623dd899 3161do_store2_e:
825ecc9d 3162 mov z_e,opl
623dd899 3163 ret
fa9059af 3164
5c8bb361 3165 checkspace PC, 2
623dd899 3166do_store2_h:
825ecc9d 3167 mov z_h,opl
623dd899 3168 ret
fa9059af 3169
5c8bb361 3170 checkspace PC, 2
623dd899 3171do_store2_l:
825ecc9d 3172 mov z_l,opl
623dd899 3173 ret
fa9059af 3174
5c8bb361 3175 checkspace PC, 2
623dd899
L
3176do_store2_a:
3177 mov z_a,opl
fb050095
L
3178 ret
3179
5c8bb361 3180 checkspace PC, 4
623dd899 3181do_fetch2_mhl:
bca3519f
L
3182; movw x,z_l
3183 mem_read_ds opl, z_hl
fb050095
L
3184 ret
3185
623dd899 3186 opctable CBjmp, PC ;+256
fa9059af 3187
fb050095
L
3188instr fetch_B, op_RLC, store2_B ;00 ;RLC B
3189instr fetch_C, op_RLC, store2_C ;01 ;RLC C
3190instr fetch_D, op_RLC, store2_D ;02 ;RLC D
3191instr fetch_E, op_RLC, store2_E ;03 ;RLC E
3192instr fetch_H, op_RLC, store2_H ;04 ;RLC H
3193instr fetch_L, op_RLC, store2_L ;05 ;RLC L
3194instr fetch2_mhl, op_RLC, store_MHL ;06 ;RLC (HL)
3195instr fetch_A, op_RLC, store2_A ;07 ;RLC A
3196instr fetch_B, op_RRC, store2_B ;08 ;RRC B
3197instr fetch_C, op_RRC, store2_C ;09 ;RRC C
3198instr fetch_D, op_RRC, store2_D ;0A ;RRC D
3199instr fetch_E, op_RRC, store2_E ;0B ;RRC E
3200instr fetch_H, op_RRC, store2_H ;0C ;RRC H
3201instr fetch_L, op_RRC, store2_L ;0D ;RRC L
3202instr fetch2_mhl, op_RRC, store_MHL ;0E ;RRC (HL)
3203instr fetch_A, op_RRC, store2_A ;0F ;RRC A
3204instr fetch_B, op_RL, store2_B ;10 ;RL B
3205instr fetch_C, op_RL, store2_C ;11 ;RL C
3206instr fetch_D, op_RL, store2_D ;12 ;RL D
3207instr fetch_E, op_RL, store2_E ;13 ;RL E
3208instr fetch_H, op_RL, store2_H ;14 ;RL H
3209instr fetch_L, op_RL, store2_L ;15 ;RL L
3210instr fetch2_mhl, op_RL, store_MHL ;16 ;RL (HL)
3211instr fetch_A, op_RL, store2_A ;17 ;RL A
3212instr fetch_B, op_RR, store2_B ;18 ;RR B
3213instr fetch_C, op_RR, store2_C ;19 ;RR C
3214instr fetch_D, op_RR, store2_D ;1A ;RR D
3215instr fetch_E, op_RR, store2_E ;1B ;RR E
3216instr fetch_H, op_RR, store2_H ;1C ;RR H
3217instr fetch_L, op_RR, store2_L ;1D ;RR L
3218instr fetch2_mhl, op_RR, store_MHL ;1E ;RR (HL)
3219instr fetch_A, op_RR, store2_A ;1F ;RR A
3220instr fetch_B, op_SLA, store2_B ;20 ;SLA B
3221instr fetch_C, op_SLA, store2_C ;21 ;SLA C
3222instr fetch_D, op_SLA, store2_D ;22 ;SLA D
3223instr fetch_E, op_SLA, store2_E ;23 ;SLA E
3224instr fetch_H, op_SLA, store2_H ;24 ;SLA H
3225instr fetch_L, op_SLA, store2_L ;25 ;SLA L
3226instr fetch2_mhl, op_SLA, store_MHL ;26 ;SLA (HL)
3227instr fetch_A, op_SLA, store2_A ;27 ;SLA A
3228instr fetch_B, op_SRA, store2_B ;28 ;SRA B
3229instr fetch_C, op_SRA, store2_C ;29 ;SRA C
3230instr fetch_D, op_SRA, store2_D ;2A ;SRA D
3231instr fetch_E, op_SRA, store2_E ;2B ;SRA E
3232instr fetch_H, op_SRA, store2_H ;2C ;SRA H
3233instr fetch_L, op_SRA, store2_L ;2D ;SRA L
3234instr fetch2_mhl, op_SRA, store_MHL ;2E ;SRA (HL)
3235instr fetch_A, op_SRA, store2_A ;2F ;SRA A
3236instr fetch_B, op_SLL, store2_B ;30 ;SLL B
3237instr fetch_C, op_SLL, store2_C ;31 ;SLL C
3238instr fetch_D, op_SLL, store2_D ;32 ;SLL D
3239instr fetch_E, op_SLL, store2_E ;33 ;SLL E
3240instr fetch_H, op_SLL, store2_H ;34 ;SLL H
3241instr fetch_L, op_SLL, store2_L ;35 ;SLL L
3242instr fetch2_mhl, op_SLL, store_MHL ;36 ;SLL (HL)
3243instr fetch_A, op_SLL, store2_A ;37 ;SLL A
3244instr fetch_B, op_SRL, store2_B ;38 ;SRL B
3245instr fetch_C, op_SRL, store2_C ;39 ;SRL C
3246instr fetch_D, op_SRL, store2_D ;3A ;SRL D
3247instr fetch_E, op_SRL, store2_E ;3B ;SRL E
3248instr fetch_H, op_SRL, store2_H ;3C ;SRL H
3249instr fetch_L, op_SRL, store2_L ;3D ;SRL L
3250instr fetch2_mhl, op_SRL, store_MHL ;3E ;SRL (HL)
3251instr fetch_A, op_SRL, store2_A ;3F ;SRL A
4c92af0d
L
3252instr fetch_B, op_BIT0, store_nop ;40 ;BIT 0,B
3253instr fetch_C, op_BIT0, store_nop ;41 ;BIT 0,C
3254instr fetch_D, op_BIT0, store_nop ;42 ;BIT 0,D
3255instr fetch_E, op_BIT0, store_nop ;43 ;BIT 0,E
3256instr fetch_H, op_BIT0, store_nop ;44 ;BIT 0,H
3257instr fetch_L, op_BIT0, store_nop ;45 ;BIT 0,L
fb050095 3258instr fetch2_mhl, op_BIT0, store_nop ;46 ;BIT 0,(HL)
4c92af0d
L
3259instr fetch_A, op_BIT0, store_nop ;47 ;BIT 0,A
3260instr fetch_B, op_BIT1, store_nop ;48 ;BIT 1,B
3261instr fetch_C, op_BIT1, store_nop ;49 ;BIT 1,C
3262instr fetch_D, op_BIT1, store_nop ;4A ;BIT 1,D
3263instr fetch_E, op_BIT1, store_nop ;4B ;BIT 1,E
3264instr fetch_H, op_BIT1, store_nop ;4C ;BIT 1,H
3265instr fetch_L, op_BIT1, store_nop ;4D ;BIT 1,L
fb050095 3266instr fetch2_mhl, op_BIT1, store_nop ;4E ;BIT 1,(HL)
4c92af0d
L
3267instr fetch_A, op_BIT1, store_nop ;4F ;BIT 1,A
3268instr fetch_B, op_BIT2, store_nop ;50 ;BIT 2,B
3269instr fetch_C, op_BIT2, store_nop ;51 ;BIT 2,C
3270instr fetch_D, op_BIT2, store_nop ;52 ;BIT 2,D
3271instr fetch_E, op_BIT2, store_nop ;53 ;BIT 2,E
3272instr fetch_H, op_BIT2, store_nop ;54 ;BIT 2,H
3273instr fetch_L, op_BIT2, store_nop ;55 ;BIT 2,L
fb050095 3274instr fetch2_mhl, op_BIT2, store_nop ;56 ;BIT 2,(HL)
4c92af0d
L
3275instr fetch_A, op_BIT2, store_nop ;57 ;BIT 2,A
3276instr fetch_B, op_BIT3, store_nop ;58 ;BIT 3,B
3277instr fetch_C, op_BIT3, store_nop ;59 ;BIT 3,C
3278instr fetch_D, op_BIT3, store_nop ;5A ;BIT 3,D
3279instr fetch_E, op_BIT3, store_nop ;5B ;BIT 3,E
3280instr fetch_H, op_BIT3, store_nop ;5C ;BIT 3,H
3281instr fetch_L, op_BIT3, store_nop ;5D ;BIT 3,L
fb050095 3282instr fetch2_mhl, op_BIT3, store_nop ;5E ;BIT 3,(HL)
4c92af0d
L
3283instr fetch_A, op_BIT3, store_nop ;5F ;BIT 3,A
3284instr fetch_B, op_BIT4, store_nop ;60 ;BIT 4,B
3285instr fetch_C, op_BIT4, store_nop ;61 ;BIT 4,C
3286instr fetch_D, op_BIT4, store_nop ;62 ;BIT 4,D
3287instr fetch_E, op_BIT4, store_nop ;63 ;BIT 4,E
3288instr fetch_H, op_BIT4, store_nop ;64 ;BIT 4,H
3289instr fetch_L, op_BIT4, store_nop ;65 ;BIT 4,L
fb050095 3290instr fetch2_mhl, op_BIT4, store_nop ;66 ;BIT 4,(HL)
4c92af0d
L
3291instr fetch_A, op_BIT4, store_nop ;67 ;BIT 4,A
3292instr fetch_B, op_BIT5, store_nop ;68 ;BIT 5,B
3293instr fetch_C, op_BIT5, store_nop ;69 ;BIT 5,C
3294instr fetch_D, op_BIT5, store_nop ;6A ;BIT 5,D
3295instr fetch_E, op_BIT5, store_nop ;6B ;BIT 5,E
3296instr fetch_H, op_BIT5, store_nop ;6C ;BIT 5,H
3297instr fetch_L, op_BIT5, store_nop ;6D ;BIT 5,L
fb050095 3298instr fetch2_mhl, op_BIT5, store_nop ;6E ;BIT 5,(HL)
4c92af0d
L
3299instr fetch_A, op_BIT5, store_nop ;6F ;BIT 5,A
3300instr fetch_B, op_BIT6, store_nop ;70 ;BIT 6,B
3301instr fetch_C, op_BIT6, store_nop ;71 ;BIT 6,C
3302instr fetch_D, op_BIT6, store_nop ;72 ;BIT 6,D
3303instr fetch_E, op_BIT6, store_nop ;73 ;BIT 6,E
3304instr fetch_H, op_BIT6, store_nop ;74 ;BIT 6,H
3305instr fetch_L, op_BIT6, store_nop ;75 ;BIT 6,L
fb050095 3306instr fetch2_mhl, op_BIT6, store_nop ;76 ;BIT 6,(HL)
4c92af0d
L
3307instr fetch_A, op_BIT6, store_nop ;77 ;BIT 6,A
3308instr fetch_B, op_BIT7, store_nop ;78 ;BIT 7,B
3309instr fetch_C, op_BIT7, store_nop ;79 ;BIT 7,C
3310instr fetch_D, op_BIT7, store_nop ;7A ;BIT 7,D
3311instr fetch_E, op_BIT7, store_nop ;7B ;BIT 7,E
3312instr fetch_H, op_BIT7, store_nop ;7C ;BIT 7,H
3313instr fetch_L, op_BIT7, store_nop ;7D ;BIT 7,L
fb050095 3314instr fetch2_mhl, op_BIT7, store_nop ;7E ;BIT 7,(HL)
4c92af0d 3315instr fetch_A, op_BIT7, store_nop ;7F ;BIT 7,A
fb050095
L
3316instr fetch_B, op_RES0, store2_B ;80 ;RES 0,B
3317instr fetch_C, op_RES0, store2_C ;81 ;RES 0,C
3318instr fetch_D, op_RES0, store2_D ;82 ;RES 0,D
3319instr fetch_E, op_RES0, store2_E ;83 ;RES 0,E
3320instr fetch_H, op_RES0, store2_H ;84 ;RES 0,H
3321instr fetch_L, op_RES0, store2_L ;85 ;RES 0,L
3322instr fetch2_mhl, op_RES0, store_MHL ;86 ;RES 0,(HL)
3323instr fetch_A, op_RES0, store2_A ;87 ;RES 0,A
3324instr fetch_B, op_RES1, store2_B ;88 ;RES 1,B
3325instr fetch_C, op_RES1, store2_C ;89 ;RES 1,C
3326instr fetch_D, op_RES1, store2_D ;8A ;RES 1,D
3327instr fetch_E, op_RES1, store2_E ;8B ;RES 1,E
3328instr fetch_H, op_RES1, store2_H ;8C ;RES 1,H
3329instr fetch_L, op_RES1, store2_L ;8D ;RES 1,L
3330instr fetch2_mhl, op_RES1, store_MHL ;8E ;RES 1,(HL)
3331instr fetch_A, op_RES1, store2_A ;8F ;RES 1,A
3332instr fetch_B, op_RES2, store2_B ;90 ;RES 2,B
3333instr fetch_C, op_RES2, store2_C ;91 ;RES 2,C
3334instr fetch_D, op_RES2, store2_D ;92 ;RES 2,D
3335instr fetch_E, op_RES2, store2_E ;93 ;RES 2,E
3336instr fetch_H, op_RES2, store2_H ;94 ;RES 2,H
3337instr fetch_L, op_RES2, store2_L ;95 ;RES 2,L
3338instr fetch2_mhl, op_RES2, store_MHL ;96 ;RES 2,(HL)
3339instr fetch_A, op_RES2, store2_A ;97 ;RES 2,A
3340instr fetch_B, op_RES3, store2_B ;98 ;RES 3,B
3341instr fetch_C, op_RES3, store2_C ;99 ;RES 3,C
3342instr fetch_D, op_RES3, store2_D ;9A ;RES 3,D
3343instr fetch_E, op_RES3, store2_E ;9B ;RES 3,E
3344instr fetch_H, op_RES3, store2_H ;9C ;RES 3,H
3345instr fetch_L, op_RES3, store2_L ;9D ;RES 3,L
3346instr fetch2_mhl, op_RES3, store_MHL ;9E ;RES 3,(HL)
3347instr fetch_A, op_RES3, store2_A ;9F ;RES 3,A
3348instr fetch_B, op_RES4, store2_B ;A0 ;RES 4,B
3349instr fetch_C, op_RES4, store2_C ;A1 ;RES 4,C
3350instr fetch_D, op_RES4, store2_D ;A2 ;RES 4,D
3351instr fetch_E, op_RES4, store2_E ;A3 ;RES 4,E
3352instr fetch_H, op_RES4, store2_H ;A4 ;RES 4,H
3353instr fetch_L, op_RES4, store2_L ;A5 ;RES 4,L
3354instr fetch2_mhl, op_RES4, store_MHL ;A6 ;RES 4,(HL)
3355instr fetch_A, op_RES4, store2_A ;A7 ;RES 4,A
3356instr fetch_B, op_RES5, store2_B ;A8 ;RES 5,B
3357instr fetch_C, op_RES5, store2_C ;A9 ;RES 5,C
3358instr fetch_D, op_RES5, store2_D ;AA ;RES 5,D
3359instr fetch_E, op_RES5, store2_E ;AB ;RES 5,E
3360instr fetch_H, op_RES5, store2_H ;AC ;RES 5,H
3361instr fetch_L, op_RES5, store2_L ;AD ;RES 5,L
3362instr fetch2_mhl, op_RES5, store_MHL ;AE ;RES 5,(HL)
3363instr fetch_A, op_RES5, store2_A ;AF ;RES 5,A
3364instr fetch_B, op_RES6, store2_B ;B0 ;RES 6,B
3365instr fetch_C, op_RES6, store2_C ;B1 ;RES 6,C
3366instr fetch_D, op_RES6, store2_D ;B2 ;RES 6,D
3367instr fetch_E, op_RES6, store2_E ;B3 ;RES 6,E
3368instr fetch_H, op_RES6, store2_H ;B4 ;RES 6,H
3369instr fetch_L, op_RES6, store2_L ;B5 ;RES 6,L
3370instr fetch2_mhl, op_RES6, store_MHL ;B6 ;RES 6,(HL)
3371instr fetch_A, op_RES6, store2_A ;B7 ;RES 6,A
3372instr fetch_B, op_RES7, store2_B ;B8 ;RES 7,B
3373instr fetch_C, op_RES7, store2_C ;B9 ;RES 7,C
3374instr fetch_D, op_RES7, store2_D ;BA ;RES 7,D
3375instr fetch_E, op_RES7, store2_E ;BB ;RES 7,E
3376instr fetch_H, op_RES7, store2_H ;BC ;RES 7,H
3377instr fetch_L, op_RES7, store2_L ;BD ;RES 7,L
3378instr fetch2_mhl, op_RES7, store_MHL ;BE ;RES 7,(HL)
3379instr fetch_A, op_RES7, store2_A ;BF ;RES 7,A
3380instr fetch_B, op_SET0, store2_B ;C0 ;SET 0,B
3381instr fetch_C, op_SET0, store2_C ;C1 ;SET 0,C
3382instr fetch_D, op_SET0, store2_D ;C2 ;SET 0,D
3383instr fetch_E, op_SET0, store2_E ;C3 ;SET 0,E
3384instr fetch_H, op_SET0, store2_H ;C4 ;SET 0,H
3385instr fetch_L, op_SET0, store2_L ;C5 ;SET 0,L
3386instr fetch2_mhl, op_SET0, store_MHL ;C6 ;SET 0,(HL)
3387instr fetch_A, op_SET0, store2_A ;C7 ;SET 0,A
3388instr fetch_B, op_SET1, store2_B ;C8 ;SET 1,B
3389instr fetch_C, op_SET1, store2_C ;C9 ;SET 1,C
3390instr fetch_D, op_SET1, store2_D ;CA ;SET 1,D
3391instr fetch_E, op_SET1, store2_E ;CB ;SET 1,E
3392instr fetch_H, op_SET1, store2_H ;CC ;SET 1,H
3393instr fetch_L, op_SET1, store2_L ;CD ;SET 1,L
3394instr fetch2_mhl, op_SET1, store_MHL ;CE ;SET 1,(HL)
3395instr fetch_A, op_SET1, store2_A ;CF ;SET 1,A
3396instr fetch_B, op_SET2, store2_B ;D0 ;SET 2,B
3397instr fetch_C, op_SET2, store2_C ;D1 ;SET 2,C
3398instr fetch_D, op_SET2, store2_D ;D2 ;SET 2,D
3399instr fetch_E, op_SET2, store2_E ;D3 ;SET 2,E
3400instr fetch_H, op_SET2, store2_H ;D4 ;SET 2,H
3401instr fetch_L, op_SET2, store2_L ;D5 ;SET 2,L
3402instr fetch2_mhl, op_SET2, store_MHL ;D6 ;SET 2,(HL)
3403instr fetch_A, op_SET2, store2_A ;D7 ;SET 2,A
3404instr fetch_B, op_SET3, store2_B ;D8 ;SET 3,B
3405instr fetch_C, op_SET3, store2_C ;D9 ;SET 3,C
3406instr fetch_D, op_SET3, store2_D ;DA ;SET 3,D
3407instr fetch_E, op_SET3, store2_E ;DB ;SET 3,E
3408instr fetch_H, op_SET3, store2_H ;DC ;SET 3,H
3409instr fetch_L, op_SET3, store2_L ;DD ;SET 3,L
3410instr fetch2_mhl, op_SET3, store_MHL ;DE ;SET 3,(HL)
3411instr fetch_A, op_SET3, store2_A ;DF ;SET 3,A
3412instr fetch_B, op_SET4, store2_B ;E0 ;SET 4,B
3413instr fetch_C, op_SET4, store2_C ;E1 ;SET 4,C
3414instr fetch_D, op_SET4, store2_D ;E2 ;SET 4,D
3415instr fetch_E, op_SET4, store2_E ;E3 ;SET 4,E
3416instr fetch_H, op_SET4, store2_H ;E4 ;SET 4,H
3417instr fetch_L, op_SET4, store2_L ;E5 ;SET 4,L
3418instr fetch2_mhl, op_SET4, store_MHL ;E6 ;SET 4,(HL)
3419instr fetch_A, op_SET4, store2_A ;E7 ;SET 4,A
3420instr fetch_B, op_SET5, store2_B ;E8 ;SET 5,B
3421instr fetch_C, op_SET5, store2_C ;E9 ;SET 5,C
3422instr fetch_D, op_SET5, store2_D ;EA ;SET 5,D
3423instr fetch_E, op_SET5, store2_E ;EB ;SET 5,E
3424instr fetch_H, op_SET5, store2_H ;EC ;SET 5,H
3425instr fetch_L, op_SET5, store2_L ;ED ;SET 5,L
3426instr fetch2_mhl, op_SET5, store_MHL ;EE ;SET 5,(HL)
3427instr fetch_A, op_SET5, store2_A ;EF ;SET 5,A
3428instr fetch_B, op_SET6, store2_B ;F0 ;SET 6,B
3429instr fetch_C, op_SET6, store2_C ;F1 ;SET 6,C
3430instr fetch_D, op_SET6, store2_D ;F2 ;SET 6,D
3431instr fetch_E, op_SET6, store2_E ;F3 ;SET 6,E
3432instr fetch_H, op_SET6, store2_H ;F4 ;SET 6,H
3433instr fetch_L, op_SET6, store2_L ;F5 ;SET 6,L
3434instr fetch2_mhl, op_SET6, store_MHL ;F6 ;SET 6,(HL)
3435instr fetch_A, op_SET6, store2_A ;F7 ;SET 6,A
3436instr fetch_B, op_SET7, store2_B ;F8 ;SET 7,B
3437instr fetch_C, op_SET7, store2_C ;F9 ;SET 7,C
3438instr fetch_D, op_SET7, store2_D ;FA ;SET 7,D
3439instr fetch_E, op_SET7, store2_E ;FB ;SET 7,E
3440instr fetch_H, op_SET7, store2_H ;FC ;SET 7,H
3441instr fetch_L, op_SET7, store2_L ;FD ;SET 7,L
3442instr fetch2_mhl, op_SET7, store_MHL ;FE ;SET 7,(HL)
3443instr fetch_A, op_SET7, store2_A ;FF ;SET 7,A
fa9059af
L
3444
3445
623dd899 3446 opctable DDFDCBjmp, PC ;+256
fa9059af 3447
fb050095
L
3448instr fetch_nop, op_RLC, store2_B ;00 ;RLC (Ix+d),B
3449instr fetch_nop, op_RLC, store2_C ;01 ;RLC (Ix+d),C
3450instr fetch_nop, op_RLC, store2_D ;02 ;RLC (Ix+d),D
3451instr fetch_nop, op_RLC, store2_E ;03 ;RLC (Ix+d),E
3452instr fetch_nop, op_RLC, store2_H ;04 ;RLC (Ix+d),H
3453instr fetch_nop, op_RLC, store2_L ;05 ;RLC (Ix+d),L
096f3a91 3454instr fetch_nop, op_RLC, store_nop ;06 ;RLC (Ix+d)
fb050095
L
3455instr fetch_nop, op_RLC, store2_A ;07 ;RLC (Ix+d),A
3456instr fetch_nop, op_RRC, store2_B ;08 ;RRC (Ix+d),B
3457instr fetch_nop, op_RRC, store2_C ;09 ;RRC (Ix+d),C
3458instr fetch_nop, op_RRC, store2_D ;0A ;RRC (Ix+d),D
3459instr fetch_nop, op_RRC, store2_E ;0B ;RRC (Ix+d),E
3460instr fetch_nop, op_RRC, store2_H ;0C ;RRC (Ix+d),H
3461instr fetch_nop, op_RRC, store2_L ;0D ;RRC (Ix+d),L
096f3a91 3462instr fetch_nop, op_RRC, store_nop ;0E ;RRC (Ix+d)
fb050095
L
3463instr fetch_nop, op_RRC, store2_A ;0F ;RRC (Ix+d),A
3464instr fetch_nop, op_RL, store2_B ;10 ;RL (Ix+d),B
3465instr fetch_nop, op_RL, store2_C ;11 ;RL (Ix+d),C
3466instr fetch_nop, op_RL, store2_D ;12 ;RL (Ix+d),D
3467instr fetch_nop, op_RL, store2_E ;13 ;RL (Ix+d),E
3468instr fetch_nop, op_RL, store2_H ;14 ;RL (Ix+d),H
3469instr fetch_nop, op_RL, store2_L ;15 ;RL (Ix+d),L
096f3a91 3470instr fetch_nop, op_RL, store_nop ;16 ;RL (Ix+d)
fb050095
L
3471instr fetch_nop, op_RL, store2_A ;17 ;RL (Ix+d),A
3472instr fetch_nop, op_RR, store2_B ;18 ;RR (Ix+d),B
3473instr fetch_nop, op_RR, store2_C ;19 ;RR (Ix+d),C
3474instr fetch_nop, op_RR, store2_D ;1A ;RR (Ix+d),D
3475instr fetch_nop, op_RR, store2_E ;1B ;RR (Ix+d),E
3476instr fetch_nop, op_RR, store2_H ;1C ;RR (Ix+d),H
3477instr fetch_nop, op_RR, store2_L ;1D ;RR (Ix+d),L
096f3a91 3478instr fetch_nop, op_RR, store_nop ;1E ;RR (Ix+d)
fb050095
L
3479instr fetch_nop, op_RR, store2_A ;1F ;RR (Ix+d),A
3480instr fetch_nop, op_SLA, store2_B ;20 ;SLA (Ix+d),B
3481instr fetch_nop, op_SLA, store2_C ;21 ;SLA (Ix+d),C
3482instr fetch_nop, op_SLA, store2_D ;22 ;SLA (Ix+d),D
3483instr fetch_nop, op_SLA, store2_E ;23 ;SLA (Ix+d),E
3484instr fetch_nop, op_SLA, store2_H ;24 ;SLA (Ix+d),H
3485instr fetch_nop, op_SLA, store2_L ;25 ;SLA (Ix+d),L
096f3a91 3486instr fetch_nop, op_SLA, store_nop ;26 ;SLA (Ix+d)
fb050095
L
3487instr fetch_nop, op_SLA, store2_A ;27 ;SLA (Ix+d),A
3488instr fetch_nop, op_SRA, store2_B ;28 ;SRA (Ix+d),B
3489instr fetch_nop, op_SRA, store2_C ;29 ;SRA (Ix+d),C
3490instr fetch_nop, op_SRA, store2_D ;2A ;SRA (Ix+d),D
3491instr fetch_nop, op_SRA, store2_E ;2B ;SRA (Ix+d),E
3492instr fetch_nop, op_SRA, store2_H ;2C ;SRA (Ix+d),H
3493instr fetch_nop, op_SRA, store2_L ;2D ;SRA (Ix+d),L
096f3a91 3494instr fetch_nop, op_SRA, store_nop ;2E ;SRA (Ix+d)
fb050095
L
3495instr fetch_nop, op_SRA, store2_A ;2F ;SRA (Ix+d),A
3496instr fetch_nop, op_SLL, store2_B ;30 ;SLL (Ix+d),B
3497instr fetch_nop, op_SLL, store2_C ;31 ;SLL (Ix+d),C
3498instr fetch_nop, op_SLL, store2_D ;32 ;SLL (Ix+d),D
3499instr fetch_nop, op_SLL, store2_E ;33 ;SLL (Ix+d),E
3500instr fetch_nop, op_SLL, store2_H ;34 ;SLL (Ix+d),H
3501instr fetch_nop, op_SLL, store2_L ;35 ;SLL (Ix+d),L
096f3a91 3502instr fetch_nop, op_SLL, store_nop ;36 ;SLL (Ix+d)
fb050095
L
3503instr fetch_nop, op_SLL, store2_A ;37 ;SLL (Ix+d),A
3504instr fetch_nop, op_SRL, store2_B ;38 ;SRL (Ix+d),B
3505instr fetch_nop, op_SRL, store2_C ;39 ;SRL (Ix+d),C
3506instr fetch_nop, op_SRL, store2_D ;3A ;SRL (Ix+d),D
3507instr fetch_nop, op_SRL, store2_E ;3B ;SRL (Ix+d),E
3508instr fetch_nop, op_SRL, store2_H ;3C ;SRL (Ix+d),H
3509instr fetch_nop, op_SRL, store2_L ;3D ;SRL (Ix+d),L
096f3a91 3510instr fetch_nop, op_SRL, store_nop ;3E ;SRL (Ix+d)
fb050095 3511instr fetch_nop, op_SRL, store2_A ;3F ;SRL (Ix+d),A
e7a0f403
L
3512instr fetch_nop, op_BIT0, store_nop ;40 ;BIT 0,(Ix+d),B
3513instr fetch_nop, op_BIT0, store_nop ;41 ;BIT 0,(Ix+d),C
3514instr fetch_nop, op_BIT0, store_nop ;42 ;BIT 0,(Ix+d),D
3515instr fetch_nop, op_BIT0, store_nop ;43 ;BIT 0,(Ix+d),E
3516instr fetch_nop, op_BIT0, store_nop ;44 ;BIT 0,(Ix+d),H
3517instr fetch_nop, op_BIT0, store_nop ;45 ;BIT 0,(Ix+d),L
3518instr fetch_nop, op_BIT0, store_nop ;46 ;BIT 0,(Ix+d)
3519instr fetch_nop, op_BIT0, store_nop ;47 ;BIT 0,(Ix+d),A
3520instr fetch_nop, op_BIT1, store_nop ;48 ;BIT 1,(Ix+d),B
3521instr fetch_nop, op_BIT1, store_nop ;49 ;BIT 1,(Ix+d),C
3522instr fetch_nop, op_BIT1, store_nop ;4A ;BIT 1,(Ix+d),D
3523instr fetch_nop, op_BIT1, store_nop ;4B ;BIT 1,(Ix+d),E
3524instr fetch_nop, op_BIT1, store_nop ;4C ;BIT 1,(Ix+d),H
3525instr fetch_nop, op_BIT1, store_nop ;4D ;BIT 1,(Ix+d),L
3526instr fetch_nop, op_BIT1, store_nop ;4E ;BIT 1,(Ix+d)
3527instr fetch_nop, op_BIT1, store_nop ;4F ;BIT 1,(Ix+d),A
3528instr fetch_nop, op_BIT2, store_nop ;50 ;BIT 2,(Ix+d),B
3529instr fetch_nop, op_BIT2, store_nop ;51 ;BIT 2,(Ix+d),C
3530instr fetch_nop, op_BIT2, store_nop ;52 ;BIT 2,(Ix+d),D
3531instr fetch_nop, op_BIT2, store_nop ;53 ;BIT 2,(Ix+d),E
3532instr fetch_nop, op_BIT2, store_nop ;54 ;BIT 2,(Ix+d),H
3533instr fetch_nop, op_BIT2, store_nop ;55 ;BIT 2,(Ix+d),L
3534instr fetch_nop, op_BIT2, store_nop ;56 ;BIT 2,(Ix+d)
3535instr fetch_nop, op_BIT2, store_nop ;57 ;BIT 2,(Ix+d),A
3536instr fetch_nop, op_BIT3, store_nop ;58 ;BIT 3,(Ix+d),B
3537instr fetch_nop, op_BIT3, store_nop ;59 ;BIT 3,(Ix+d),C
3538instr fetch_nop, op_BIT3, store_nop ;5A ;BIT 3,(Ix+d),D
3539instr fetch_nop, op_BIT3, store_nop ;5B ;BIT 3,(Ix+d),E
3540instr fetch_nop, op_BIT3, store_nop ;5C ;BIT 3,(Ix+d),H
3541instr fetch_nop, op_BIT3, store_nop ;5D ;BIT 3,(Ix+d),L
3542instr fetch_nop, op_BIT3, store_nop ;5E ;BIT 3,(Ix+d)
3543instr fetch_nop, op_BIT3, store_nop ;5F ;BIT 3,(Ix+d),A
3544instr fetch_nop, op_BIT4, store_nop ;60 ;BIT 4,(Ix+d),B
3545instr fetch_nop, op_BIT4, store_nop ;61 ;BIT 4,(Ix+d),C
3546instr fetch_nop, op_BIT4, store_nop ;62 ;BIT 4,(Ix+d),D
3547instr fetch_nop, op_BIT4, store_nop ;63 ;BIT 4,(Ix+d),E
3548instr fetch_nop, op_BIT4, store_nop ;64 ;BIT 4,(Ix+d),H
3549instr fetch_nop, op_BIT4, store_nop ;65 ;BIT 4,(Ix+d),L
3550instr fetch_nop, op_BIT4, store_nop ;66 ;BIT 4,(Ix+d)
3551instr fetch_nop, op_BIT4, store_nop ;67 ;BIT 4,(Ix+d),A
3552instr fetch_nop, op_BIT5, store_nop ;68 ;BIT 5,(Ix+d),B
3553instr fetch_nop, op_BIT5, store_nop ;69 ;BIT 5,(Ix+d),C
3554instr fetch_nop, op_BIT5, store_nop ;6A ;BIT 5,(Ix+d),D
3555instr fetch_nop, op_BIT5, store_nop ;6B ;BIT 5,(Ix+d),E
3556instr fetch_nop, op_BIT5, store_nop ;6C ;BIT 5,(Ix+d),H
3557instr fetch_nop, op_BIT5, store_nop ;6D ;BIT 5,(Ix+d),L
3558instr fetch_nop, op_BIT5, store_nop ;6E ;BIT 5,(Ix+d)
3559instr fetch_nop, op_BIT5, store_nop ;6F ;BIT 5,(Ix+d),A
3560instr fetch_nop, op_BIT6, store_nop ;70 ;BIT 6,(Ix+d),B
3561instr fetch_nop, op_BIT6, store_nop ;71 ;BIT 6,(Ix+d),C
3562instr fetch_nop, op_BIT6, store_nop ;72 ;BIT 6,(Ix+d),D
3563instr fetch_nop, op_BIT6, store_nop ;73 ;BIT 6,(Ix+d),E
3564instr fetch_nop, op_BIT6, store_nop ;74 ;BIT 6,(Ix+d),H
3565instr fetch_nop, op_BIT6, store_nop ;75 ;BIT 6,(Ix+d),L
3566instr fetch_nop, op_BIT6, store_nop ;76 ;BIT 6,(Ix+d)
3567instr fetch_nop, op_BIT6, store_nop ;77 ;BIT 6,(Ix+d),A
3568instr fetch_nop, op_BIT7, store_nop ;78 ;BIT 7,(Ix+d),B
3569instr fetch_nop, op_BIT7, store_nop ;79 ;BIT 7,(Ix+d),C
3570instr fetch_nop, op_BIT7, store_nop ;7A ;BIT 7,(Ix+d),D
3571instr fetch_nop, op_BIT7, store_nop ;7B ;BIT 7,(Ix+d),E
3572instr fetch_nop, op_BIT7, store_nop ;7C ;BIT 7,(Ix+d),H
3573instr fetch_nop, op_BIT7, store_nop ;7D ;BIT 7,(Ix+d),L
3574instr fetch_nop, op_BIT7, store_nop ;7E ;BIT 7,(Ix+d)
3575instr fetch_nop, op_BIT7, store_nop ;7F ;BIT 7,(Ix+d),A
fb050095
L
3576instr fetch_nop, op_RES0, store2_B ;80 ;RES 0,(Ix+d),B
3577instr fetch_nop, op_RES0, store2_C ;81 ;RES 0,(Ix+d),C
3578instr fetch_nop, op_RES0, store2_D ;82 ;RES 0,(Ix+d),D
3579instr fetch_nop, op_RES0, store2_E ;83 ;RES 0,(Ix+d),E
3580instr fetch_nop, op_RES0, store2_H ;84 ;RES 0,(Ix+d),H
3581instr fetch_nop, op_RES0, store2_L ;85 ;RES 0,(Ix+d),L
e7a0f403 3582instr fetch_nop, op_RES0, store_nop ;86 ;RES 0,(Ix+d)
fb050095
L
3583instr fetch_nop, op_RES0, store2_A ;87 ;RES 0,(Ix+d),A
3584instr fetch_nop, op_RES1, store2_B ;88 ;RES 1,(Ix+d),B
3585instr fetch_nop, op_RES1, store2_C ;89 ;RES 1,(Ix+d),C
3586instr fetch_nop, op_RES1, store2_D ;8A ;RES 1,(Ix+d),D
3587instr fetch_nop, op_RES1, store2_E ;8B ;RES 1,(Ix+d),E
3588instr fetch_nop, op_RES1, store2_H ;8C ;RES 1,(Ix+d),H
3589instr fetch_nop, op_RES1, store2_L ;8D ;RES 1,(Ix+d),L
e7a0f403 3590instr fetch_nop, op_RES1, store_nop ;8E ;RES 1,(Ix+d)
fb050095
L
3591instr fetch_nop, op_RES1, store2_A ;8F ;RES 1,(Ix+d),A
3592instr fetch_nop, op_RES2, store2_B ;90 ;RES 2,(Ix+d),B
3593instr fetch_nop, op_RES2, store2_C ;91 ;RES 2,(Ix+d),C
3594instr fetch_nop, op_RES2, store2_D ;92 ;RES 2,(Ix+d),D
3595instr fetch_nop, op_RES2, store2_E ;93 ;RES 2,(Ix+d),E
3596instr fetch_nop, op_RES2, store2_H ;94 ;RES 2,(Ix+d),H
3597instr fetch_nop, op_RES2, store2_L ;95 ;RES 2,(Ix+d),L
e7a0f403 3598instr fetch_nop, op_RES2, store_nop ;96 ;RES 2,(Ix+d)
fb050095
L
3599instr fetch_nop, op_RES2, store2_A ;97 ;RES 2,(Ix+d),A
3600instr fetch_nop, op_RES3, store2_B ;98 ;RES 3,(Ix+d),B
3601instr fetch_nop, op_RES3, store2_C ;99 ;RES 3,(Ix+d),C
3602instr fetch_nop, op_RES3, store2_D ;9A ;RES 3,(Ix+d),D
3603instr fetch_nop, op_RES3, store2_E ;9B ;RES 3,(Ix+d),E
3604instr fetch_nop, op_RES3, store2_H ;9C ;RES 3,(Ix+d),H
3605instr fetch_nop, op_RES3, store2_L ;9D ;RES 3,(Ix+d),L
e7a0f403 3606instr fetch_nop, op_RES3, store_nop ;9E ;RES 3,(Ix+d)
fb050095
L
3607instr fetch_nop, op_RES3, store2_A ;9F ;RES 3,(Ix+d),A
3608instr fetch_nop, op_RES4, store2_B ;A0 ;RES 4,(Ix+d),B
3609instr fetch_nop, op_RES4, store2_C ;A1 ;RES 4,(Ix+d),C
3610instr fetch_nop, op_RES4, store2_D ;A2 ;RES 4,(Ix+d),D
3611instr fetch_nop, op_RES4, store2_E ;A3 ;RES 4,(Ix+d),E
3612instr fetch_nop, op_RES4, store2_H ;A4 ;RES 4,(Ix+d),H
3613instr fetch_nop, op_RES4, store2_L ;A5 ;RES 4,(Ix+d),L
e7a0f403 3614instr fetch_nop, op_RES4, store_nop ;A6 ;RES 4,(Ix+d)
fb050095
L
3615instr fetch_nop, op_RES4, store2_A ;A7 ;RES 4,(Ix+d),A
3616instr fetch_nop, op_RES5, store2_B ;A8 ;RES 5,(Ix+d),B
3617instr fetch_nop, op_RES5, store2_C ;A9 ;RES 5,(Ix+d),C
3618instr fetch_nop, op_RES5, store2_D ;AA ;RES 5,(Ix+d),D
3619instr fetch_nop, op_RES5, store2_E ;AB ;RES 5,(Ix+d),E
3620instr fetch_nop, op_RES5, store2_H ;AC ;RES 5,(Ix+d),H
3621instr fetch_nop, op_RES5, store2_L ;AD ;RES 5,(Ix+d),L
e7a0f403 3622instr fetch_nop, op_RES5, store_nop ;AE ;RES 5,(Ix+d)
fb050095
L
3623instr fetch_nop, op_RES5, store2_A ;AF ;RES 5,(Ix+d),A
3624instr fetch_nop, op_RES6, store2_B ;B0 ;RES 6,(Ix+d),B
3625instr fetch_nop, op_RES6, store2_C ;B1 ;RES 6,(Ix+d),C
3626instr fetch_nop, op_RES6, store2_D ;B2 ;RES 6,(Ix+d),D
3627instr fetch_nop, op_RES6, store2_E ;B3 ;RES 6,(Ix+d),E
3628instr fetch_nop, op_RES6, store2_H ;B4 ;RES 6,(Ix+d),H
3629instr fetch_nop, op_RES6, store2_L ;B5 ;RES 6,(Ix+d),L
e7a0f403 3630instr fetch_nop, op_RES6, store_nop ;B6 ;RES 6,(Ix+d)
fb050095
L
3631instr fetch_nop, op_RES6, store2_A ;B7 ;RES 6,(Ix+d),A
3632instr fetch_nop, op_RES7, store2_B ;B8 ;RES 7,(Ix+d),B
3633instr fetch_nop, op_RES7, store2_C ;B9 ;RES 7,(Ix+d),C
3634instr fetch_nop, op_RES7, store2_D ;BA ;RES 7,(Ix+d),D
3635instr fetch_nop, op_RES7, store2_E ;BB ;RES 7,(Ix+d),E
3636instr fetch_nop, op_RES7, store2_H ;BC ;RES 7,(Ix+d),H
3637instr fetch_nop, op_RES7, store2_L ;BD ;RES 7,(Ix+d),L
e7a0f403 3638instr fetch_nop, op_RES7, store_nop ;BE ;RES 7,(Ix+d)
fb050095
L
3639instr fetch_nop, op_RES7, store2_A ;BF ;RES 7,(Ix+d),A
3640instr fetch_nop, op_SET0, store2_B ;C0 ;SET 0,(Ix+d),B
3641instr fetch_nop, op_SET0, store2_C ;C1 ;SET 0,(Ix+d),C
3642instr fetch_nop, op_SET0, store2_D ;C2 ;SET 0,(Ix+d),D
3643instr fetch_nop, op_SET0, store2_E ;C3 ;SET 0,(Ix+d),E
3644instr fetch_nop, op_SET0, store2_H ;C4 ;SET 0,(Ix+d),H
3645instr fetch_nop, op_SET0, store2_L ;C5 ;SET 0,(Ix+d),L
e7a0f403 3646instr fetch_nop, op_SET0, store_nop ;C6 ;SET 0,(Ix+d)
fb050095
L
3647instr fetch_nop, op_SET0, store2_A ;C7 ;SET 0,(Ix+d),A
3648instr fetch_nop, op_SET1, store2_B ;C8 ;SET 1,(Ix+d),B
3649instr fetch_nop, op_SET1, store2_C ;C9 ;SET 1,(Ix+d),C
3650instr fetch_nop, op_SET1, store2_D ;CA ;SET 1,(Ix+d),D
3651instr fetch_nop, op_SET1, store2_E ;CB ;SET 1,(Ix+d),E
3652instr fetch_nop, op_SET1, store2_H ;CC ;SET 1,(Ix+d),H
3653instr fetch_nop, op_SET1, store2_L ;CD ;SET 1,(Ix+d),L
e7a0f403 3654instr fetch_nop, op_SET1, store_nop ;CE ;SET 1,(Ix+d)
fb050095
L
3655instr fetch_nop, op_SET1, store2_A ;CF ;SET 1,(Ix+d),A
3656instr fetch_nop, op_SET2, store2_B ;D0 ;SET 2,(Ix+d),B
3657instr fetch_nop, op_SET2, store2_C ;D1 ;SET 2,(Ix+d),C
3658instr fetch_nop, op_SET2, store2_D ;D2 ;SET 2,(Ix+d),D
3659instr fetch_nop, op_SET2, store2_E ;D3 ;SET 2,(Ix+d),E
3660instr fetch_nop, op_SET2, store2_H ;D4 ;SET 2,(Ix+d),H
3661instr fetch_nop, op_SET2, store2_L ;D5 ;SET 2,(Ix+d),L
e7a0f403 3662instr fetch_nop, op_SET2, store_nop ;D6 ;SET 2,(Ix+d)
fb050095
L
3663instr fetch_nop, op_SET2, store2_A ;D7 ;SET 2,(Ix+d),A
3664instr fetch_nop, op_SET3, store2_B ;D8 ;SET 3,(Ix+d),B
3665instr fetch_nop, op_SET3, store2_C ;D9 ;SET 3,(Ix+d),C
3666instr fetch_nop, op_SET3, store2_D ;DA ;SET 3,(Ix+d),D
3667instr fetch_nop, op_SET3, store2_E ;DB ;SET 3,(Ix+d),E
3668instr fetch_nop, op_SET3, store2_H ;DC ;SET 3,(Ix+d),H
3669instr fetch_nop, op_SET3, store2_L ;DD ;SET 3,(Ix+d),L
e7a0f403 3670instr fetch_nop, op_SET3, store_nop ;DE ;SET 3,(Ix+d)
fb050095
L
3671instr fetch_nop, op_SET3, store2_A ;DF ;SET 3,(Ix+d),A
3672instr fetch_nop, op_SET4, store2_B ;E0 ;SET 4,(Ix+d),B
3673instr fetch_nop, op_SET4, store2_C ;E1 ;SET 4,(Ix+d),C
3674instr fetch_nop, op_SET4, store2_D ;E2 ;SET 4,(Ix+d),D
3675instr fetch_nop, op_SET4, store2_E ;E3 ;SET 4,(Ix+d),E
3676instr fetch_nop, op_SET4, store2_H ;E4 ;SET 4,(Ix+d),H
3677instr fetch_nop, op_SET4, store2_L ;E5 ;SET 4,(Ix+d),L
e7a0f403 3678instr fetch_nop, op_SET4, store_nop ;E6 ;SET 4,(Ix+d)
fb050095
L
3679instr fetch_nop, op_SET4, store2_A ;E7 ;SET 4,(Ix+d),A
3680instr fetch_nop, op_SET5, store2_B ;E8 ;SET 5,(Ix+d),B
3681instr fetch_nop, op_SET5, store2_C ;E9 ;SET 5,(Ix+d),C
3682instr fetch_nop, op_SET5, store2_D ;EA ;SET 5,(Ix+d),D
3683instr fetch_nop, op_SET5, store2_E ;EB ;SET 5,(Ix+d),E
3684instr fetch_nop, op_SET5, store2_H ;EC ;SET 5,(Ix+d),H
3685instr fetch_nop, op_SET5, store2_L ;ED ;SET 5,(Ix+d),L
e7a0f403 3686instr fetch_nop, op_SET5, store_nop ;EE ;SET 5,(Ix+d)
fb050095
L
3687instr fetch_nop, op_SET5, store2_A ;EF ;SET 5,(Ix+d),A
3688instr fetch_nop, op_SET6, store2_B ;F0 ;SET 6,(Ix+d),B
3689instr fetch_nop, op_SET6, store2_C ;F1 ;SET 6,(Ix+d),C
3690instr fetch_nop, op_SET6, store2_D ;F2 ;SET 6,(Ix+d),D
3691instr fetch_nop, op_SET6, store2_E ;F3 ;SET 6,(Ix+d),E
3692instr fetch_nop, op_SET6, store2_H ;F4 ;SET 6,(Ix+d),H
3693instr fetch_nop, op_SET6, store2_L ;F5 ;SET 6,(Ix+d),L
e7a0f403 3694instr fetch_nop, op_SET6, store_nop ;F6 ;SET 6,(Ix+d)
fb050095
L
3695instr fetch_nop, op_SET6, store2_A ;F7 ;SET 6,(Ix+d),A
3696instr fetch_nop, op_SET7, store2_B ;F8 ;SET 7,(Ix+d),B
3697instr fetch_nop, op_SET7, store2_C ;F9 ;SET 7,(Ix+d),C
3698instr fetch_nop, op_SET7, store2_D ;FA ;SET 7,(Ix+d),D
3699instr fetch_nop, op_SET7, store2_E ;FB ;SET 7,(Ix+d),E
3700instr fetch_nop, op_SET7, store2_H ;FC ;SET 7,(Ix+d),H
3701instr fetch_nop, op_SET7, store2_L ;FD ;SET 7,(Ix+d),L
e7a0f403 3702instr fetch_nop, op_SET7, store_nop ;FE ;SET 7,(Ix+d)
fb050095 3703instr fetch_nop, op_SET7, store2_A ;FF ;SET 7,(Ix+d),A
fa9059af 3704
623dd899
L
3705do_fetch_0:
3706 ldi opl,0
3707 ret
3708
3709;----------------------------------------------------------------
3710;|Mnemonic |SZHPNC|Description |Notes |
3711;----------------------------------------------------------------
3712;|IN r,[C] |***P0-|Input |r=[C] |
3713;
3714
3715do_op_in: ; in opl,(opl)
3716.if PORT_DEBUG
3717 push opl
3718 cp opl,_0 ; don't debug port 0 (con stat)
3719 breq dbg_op_in_1
3720 printnewline
3721 printstring "Port read: ("
3722 mov temp,opl
3723 lcall printhex
3724 printstring ") -> "
3725dbg_op_in_1:
3726.endif
3727
3728 mov temp2,opl
3729 lcall portRead
3730 mov opl,temp
3731 bst z_flags,ZFL_C ;save Carry
3732 ldpmx z_flags,sz53p_tab,temp ;S,Z,P
3733 bld z_flags,ZFL_C
3734
3735.if PORT_DEBUG
3736 pop temp
3737 cp temp,_0
3738 breq dbg_op_in_2
3739 lcall printhex
3740 printstring " "
3741dbg_op_in_2:
3742.endif
3743 ret
3744
3745;----------------------------------------------------------------
3746;|Mnemonic |SZHPNC|Description |Notes |
3747;----------------------------------------------------------------
3748;|OUT [C],r |------|Output |[C]=r |
3749;
3750
3751do_op_out: ; out (c),opl
3752.if PORT_DEBUG
3753 printnewline
3754 printstring "Port write: "
3755 mov temp,opl
3756 lcall printhex
3757 printstring " -> ("
825ecc9d 3758 mov temp,z_c
623dd899
L
3759 lcall printhex
3760 printstring ") "
3761.endif
3762 mov temp,opl
825ecc9d 3763 mov temp2,z_c
623dd899
L
3764 lcall portWrite
3765 ret
3766
3767;----------------------------------------------------------------
3768;|Mnemonic |SZHPNC|Description |Notes |
3769;----------------------------------------------------------------
3770;|LD dst,src|------|Load |dst=src |
3771;
3772
3773do_op_stbc: ;store bc to mem loc in opl:h
3774 movw xl,opl
825ecc9d 3775 mem_write_s z_c
623dd899 3776 adiw xl,1
825ecc9d 3777 mem_write_s z_b
623dd899
L
3778 ret
3779
3780;----------------------------------------------------------------
3781;|Mnemonic |SZHPNC|Description |Notes |
3782;----------------------------------------------------------------
3783;|LD dst,src|------|Load |dst=src |
3784;
3785;
3786do_op_stde: ;store de to mem loc in opl:h
3787 movw xl,opl
825ecc9d 3788 mem_write_s z_e
623dd899 3789 adiw xl,1
825ecc9d 3790 mem_write_s z_d
623dd899
L
3791 ret
3792
3793;----------------------------------------------------------------
3794;|Mnemonic |SZHPNC|Description |Notes |
3795;----------------------------------------------------------------
3796;|LD dst,src|------|Load |dst=src |
3797;
3798;
3799do_op_stsp: ;store sp to mem loc in opl:h
3800 movw xl,opl
3801 mem_write_s z_spl
3802 adiw xl,1
3803 mem_write_s z_sph
3804 ret
3805
3806;----------------------------------------------------------------
3807;|Mnemonic |SZHPNC|Description |Notes |
3808;----------------------------------------------------------------
3809;|ADC HL,ss |***V0*|Add with Carry |HL=HL+ss+CY |
3810;
3811
3812do_op_ADCHL:
825ecc9d 3813 lsr z_flags ; ZFL_C --> Carry
623dd899 3814 ldi z_flags,0 ; clear N
825ecc9d
L
3815 adc z_l,opl
3816 in temp,sreg ; save lower Z
3817 adc z_h,oph
3818 in temp2,sreg
3819
3820 and temp,temp2 ; 16bit Z
623dd899
L
3821 bmov z_flags,ZFL_C, temp2,AVR_C
3822 bmov z_flags,ZFL_P, temp2,AVR_V
3823 bmov z_flags,ZFL_H, temp2,AVR_H
3824 bmov z_flags,ZFL_Z, temp,AVR_Z
3825 bmov z_flags,ZFL_S, temp2,AVR_N
3826 ret
3827
3828;----------------------------------------------------------------
3829;|Mnemonic |SZHPNC|Description |Notes |
3830;----------------------------------------------------------------
3831;|SBC HL,ss |***V1*|Subtract with carry |HL=HL-ss-CY |
3832;
3833
3834 checkspace PC, 24
3835
3836do_op_sbchl:
825ecc9d
L
3837 lsr z_flags ; get Z80 carry
3838 sez ; set z
3839 sbc z_l,opl
3840 sbc z_h,oph
623dd899 3841 in temp,sreg
825ecc9d 3842 ldi z_flags,(1<<ZFL_N) ; set N
623dd899
L
3843 bmov z_flags,ZFL_C, temp,AVR_C
3844 bmov z_flags,ZFL_P, temp,AVR_V
3845 bmov z_flags,ZFL_H, temp,AVR_H
3846 bmov z_flags,ZFL_Z, temp,AVR_Z
3847 bmov z_flags,ZFL_S, temp,AVR_N
3848 ret
3849
3850;----------------------------------------------------------------
3851;|Mnemonic |SZHPNC|Description |Notes |
3852;----------------------------------------------------------------
3853;|NEG |***V1*|Negate A |A=0-A |
3854
3855;
3856do_op_NEG:
3857 ldi temp,0
3858 sub temp,z_a
3859 mov z_a,temp
3860 in temp,sreg
3861 ldpmx z_flags,sz53p_tab,z_a ;S,Z,P
3862 bmov z_flags,ZFL_C, temp,AVR_C
3863 bmov z_flags,ZFL_H, temp,AVR_H
3864 do_z80_flags_V
3865 do_z80_flags_set_N
3866 ret
3867
3868;----------------------------------------------------------------
3869;|Mnemonic |SZHPNC|Description |Notes |
3870;----------------------------------------------------------------
3871;|RETI |------|Return from Interrupt|PC=[SP]+ |
3872;|RETN |------|Return from NMI | Copy IFF2 to IFF1 |
3873
3874
3875do_op_RETI:
3876do_op_RETN:
3877 ldd temp,y+oz_istat
3878 bmov temp,IFF1, temp,IFF2
3879 std y+oz_istat,temp
3880 ljmp do_store_ret
3881
3882
3883;----------------------------------------------------------------
3884;|Mnemonic |SZHPNC|Description |Notes |
3885;----------------------------------------------------------------
3886;|IM n |------|Interrupt Mode | (n=0,1,2)|
3887
3888do_op_IM0:
3889 ldd temp,y+oz_istat
3890 andi temp, ~IM_MASK
3891 std y+oz_istat,temp
3892 ret
3893
3894do_op_IM1:
3895 ldd temp,y+oz_istat
3896 andi temp,~IM_MASK
3897 ori temp,IM1
3898 std y+oz_istat,temp
3899 ret
3900
3901do_op_IM2:
3902 ldd temp,y+oz_istat
3903 andi temp, ~IM_MASK
3904 ori temp,IM2
3905 std y+oz_istat,temp
3906 ret
3907
3908;----------------------------------------------------------------
3909;|Mnemonic |SZHPNC|Description |Notes |
3910;----------------------------------------------------------------
3911;|LD A,i |**0*0-|Load |(i=I,R) IFF2 --> P |
3912;|LD i,A |------|Load |(i=I,R) |
3913
3914do_op_ldai:
3915 ldd z_a,y+oz_i
3916 rjmp op_ldar1
3917
3918do_op_ldar:
3919 ldd z_a,y+oz_r
3920op_ldar1:
3921 bst z_flags,ZFL_C ;save C
3922 ldpmx z_flags,sz53p_tab,z_a ;S,Z,H,P,N
3923 bld z_flags,ZFL_C ;
3924 ldd temp,y+oz_istat
3925 bmov z_flags,ZFL_P, temp,IFF2
3926 ret
3927
3928do_op_ldia:
3929 std y+oz_i,z_a
3930 ret
3931
3932do_op_ldra:
3933 std y+oz_r,z_a
3934 ret
3935
3936;----------------------------------------------------------------
3937;|Mnemonic |SZHPNC|Description |Notes |
3938;----------------------------------------------------------------
3939;|RLD |**0P0-|Rotate Left 4 bits |{A,[HL]}={A,[HL]}<- ##|
3940;|RRD |**0P0-|Rotate Right 4 bits |{A,[HL]}=->{A,[HL]} ##|
3941
3942do_op_rld:
3943 swap opl
3944 mov oph,opl
3945 andi opl,0xf0
3946 andi oph,0x0f
3947 mov temp,z_a
3948 andi temp,0x0f
3949 or opl,temp
3950 mov temp,z_a
3951 andi temp,0xf0
3952 or temp,oph
3953 mov z_a,temp
3954 bst z_flags,ZFL_C ;save C
3955 ldpmx z_flags,sz53p_tab,z_a ;S,Z,H,P,N
3956 bld z_flags,ZFL_C ;
3957 ret
3958
3959do_op_rrd:
3960 mov oph,opl
3961 andi opl,0xf0
3962 andi oph,0x0f
3963 mov temp,z_a
3964 andi temp,0x0f
3965 or opl,temp
3966 swap opl
3967 mov temp,z_a
3968 andi temp,0xf0
3969 or temp,oph
3970 mov z_a,temp
3971 bst z_flags,ZFL_C ;save C
3972 ldpmx z_flags,sz53p_tab,z_a ;S,Z,H,P,N
3973 bld z_flags,ZFL_C ;
3974 ret
3975
3976
3977;----------------------------------------------------------------
3978;|Mnemonic |SZHPNC|Description |Notes |
3979;----------------------------------------------------------------
3980;|LDD |--0*0-|Load and Decrement |[DE]=[HL],HL=HL-1,# |
3981;|LDDR |--000-|Load, Dec., Repeat |LDD till BC=0 |
3982;|LDI |--0*0-|Load and Increment |[DE]=[HL],HL=HL+1,# |
3983;|LDIR |--000-|Load, Inc., Repeat |LDI till BC=0 |
3984;
3985
825ecc9d 3986 checkspace PC, 13
623dd899
L
3987
3988op_LDxx_common:
bca3519f
L
3989; movw x,z_l ;
3990; lcall dram_read ; temp = (HL)
3991 mem_read_ds temp, z_hl
3992; movw x,z_e ;
3993; lcall dram_write ; (DE) = temp
3994 mem_write_ds z_de, temp
623dd899 3995
623dd899 3996 cbr z_flags,(1<<ZFL_H) | (1<<ZFL_P) | (1<<ZFL_N)
825ecc9d
L
3997
3998 movw x,z_c
3999 sbiw x,1 ;BC--
4000 movw z_c,x
623dd899
L
4001 breq PC+2
4002 sbr z_flags,(1<<ZFL_P)
623dd899
L
4003 ret
4004
825ecc9d 4005 checkspace PC, 6
623dd899
L
4006
4007do_op_LDI:
4008 rcall op_LDxx_common
825ecc9d
L
4009 sub z_e,_255 ;-low(-1) DE++
4010 sbc z_d,_255 ;-high(-1)
4011 sub z_l,_255 ;-low(-1) HL++
4012 sbc z_h,_255 ;-high(-1)
623dd899
L
4013 ret
4014
825ecc9d 4015 checkspace PC, 6
623dd899
L
4016
4017do_op_LDD:
4018 rcall op_LDxx_common
825ecc9d
L
4019 add z_e,_255 ;+low(-1) DE--
4020 adc z_d,_255 ;+high(-1)
4021 add z_l,_255 ;+low(-1) HL--
4022 adc z_h,_255 ;+high(-1)
623dd899
L
4023 ret
4024
4025 checkspace PC, 5
4026
4027do_op_LDIR:
4028 rcall do_op_LDI
4029#if 1
4030 sbrc z_flags,ZFL_P
4031 rjmp do_op_LDIR
4032 ret
4033#else
4034 sbrs z_flags,ZFL_P
4035 ret
4036 sbiw z_pcl,2
4037 ret
4038#endif
4039
4040 checkspace PC, 5
4041
4042do_op_LDDR:
4043 rcall do_op_LDD
bca3519f
L
4044#if 1
4045 sbrc z_flags,ZFL_P
4046 rjmp do_op_LDDR
4047 ret
4048#else
623dd899
L
4049 sbrs z_flags,ZFL_P
4050 ret
4051 sbiw z_pcl,2
4052 ret
bca3519f 4053#endif
623dd899
L
4054
4055;----------------------------------------------------------------
4056;|Mnemonic |SZHPNC|Description |Notes |
4057;----------------------------------------------------------------
4058;|CPD |****1-|Compare and Decrement|A-[HL],HL=HL-1,BC=BC-1|
4059;|CPDR |****1-|Compare, Dec., Repeat|CPD till A=[HL]or BC=0|
4060;|CPI |****1-|Compare and Increment|A-[HL],HL=HL+1,BC=BC-1|
4061;|CPIR |****1-|Compare, Inc., Repeat|CPI till A=[HL]or BC=0|
4062
4063
4064 checkspace PC, 21
4065
4066op_CPxx_common:
825ecc9d
L
4067 movw x,z_l ; HL
4068
4069 movw z,z_c ;BC
623dd899
L
4070
4071 cbr z_flags,(1<<ZFL_S)|(1<<ZFL_Z)|(1<<ZFL_H)|(1<<ZFL_P)
4072 sbr z_flags,(1<<ZFL_N)
4073 lcall dram_read ; temp = (HL)
4074
825ecc9d 4075 cp z_a,temp ; A - (HL)
623dd899
L
4076
4077 brpl PC+2
4078 sbr z_flags,(1<<ZFL_S)
4079 brne PC+2
4080 sbr z_flags,(1<<ZFL_Z)
4081 brhc PC+2
4082 sbr z_flags,(1<<ZFL_H)
4083
4084 sbiw z,1 ; BC--
4085 breq PC+2
4086 sbr z_flags,(1<<ZFL_P)
825ecc9d 4087 movw z_c,z ;BC
623dd899
L
4088 ret
4089
4090 checkspace PC, 5
4091
4092do_op_CPI:
4093 rcall op_CPxx_common
4094 adiw x,1 ; HL++
825ecc9d 4095 movw z_l,x ; HL
623dd899
L
4096 ret
4097
4098
4099 checkspace PC, 5
4100
4101do_op_CPD:
4102 rcall op_CPxx_common
4103 sbiw x,1 ; HL--
825ecc9d 4104 movw z_l,x ; HL
623dd899
L
4105 ret
4106
4107 checkspace PC, 7
4108
4109do_op_CPIR:
4110 rcall do_op_CPI
4111 sbrc z_flags,ZFL_Z
4112 ret
4113 sbrs z_flags,ZFL_P
4114 ret
4115 sbiw z_pcl,2
4116 ret
4117
4118 checkspace PC, 7
4119
4120do_op_CPDR:
4121 rcall do_op_CPD
4122 sbrc z_flags,ZFL_Z
4123 ret
4124 sbrs z_flags,ZFL_P
4125 ret
4126 sbiw z_pcl,2
4127 ret
4128
4129;----------------------------------------------------------------
4130;|Mnemonic |SZHPNC|Description |Notes |
4131;----------------------------------------------------------------
4132;|INI |?*??1-|Input and Increment |[HL]=[C],HL=HL+1,B=B-1|
4133;|IND |?*??1-|Input and Decrement |[HL]=[C],HL=HL-1,B=B-1|
4134;|INIR |?1??1-|Input, Inc., Repeat |INI till B=0 |
4135;|INDR |?1??1-|Input, Dec., Repeat |IND till B=0 |
4136
825ecc9d 4137 checkspace PC, 12
623dd899
L
4138
4139op_INxx_common:
4140 cbr z_flags,(1<<ZFL_Z)
4141 sbr z_flags,(1<<ZFL_N)
825ecc9d 4142 mov temp2,z_c ;C
623dd899 4143 lcall portRead
825ecc9d 4144 movw x,z_l ;HL
623dd899 4145 lcall dram_write
825ecc9d 4146 dec z_b ;B
623dd899
L
4147 brne PC+2
4148 sbr z_flags,(1<<ZFL_Z)
4149 ret
4150
825ecc9d 4151 checkspace PC, 4
623dd899
L
4152
4153do_op_INI:
4154 rcall op_INxx_common
4155 adiw x,1
825ecc9d 4156 movw z_l,x ;HL
623dd899
L
4157 ret
4158
825ecc9d 4159 checkspace PC, 4
623dd899
L
4160
4161do_op_IND:
4162 rcall op_INxx_common
4163 sbiw x,1
825ecc9d 4164 movw z_l,x ;HL
623dd899
L
4165 ret
4166
4167 checkspace PC, 5
4168
4169do_op_INIR:
4170 rcall do_op_INI
4171 sbrc z_flags,ZFL_Z
4172 ret
4173 sbiw z_pcl,2
4174 ret
4175
4176 checkspace PC, 5
4177
4178do_op_INDR:
4179 rcall do_op_IND
4180 sbrc z_flags,ZFL_Z
4181 ret
4182 sbiw z_pcl,2
4183 ret
4184
4185;----------------------------------------------------------------
4186;|Mnemonic |SZHPNC|Description |Notes |
4187;----------------------------------------------------------------
4188;|OUTI |?*??1-|Output and Increment |[C]=[HL],HL=HL+1,B=B-1|
4189;|OUTD |?*??1-|Output and Decrement |[C]=[HL],HL=HL-1,B=B-1|
4190;|OTIR |?1??1-|Output, Inc., Repeat |OUTI till B=0 |
4191;|OTDR |?1??1-|Output, Dec., Repeat |OUTD till B=0 |
4192
825ecc9d 4193 checkspace PC, 12
623dd899
L
4194
4195op_OUTxx_common:
825ecc9d 4196 movw x,z_l ;HL
623dd899 4197 lcall dram_read ;temp = (z)
825ecc9d 4198 mov temp2,z_c ;C
623dd899 4199 lcall portWrite
825ecc9d
L
4200 cbr z_flags,(1<<ZFL_Z)
4201 sbr z_flags,(1<<ZFL_N)
4202 dec z_b ;B
623dd899
L
4203 brne PC+2
4204 sbr z_flags,(1<<ZFL_Z)
4205 ret
4206
825ecc9d 4207 checkspace PC, 4
623dd899
L
4208
4209do_op_OUTI:
623dd899 4210 rcall op_OUTxx_common
825ecc9d
L
4211 sub z_l,_255 ;-low(-1)
4212 sbc z_h,_255 ;-high(-1)
623dd899
L
4213 ret
4214
825ecc9d 4215 checkspace PC, 4
623dd899
L
4216
4217do_op_OUTD:
623dd899 4218 rcall op_OUTxx_common
825ecc9d
L
4219 add z_l,_255 ;+low(-1)
4220 adc z_h,_255 ;+high(-1)
623dd899
L
4221 ret
4222
4223 checkspace PC, 5
4224
4225do_op_OTIR:
4226 rcall do_op_OUTI
4227 sbrc z_flags,ZFL_Z
4228 ret
4229 sbiw z_pcl,2
4230 ret
4231
4232 checkspace PC, 5
4233
4234do_op_OTDR:
4235 rcall do_op_OUTD
4236 sbrc z_flags,ZFL_Z
4237 ret
4238 sbiw z_pcl,2
4239 ret
4240
4241#if 1
4242 opctable EDjmp, PC ;+ 2*256
4243
4244instr fetch_nop, op_nop, store_nop ;00 ;NOP
4245instr fetch_nop, op_nop, store_nop ;01 ;NOP
4246instr fetch_nop, op_nop, store_nop ;02 ;NOP
4247instr fetch_nop, op_nop, store_nop ;03 ;NOP
4248instr fetch_nop, op_nop, store_nop ;04 ;NOP
4249instr fetch_nop, op_nop, store_nop ;05 ;NOP
4250instr fetch_nop, op_nop, store_nop ;06 ;NOP
4251instr fetch_nop, op_nop, store_nop ;07 ;NOP
4252instr fetch_nop, op_nop, store_nop ;08 ;NOP
4253instr fetch_nop, op_nop, store_nop ;09 ;NOP
4254instr fetch_nop, op_nop, store_nop ;0A ;NOP
4255instr fetch_nop, op_nop, store_nop ;0B ;NOP
4256instr fetch_nop, op_nop, store_nop ;0C ;NOP
4257instr fetch_nop, op_nop, store_nop ;0D ;NOP
4258instr fetch_nop, op_nop, store_nop ;0E ;NOP
4259instr fetch_nop, op_nop, store_nop ;0F ;NOP
4260instr fetch_nop, op_nop, store_nop ;10 ;NOP
4261instr fetch_nop, op_nop, store_nop ;11 ;NOP
4262instr fetch_nop, op_nop, store_nop ;12 ;NOP
4263instr fetch_nop, op_nop, store_nop ;13 ;NOP
4264instr fetch_nop, op_nop, store_nop ;14 ;NOP
4265instr fetch_nop, op_nop, store_nop ;15 ;NOP
4266instr fetch_nop, op_nop, store_nop ;16 ;NOP
4267instr fetch_nop, op_nop, store_nop ;17 ;NOP
4268instr fetch_nop, op_nop, store_nop ;18 ;NOP
4269instr fetch_nop, op_nop, store_nop ;19 ;NOP
4270instr fetch_nop, op_nop, store_nop ;1A ;NOP
4271instr fetch_nop, op_nop, store_nop ;1B ;NOP
4272instr fetch_nop, op_nop, store_nop ;1C ;NOP
4273instr fetch_nop, op_nop, store_nop ;1D ;NOP
4274instr fetch_nop, op_nop, store_nop ;1E ;NOP
4275instr fetch_nop, op_nop, store_nop ;1F ;NOP
4276instr fetch_nop, op_nop, store_nop ;20 ;NOP
4277instr fetch_nop, op_nop, store_nop ;21 ;NOP
4278instr fetch_nop, op_nop, store_nop ;22 ;NOP
4279instr fetch_nop, op_nop, store_nop ;23 ;NOP
4280instr fetch_nop, op_nop, store_nop ;24 ;NOP
4281instr fetch_nop, op_nop, store_nop ;25 ;NOP
4282instr fetch_nop, op_nop, store_nop ;26 ;NOP
4283instr fetch_nop, op_nop, store_nop ;27 ;NOP
4284instr fetch_nop, op_nop, store_nop ;28 ;NOP
4285instr fetch_nop, op_nop, store_nop ;29 ;NOP
4286instr fetch_nop, op_nop, store_nop ;2A ;NOP
4287instr fetch_nop, op_nop, store_nop ;2B ;NOP
4288instr fetch_nop, op_nop, store_nop ;2C ;NOP
4289instr fetch_nop, op_nop, store_nop ;2D ;NOP
4290instr fetch_nop, op_nop, store_nop ;2E ;NOP
4291instr fetch_nop, op_nop, store_nop ;2F ;NOP
4292instr fetch_nop, op_nop, store_nop ;30 ;NOP
4293instr fetch_nop, op_nop, store_nop ;31 ;NOP
4294instr fetch_nop, op_nop, store_nop ;32 ;NOP
4295instr fetch_nop, op_nop, store_nop ;33 ;NOP
4296instr fetch_nop, op_nop, store_nop ;34 ;NOP
4297instr fetch_nop, op_nop, store_nop ;35 ;NOP
4298instr fetch_nop, op_nop, store_nop ;36 ;NOP
4299instr fetch_nop, op_nop, store_nop ;37 ;NOP
4300instr fetch_nop, op_nop, store_nop ;38 ;NOP
4301instr fetch_nop, op_nop, store_nop ;39 ;NOP
4302instr fetch_nop, op_nop, store_nop ;3A ;NOP
4303instr fetch_nop, op_nop, store_nop ;3B ;NOP
4304instr fetch_nop, op_nop, store_nop ;3C ;NOP
4305instr fetch_nop, op_nop, store_nop ;3D ;NOP
4306instr fetch_nop, op_nop, store_nop ;3E ;NOP
4307instr fetch_nop, op_nop, store_nop ;3F ;NOP
4308instr fetch_C, op_IN, store2_B ;40 ;IN B,(C)
4309instr fetch_B, op_OUT, store_nop ;41 ;OUT (C),B
4310instr fetch_BC, op_SBCHL, store_nop ;42 ;SBC HL,BC
4311instr fetch_DIR16, op_STBC, store_nop ;43 ;LD (nn),BC
4312instr fetch_nop, op_NEG, store_nop ;44 ;NEG
4313instr fetch_nop, op_RETN, store_nop ;45 ;RETN
4314instr fetch_nop, op_IM0, store_nop ;46 ;IM 0
4315instr fetch_nop, op_ldia, store_nop ;47 ;LD I,A
4316instr fetch_C, op_IN, store2_C ;48 ;IN C,(C)
4317instr fetch_C, op_OUT, store_nop ;49 ;OUT (C),C
4318instr fetch_BC, op_ADCHL, store_nop ;4A ;ADC HL,BC
4319instr fetch_DIR16, op_RMEM16, store_BC ;4B nn nn ;LD BC,(nn)
4320instr fetch_nop, op_NEG, store_nop ;4C ;NEG
4321instr fetch_nop, op_RETI, store_nop ;4D ;RETI
4322instr fetch_nop, op_IM0, store_nop ;4E ;IM 0
4323instr fetch_nop, op_ldra, store_nop ;4F ;LD R,A
4324instr fetch_C, op_IN, store2_D ;50 ;IN D,(C)
4325instr fetch_D, op_OUT, store_nop ;51 ;OUT (C),D
4326instr fetch_DE, op_SBCHL, store_nop ;52 ;SBC HL,DE
4327instr fetch_DIR16, op_STDE, store_nop ;53 nn nn ;LD (nn),DE
4328instr fetch_nop, op_NEG, store_nop ;54 ;NEG
4329instr fetch_nop, op_RETN, store_nop ;55 ;RETN
4330instr fetch_nop, op_IM1, store_nop ;56 ;IM 1
4331instr fetch_nop, op_ldai, store_nop ;57 ;LD A,I
4332instr fetch_C, op_IN, store2_E ;58 ;IN E,(C)
4333instr fetch_E, op_OUT, store_nop ;59 ;OUT (C),E
4334instr fetch_DE, op_ADCHL, store_nop ;5A ;ADC HL,DE
4335instr fetch_DIR16, op_RMEM16, store_DE ;5B nn nn ;LD DE,(nn)
4336instr fetch_nop, op_NEG, store_nop ;5C ;NEG
4337instr fetch_nop, op_RETN, store_nop ;5D ;RETN
4338instr fetch_nop, op_IM2, store_nop ;5E ;IM 2
4339instr fetch_nop, op_ldar, store_nop ;5F ;LD A,R
4340instr fetch_C, op_IN, store2_H ;60 ;IN H,(C)
4341instr fetch_H, op_OUT, store_nop ;61 ;OUT (C),H
4342instr fetch_HL, op_SBCHL, store_nop ;62 ;SBC HL,HL
4343instr fetch_DIR16, op_STHL, store_nop ;63 nn nn ;LD (nn),HL
4344instr fetch_nop, op_NEG, store_nop ;64 ;NEG
4345instr fetch_nop, op_RETN, store_nop ;65 ;RETN
4346instr fetch_nop, op_IM0, store_nop ;66 ;IM 0
4347instr fetch2_mhl, op_RRD, store_mhl ;67 ;RRD
4348instr fetch_C, op_IN, store2_L ;68 ;IN L,(C)
4349instr fetch_L, op_OUT, store_nop ;69 ;OUT (C),L
4350instr fetch_HL, op_ADCHL, store_nop ;6A ;ADC HL,HL
4351instr fetch_DIR16, op_RMEM16, store_HL ;6B nn nn ;LD HL,(nn)
4352instr fetch_nop, op_NEG, store_nop ;6C ;NEG
4353instr fetch_nop, op_RETN, store_nop ;6D ;RETN
4354instr fetch_nop, op_IM0, store_nop ;6E ;IM 0
4355instr fetch2_mhl, op_RLD, store_mhl ;6F ;RLD
4356instr fetch_C, op_IN, store_nop ;70 ;IN (C)
4357instr fetch_0, op_OUT, store_nop ;71 ;OUT (C),0
4358instr fetch_SP, op_SBCHL, store_nop ;72 ;SBC HL,SP
4359instr fetch_DIR16, op_STSP, store_nop ;73 nn nn ;LD (nn),SP
4360instr fetch_nop, op_NEG, store_nop ;74 ;NEG
4361instr fetch_nop, op_RETN, store_nop ;75 ;RETN
4362instr fetch_nop, op_IM1, store_nop ;76 ;IM 1
4363instr fetch_nop, op_nop, store_nop ;77 ;NOP
4364instr fetch_C, op_IN, store2_A ;78 ;IN A,(C)
4365instr fetch_A, op_OUT, store_nop ;79 ;OUT (C),A
4366instr fetch_SP, op_ADCHL, store_nop ;7A ;ADC HL,SP
4367instr fetch_DIR16, op_RMEM16, store_SP ;7B nn nn ;LD SP,(nn)
4368instr fetch_nop, op_NEG, store_nop ;7C ;NEG
4369instr fetch_nop, op_RETN, store_nop ;7D ;RETN
4370instr fetch_nop, op_IM2, store_nop ;7E ;IM 2
4371instr fetch_nop, op_nop, store_nop ;7F ;NOP
4372instr fetch_nop, op_nop, store_nop ;80 ;NOP
4373instr fetch_nop, op_nop, store_nop ;81 ;NOP
4374instr fetch_nop, op_nop, store_nop ;82 ;NOP
4375instr fetch_nop, op_nop, store_nop ;83 ;NOP
4376instr fetch_nop, op_nop, store_nop ;84 ;NOP
4377instr fetch_nop, op_nop, store_nop ;85 ;NOP
4378instr fetch_nop, op_nop, store_nop ;86 ;NOP
4379instr fetch_nop, op_nop, store_nop ;87 ;NOP
4380instr fetch_nop, op_nop, store_nop ;88 ;NOP
4381instr fetch_nop, op_nop, store_nop ;89 ;NOP
4382instr fetch_nop, op_nop, store_nop ;8A ;NOP
4383instr fetch_nop, op_nop, store_nop ;8B ;NOP
4384instr fetch_nop, op_nop, store_nop ;8C ;NOP
4385instr fetch_nop, op_nop, store_nop ;8D ;NOP
4386instr fetch_nop, op_nop, store_nop ;8E ;NOP
4387instr fetch_nop, op_nop, store_nop ;8F ;NOP
4388instr fetch_nop, op_nop, store_nop ;90 ;NOP
4389instr fetch_nop, op_nop, store_nop ;91 ;NOP
4390instr fetch_nop, op_nop, store_nop ;92 ;NOP
4391instr fetch_nop, op_nop, store_nop ;93 ;NOP
4392instr fetch_nop, op_nop, store_nop ;94 ;NOP
4393instr fetch_nop, op_nop, store_nop ;95 ;NOP
4394instr fetch_nop, op_nop, store_nop ;96 ;NOP
4395instr fetch_nop, op_nop, store_nop ;97 ;NOP
4396instr fetch_nop, op_nop, store_nop ;98 ;NOP
4397instr fetch_nop, op_nop, store_nop ;99 ;NOP
4398instr fetch_nop, op_nop, store_nop ;9A ;NOP
4399instr fetch_nop, op_nop, store_nop ;9B ;NOP
4400instr fetch_nop, op_nop, store_nop ;9C ;NOP
4401instr fetch_nop, op_nop, store_nop ;9D ;NOP
4402instr fetch_nop, op_nop, store_nop ;9E ;NOP
4403instr fetch_nop, op_nop, store_nop ;9F ;NOP
4404instr fetch_nop, op_LDI, store_nop ;A0 ;LDI
4405instr fetch_nop, op_CPI, store_nop ;A1 ;CPI
4406instr fetch_nop, op_INI, store_nop ;A2 ;INI
4407instr fetch_nop, op_OUTI, store_nop ;A3 ;OUTI
4408instr fetch_nop, op_nop, store_nop ;A4 ;NOP
4409instr fetch_nop, op_nop, store_nop ;A5 ;NOP
4410instr fetch_nop, op_nop, store_nop ;A6 ;NOP
4411instr fetch_nop, op_nop, store_nop ;A7 ;NOP
4412instr fetch_nop, op_LDD, store_nop ;A8 ;LDD
4413instr fetch_nop, op_CPD, store_nop ;A9 ;CPD
4414instr fetch_nop, op_IND, store_nop ;AA ;IND
4415instr fetch_nop, op_OUTD, store_nop ;AB ;OUTD
4416instr fetch_nop, op_nop, store_nop ;AC ;NOP
4417instr fetch_nop, op_nop, store_nop ;AD ;NOP
4418instr fetch_nop, op_nop, store_nop ;AE ;NOP
4419instr fetch_nop, op_nop, store_nop ;AF ;NOP
4420instr fetch_nop, op_LDIR, store_nop ;B0 ;LDIR
4421instr fetch_nop, op_CPIR, store_nop ;B1 ;CPIR
4422instr fetch_nop, op_INIR, store_nop ;B2 ;INIR
4423instr fetch_nop, op_OTIR, store_nop ;B3 ;OTIR
4424instr fetch_nop, op_nop, store_nop ;B4 ;NOP
4425instr fetch_nop, op_nop, store_nop ;B5 ;NOP
4426instr fetch_nop, op_nop, store_nop ;B6 ;NOP
4427instr fetch_nop, op_nop, store_nop ;B7 ;NOP
4428instr fetch_nop, op_LDDR, store_nop ;B8 ;LDDR
4429instr fetch_nop, op_CPDR, store_nop ;B9 ;CPDR
4430instr fetch_nop, op_INDR, store_nop ;BA ;INDR
4431instr fetch_nop, op_OTDR, store_nop ;BB ;OTDR
4432instr fetch_nop, op_nop, store_nop ;BC ;NOP
4433instr fetch_nop, op_nop, store_nop ;BD ;NOP
4434instr fetch_nop, op_nop, store_nop ;BE ;NOP
4435instr fetch_nop, op_nop, store_nop ;BF ;NOP
4436instr fetch_nop, op_nop, store_nop ;C0 ;NOP
4437instr fetch_nop, op_nop, store_nop ;C1 ;NOP
4438instr fetch_nop, op_nop, store_nop ;C2 ;NOP
4439instr fetch_nop, op_nop, store_nop ;C3 ;NOP
4440instr fetch_nop, op_nop, store_nop ;C4 ;NOP
4441instr fetch_nop, op_nop, store_nop ;C5 ;NOP
4442instr fetch_nop, op_nop, store_nop ;C6 ;NOP
4443instr fetch_nop, op_nop, store_nop ;C7 ;NOP
4444instr fetch_nop, op_nop, store_nop ;C8 ;NOP
4445instr fetch_nop, op_nop, store_nop ;C9 ;NOP
4446instr fetch_nop, op_nop, store_nop ;CA ;NOP
4447instr fetch_nop, op_nop, store_nop ;CB ;NOP
4448instr fetch_nop, op_nop, store_nop ;CC ;NOP
4449instr fetch_nop, op_nop, store_nop ;CD ;NOP
4450instr fetch_nop, op_nop, store_nop ;CE ;NOP
4451instr fetch_nop, op_nop, store_nop ;CF ;NOP
4452instr fetch_nop, op_nop, store_nop ;D0 ;NOP
4453instr fetch_nop, op_nop, store_nop ;D1 ;NOP
4454instr fetch_nop, op_nop, store_nop ;D2 ;NOP
4455instr fetch_nop, op_nop, store_nop ;D3 ;NOP
4456instr fetch_nop, op_nop, store_nop ;D4 ;NOP
4457instr fetch_nop, op_nop, store_nop ;D5 ;NOP
4458instr fetch_nop, op_nop, store_nop ;D6 ;NOP
4459instr fetch_nop, op_nop, store_nop ;D7 ;NOP
4460instr fetch_nop, op_nop, store_nop ;D8 ;NOP
4461instr fetch_nop, op_nop, store_nop ;D9 ;NOP
4462instr fetch_nop, op_nop, store_nop ;DA ;NOP
4463instr fetch_nop, op_nop, store_nop ;DB ;NOP
4464instr fetch_nop, op_nop, store_nop ;DC ;NOP
4465instr fetch_nop, op_nop, store_nop ;DD ;NOP
4466instr fetch_nop, op_nop, store_nop ;DE ;NOP
4467instr fetch_nop, op_nop, store_nop ;DF ;NOP
4468instr fetch_nop, op_nop, store_nop ;E0 ;NOP
4469instr fetch_nop, op_nop, store_nop ;E1 ;NOP
4470instr fetch_nop, op_nop, store_nop ;E2 ;NOP
4471instr fetch_nop, op_nop, store_nop ;E3 ;NOP
4472instr fetch_nop, op_nop, store_nop ;E4 ;NOP
4473instr fetch_nop, op_nop, store_nop ;E5 ;NOP
4474instr fetch_nop, op_nop, store_nop ;E6 ;NOP
4475instr fetch_nop, op_nop, store_nop ;E7 ;NOP
4476instr fetch_nop, op_nop, store_nop ;E8 ;NOP
4477instr fetch_nop, op_nop, store_nop ;E9 ;NOP
4478instr fetch_nop, op_nop, store_nop ;EA ;NOP
4479instr fetch_nop, op_nop, store_nop ;EB ;NOP
4480instr fetch_nop, op_nop, store_nop ;EC ;NOP
4481instr fetch_nop, op_nop, store_nop ;ED ;NOP
4482instr fetch_nop, op_nop, store_nop ;EE ;NOP
4483instr fetch_nop, op_nop, store_nop ;EF ;NOP
4484instr fetch_nop, op_nop, store_nop ;F0 ;NOP
4485instr fetch_nop, op_nop, store_nop ;F1 ;NOP
4486instr fetch_nop, op_nop, store_nop ;F2 ;NOP
4487instr fetch_nop, op_nop, store_nop ;F3 ;NOP
4488instr fetch_nop, op_nop, store_nop ;F4 ;NOP
4489instr fetch_nop, op_nop, store_nop ;F5 ;NOP
4490instr fetch_nop, op_nop, store_nop ;F6 ;NOP
4491instr fetch_nop, op_nop, store_nop ;F7 ;NOP
4492instr fetch_nop, op_nop, store_nop ;F8 ;NOP
4493instr fetch_nop, op_nop, store_nop ;F9 ;NOP
4494instr fetch_nop, op_nop, store_nop ;FA ;NOP
4495instr fetch_nop, op_nop, store_nop ;FB ;NOP
4496instr fetch_nop, op_nop, store_nop ;FC ;NOP
4497instr fetch_nop, op_nop, store_nop ;FD ;NOP
4498instr fetch_nop, op_nop, store_nop ;FE ;NOP
4499instr fetch_nop, op_nop, store_nop ;FF ;NOP
4500#endif
fa9059af
L
4501
4502#endif
4503
4504;----------------------------------------------------------------
4505; Lookup table, stolen from z80ex, Z80 emulation library.
4506; http://z80ex.sourceforge.net/
4507
4508; The S, Z, 5 and 3 bits and the parity of the lookup value
4509
5c8bb361 4510 checkspace PC, 256
623dd899
L
4511
4512 .org (PC+255) & 0xff00
fa9059af 4513; .org opcjmp + 256
623dd899 4514; .org sz53p_table_pos
e7a0f403 4515; .org FLASHEND & 0xff00
4c92af0d 4516; .org 0x1fff & 0xff00
fa9059af
L
4517
4518sz53p_tab:
4519 .db 0x44,0x00,0x00,0x04,0x00,0x04,0x04,0x00
4520 .db 0x08,0x0c,0x0c,0x08,0x0c,0x08,0x08,0x0c
4521 .db 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04
4522 .db 0x0c,0x08,0x08,0x0c,0x08,0x0c,0x0c,0x08
4523 .db 0x20,0x24,0x24,0x20,0x24,0x20,0x20,0x24
4524 .db 0x2c,0x28,0x28,0x2c,0x28,0x2c,0x2c,0x28
4525 .db 0x24,0x20,0x20,0x24,0x20,0x24,0x24,0x20
4526 .db 0x28,0x2c,0x2c,0x28,0x2c,0x28,0x28,0x2c
4527 .db 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04
4528 .db 0x0c,0x08,0x08,0x0c,0x08,0x0c,0x0c,0x08
4529 .db 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00
4530 .db 0x08,0x0c,0x0c,0x08,0x0c,0x08,0x08,0x0c
4531 .db 0x24,0x20,0x20,0x24,0x20,0x24,0x24,0x20
4532 .db 0x28,0x2c,0x2c,0x28,0x2c,0x28,0x28,0x2c
4533 .db 0x20,0x24,0x24,0x20,0x24,0x20,0x20,0x24
4534 .db 0x2c,0x28,0x28,0x2c,0x28,0x2c,0x2c,0x28
4535 .db 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84
4536 .db 0x8c,0x88,0x88,0x8c,0x88,0x8c,0x8c,0x88
4537 .db 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80
4538 .db 0x88,0x8c,0x8c,0x88,0x8c,0x88,0x88,0x8c
4539 .db 0xa4,0xa0,0xa0,0xa4,0xa0,0xa4,0xa4,0xa0
4540 .db 0xa8,0xac,0xac,0xa8,0xac,0xa8,0xa8,0xac
4541 .db 0xa0,0xa4,0xa4,0xa0,0xa4,0xa0,0xa0,0xa4
4542 .db 0xac,0xa8,0xa8,0xac,0xa8,0xac,0xac,0xa8
4543 .db 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80
4544 .db 0x88,0x8c,0x8c,0x88,0x8c,0x88,0x88,0x8c
4545 .db 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84
4546 .db 0x8c,0x88,0x88,0x8c,0x88,0x8c,0x8c,0x88
4547 .db 0xa0,0xa4,0xa4,0xa0,0xa4,0xa0,0xa0,0xa4
4548 .db 0xac,0xa8,0xa8,0xac,0xa8,0xac,0xac,0xa8
4549 .db 0xa4,0xa0,0xa0,0xa4,0xa0,0xa4,0xa4,0xa0
4550 .db 0xa8,0xac,0xac,0xa8,0xac,0xa8,0xa8,0xac
4551
4552; vim:set ts=8 noet nowrap
4553