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