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