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