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