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