]> cloudbase.mooo.com Git - ddt180.git/blob - ddt180.z80
ef1dd6c6138961eb2618ad3178f07b053e4f8258
[ddt180.git] / ddt180.z80
1 ; Disassembled ddtz.com, version "DDT/Z [8101]"
2 ; with modified relocater.
3 ;
4 ; Build steps:
5 ; - Assemble to a .REL file with M80 or a compatible assembler.
6 ; - Use Digital Research Link-80 to generate a .PRL file (op switch).
7 ; - Cut the .PRL header (first 256 byte) end rename the result to DDTZ.COM.
8
9
10 maclib config.inc
11
12 ; Some greneral definitions
13
14 BS equ 08h
15 TAB equ 09h
16 CR equ 0dh
17 LF equ 0ah
18 DEL equ 7fh
19 CNTRX equ 'X'-'@'
20
21 ; CP/M memory layout
22
23 BDOS equ 5
24 TPA equ 0100h
25
26 ; ddtz specific definitions
27
28 STACK_SIZE equ 80 ;ddtz internal stack
29 CONBUF_SIZE equ 80 ;Size of console input buffer
30 BP_CNT equ 12 ;Number of breakpoints
31 BP_SIZE equ 4 ;Size of a breakpoint record
32
33 bitmap_size equ (prog_size+7)/8
34
35 ;-------------------------------------------------------------------------------
36
37 cseg
38 start::
39 ddtz_base::
40 jr reloc
41 nop
42 l0003h:
43 rst 30h ;rst used by ddtz
44 di_or_ei: ;ints enabled/disabled while ddtz is running
45 nop
46 ret
47
48 ;-------------------------------------------------------------------------------
49
50 signon:
51 db 'DDTZ/180'
52 db ' - Version '
53 maclib version.inc
54 defvers
55 dc ' ('
56
57 ;-------------------------------------------------------------------------------
58 ; Clear old position
59
60 cmde_clr:
61 ld (hl),0
62 inc hl
63 dec bc
64 ld a,b
65 or c
66 jr nz,cmde_clr
67
68 ; Determine current position
69
70 reloc:
71 ld bc,(028h-2)
72 ld de,(028h)
73 ld a,i ;get iff2
74 ex af,af'
75 di
76 ld sp,028h ;rst instr needs a minimal stack
77 ld hl,0e9e1h ;opcpdes pop hl/jp (hl)
78 ld (028h),hl
79 rst 028h
80 wearehere:
81 ld (028h-2),bc
82 ld (028h),de
83 ld de,-(wearehere-ddtz_base)
84 add hl,de ; hl:
85
86 ld de,ddtz_base ; de:
87 or a
88 sbc hl,de
89 ex de,hl ; de: reloc offset
90 ld hl,stack
91 add hl,de
92 ld sp,hl
93 ex af,af'
94 push af
95 pop bc
96 bit 2,c
97 jr z,$+3
98 ei
99 ld hl,ddtz_end ;start of reloc bitmap
100 add hl,de
101
102 push hl
103 exx
104 pop hl
105 ld bc,0108h ;init bit counter b (c==reload val)
106 exx
107
108 LD HL,ddtz_base
109 add hl,de ;--> ddtz_base
110 ld bc,prog_size
111 reloc_lp:
112 EXX
113 djnz reloc_nl
114 ld b,c ;reload bit counter
115 LD e,(HL) ;get next 8 relocation bits
116 INC HL
117 reloc_nl:
118 sla e
119 EXX
120 JR NC,reloc_next
121 DEC HL
122 LD A,(HL)
123 ADD A,E
124 LD (HL),A
125 INC HL
126 LD A,(HL)
127 ADC A,D
128 LD (HL),A
129 reloc_next:
130 inc hl
131 dec bc
132 ld a,b
133 or c
134 jr nz,reloc_lp
135
136 ;-------------------------------------------------------------------------------
137
138
139 init::
140 LD SP,stack
141
142 if CPM
143
144 ld hl,(1) ;wboot addr
145 ld de,convec
146 ex de,hl
147 ld b,3
148 vini_l:
149 inc de
150 inc de
151 inc de
152 inc hl
153 ld (hl),e
154 inc hl
155 ld (hl),d
156 inc hl
157 djnz vini_l
158 else
159 xor a
160 dec a
161 daa ; Z80: 099H, x180+: 0F9H
162 cp 99h ; Result on 180 type cpus is F9 here. Thanks Hitachi
163 jr z,ini_z80
164
165 xor a
166 call cinit
167 ld a,1
168 call cinit
169 jr ini_sign
170 ini_z80:
171 ; if ...
172 ; .printx Error: Not yet implemented!
173 ; db "Stop
174 ; endif
175 endif ; CPM
176
177 ini_sign:
178 ld hl,signon
179 call pstr
180 ld hl,ddtz_base
181 call out_hl
182 call pstr_inl
183 dc ' - '
184 ld de,prog_size+bitmap_size-1
185 add hl,de
186 call out_hl
187 call pstr_inl
188 dc ')',CR,LF
189
190 ld a,i
191 ld (reg.i),a
192 ld a,0f3h
193 jp po,l0093h
194 ld a,0fbh
195 l0093h:
196 ld (reg.iff),a
197 call di_or_ei
198 ld hl,ddtz_base
199 ld l,000h
200 ld (reg_sp),hl
201
202 jp mainloop
203
204 ;-------------------------------------------------------------------------------
205
206 if CPM
207
208 convec:
209 const: jp 0 ; return console input status
210 conin: jp 0 ; return console input character
211 conout: jp 0 ; send console output character
212
213 else
214
215 include z180reg.inc
216
217 iobyte equ 3
218
219 max_device equ 3
220
221 ;-------------------------------------------------------------------------------
222
223 ; init device
224 cinit: ; a = device
225 call vector_io_0
226 dw as0init
227 dw rret
228 dw rret
229 dw rret
230
231 ; character input status
232 const: ; return a != 0 if character waiting
233 call vector_io
234 dw as0ista
235 dw null$status
236 dw csio_ista
237 dw null$status
238
239 ; character input
240 conin: ; return a = input char
241 call vector_io
242 dw as0inp
243 dw null$input
244 dw csio_inp
245 dw null$input
246
247 ; character output
248 conout: ; c = output char
249 call vector_io
250 dw as0out
251 dw rret
252 dw csio_out
253 dw rret
254
255 ;-------------------------------------------------------------------------------
256
257 vector_io:
258 ld a,(iobyte)
259 vector_io_0:
260 pop hl
261 cp max_device
262 jr c,exist
263 ld a,max_device ; use null device if a >= max$device
264 exist:
265 call add_hl_a2
266 ld a,(hl)
267 inc hl
268 ld h,(hl)
269 ld l,a
270 jp (hl)
271
272 ;-------------------------------------------------------------------------------
273
274 null$input:
275 ld a,1Ah
276 rret:
277 ret
278 ret$true:
279 or 0FFh
280 ret
281
282 null$status:
283 xor a
284 ret
285
286 ;-------------------------------------------------------------------------------
287 ;
288 ; TC = (f PHI /(2*baudrate*Clock_mode)) - 2
289 ;
290 ; TC = (f PHI / (32 * baudrate)) - 2
291 ;
292 ; Init Serial I/O for console input and output (ASCI1)
293 ;
294
295
296
297 as0init:
298 ld hl,initab0
299 jp ioiniml
300
301 as1init:
302 ld hl,initab1
303 jp ioiniml
304
305
306 ld a,M_MPBT
307 out0 (cntlb1),a
308 ld a,M_RE + M_TE + M_MOD2 ;Rx/Tx enable
309 out0 (cntla1),a
310 ld a,M_RIE
311 out0 (stat1),a ;Enable rx interrupts
312
313 ret ;
314
315
316 initab0:
317 db 1,stat0,0 ;Disable rx/tx interrupts
318 ;Enable baud rate generator
319 db 1,asext0,M_BRGMOD+M_DCD0DIS+M_CTS0DIS
320 db 2,astc0l,low 28, high 28
321 db 1,cntlb0,M_MPBT ;No MP Mode, X16
322 db 1,cntla0,M_RE+M_TE+M_MOD2 ;Rx/Tx enable, 8N1
323 db 0
324
325 initab1:
326 db 1,stat1,0 ;Disable rx/tx ints, disable CTS1
327 db 1,asext1,M_BRGMOD ;Enable baud rate generator
328 db 2,astc1l,low 3, high 3
329 db 1,cntlb1,M_MPBT ;No MP Mode, X16
330 db 1,cntla1,M_RE+M_TE+M_MOD2 ;Rx/Tx enable, 8N1
331 db 0
332
333 ;-------------------------------------------------------------------------------
334
335 ioiniml:
336 push bc
337 xor a
338 ioml_lp:
339 ld b,(hl)
340 inc hl
341 cp b
342 jr z,ioml_e
343
344 ld c,(hl)
345 inc hl
346 otimr
347 jr ioml_lp
348 ioml_e:
349 pop bc
350 ret
351
352 ;-------------------------------------------------------------------------------
353
354 as0ista:
355 in0 a,(stat0)
356 rlca
357 sbc a,a
358 ret
359
360 as1ista:
361 in0 a,(stat1)
362 rlca
363 sbc a,a
364 ret
365
366 as0inp:
367 in0 a,(stat0)
368 rlca
369 jr nc,as0inp
370 in0 a,rdr0
371 ret
372
373 as1inp:
374 in0 a,(stat1)
375 rlca
376 jr nc,as1inp
377 in0 a,rdr1
378 ret
379
380 as0out:
381 in0 a,(stat0)
382 and M_TDRE
383 jr z,as0out
384 out0 (tdr0),c
385 ld a,c
386 ret
387
388 as1out:
389 in0 a,(stat1)
390 and M_TDRE
391 jr z,as1out
392 out0 (tdr1),c
393 ld a,c
394 ret
395
396 ;-------------------------------------------------------------------------------
397
398 csio_ista:
399 csio_inp:
400 csio_out:
401 xor a
402 ret
403
404
405 ld a,0ffh
406 do_csio:
407 push af
408 call csio_wait_te
409 pop af
410 out0 (trdr),a
411 ld a,M_CSIO_TE
412 out0 (cntr),a
413 call csio_wait_te
414 in0 a,(trdr)
415 ret
416
417 csio_wait_te:
418 in0 a,(cntr)
419 and M_CSIO_TE
420 jr nz,csio_wait_te
421 ret
422
423 endif ; CPM
424
425 ;-------------------------------------------------------------------------------
426
427 CMDTAB::
428 ; dw ERROR ;cmd_@ ;examine/substitute the displacement register @
429 ; dw ERROR ;cmd_A ;Assemble
430 dw cmd_B ;Breakpoints display/set/clear
431 dw ERROR ;cmd_C ;trace over Calls
432 dw cmd_D ;Display memory in hex and ascii
433 dw cmd_E ;rElocate debugger
434 dw ERROR ;cmd_F ;specify Filename and command line
435 dw cmd_G ;Go
436 dw cmd_H ;compute Hex and other expressions
437 dw cmd_I ;Input a byte from port
438 dw ERROR ;
439 dw ERROR ;
440 dw cmd_L ;List disassembled code
441 dw cmd_M ;Move memory [and verify]
442 dw ERROR ;
443 dw cmd_O ;Output a byte to port
444 dw ERROR ;
445 dw cmd_Q ;Qery memory for byte string
446 dw cmd_R ;Read binary or hex file
447 dw cmd_S ;Substitute memory
448 dw cmd_T ;Trace
449 dw ERROR ;
450 dw cmd_V ;Verify (compare) two memory areas
451 dw ERROR ;cmd_W ;Write a file to disk
452 dw cmd_X ;eXamine [and substitute] registers
453 dw ERROR ;cmd_Y ;examine [and substitute] Y variables
454 dw cmd_Z ;Zap (fill) memory with a byte string
455
456 ERROR:
457 call pstr_inl
458 dc '?',CR,LF
459 ;fall thru
460 mainloop::
461 ld sp,stack
462 ld hl,(reg.pc)
463 call bp_clr_temporary
464 ld hl,(cmd_rpt)
465 ld de,mainloop
466 push de
467 call cp_hl_de
468 ld a,'>'
469 call outchar
470 call nz,outchar
471 call z,outbl
472 call get_line
473 call skipbl
474 jr z,exe_hl
475 pop hl
476 push hl
477 ld (cmd_rpt),hl
478 inc de
479 sub 'B'
480 jr c,ERROR
481 cp 'Z'+1-'@'
482 jr nc,ERROR
483 ld hl,CMDTAB
484 call add_hl_a2
485 ld a,(hl)
486 inc hl
487 ld h,(hl)
488 ld l,a
489 exe_hl:
490 CALL_HL:
491 jp (hl)
492
493 ;-------------------------------------------------------------------------------
494
495 crlf:
496 call pstr_inl
497 dc CR,LF
498 xor a
499 ld (con_col),a
500 call inchar
501 jr c,mainloop
502 ret
503
504 sub_01d9h:
505 call pstr_inl
506 dc '-'
507 jp neg.hl
508
509 out_hl_dec_neg:
510 push hl
511 call sub_01d9h
512 defb 03eh ;ld a,.. swallow push hl
513 out.hl.dec:
514 push hl
515 ld b,006h
516 call sub_01f9h
517 pop hl
518 call pstr_inl
519 dc '.'
520 l01f3h:
521 call outbl
522 djnz l01f3h
523 ret
524
525 sub_01f9h:
526 dec b
527 push de
528 ld de,10
529 call div_hl_de
530 ld a,h
531 or l
532 call nz,sub_01f9h
533 ld a,e
534 pop de
535 jr out_dgt
536
537 out_hl_neg:
538 push hl
539 call sub_01d9h
540 call out_hl
541 pop hl
542 ret
543
544 out_hl:
545 ld a,h
546 call out_hex
547 ld a,l
548
549 out_hex:
550 push af
551 rra
552 rra
553 rra
554 rra
555 call out_dgt
556 pop af
557
558 out_dgt:
559 or 0f0h
560 daa
561 add a,0a0h
562 adc a,040h
563 jr outchar
564
565 out.bin.w:
566 ld a,h
567 call out.bin.b
568 ld a,l
569 out.bin.b:
570 ld b,8
571 l01c9h:
572 rlca
573 push af
574 and 1
575 call out_dgt
576 pop af
577 djnz l01c9h
578 ld a,'"'
579 jr outchar
580
581 out.ascii:
582 push bc
583 ld c,a
584 res 7,a
585 cp ' '
586 push af
587 call nc,outbl
588 call pstr_inl
589 dc ''''
590 pop af
591 jr nc,l0242h
592 sub 0c0h
593 ld b,a
594 call pstr_inl
595 dc '^'
596 ld a,b
597 l0242h:
598 call outchar
599 cp ''''
600 call z,outchar
601 call pstr_inl
602 dc ''''
603 sla c
604 pop bc
605 ret nc
606 ld a,'.'
607 jr outchar
608
609 outbl6:
610 call outbl2
611 outbl4:
612 call outbl2
613 outbl2:
614 call outbl
615 outbl:
616 ld a,' '
617 outchar:
618 push ix
619 push iy
620 push hl
621 push de
622 push bc
623 push af
624 and 07fh
625 ld c,a
626 call conout
627 ld hl,con_col
628 inc (hl)
629 pop af
630 pop bc
631 pop de
632 pop hl
633 pop iy
634 pop ix
635 ret
636
637 p_goto_col:
638 ld a,(con_col)
639 cp c
640 ret nc
641 ret z
642 call outbl
643 jr p_goto_col
644
645 ;-------------------------------------------------------------------------------
646
647 incharw:
648 call inchar
649 jr nc,incharw
650 ret
651
652 ;-------------------------------------------------------------------------------
653
654 inchar:
655 push ix
656 push hl
657 push de
658 push bc
659 call const
660 and a
661 jr z,inch1
662 call conin
663 scf
664 inch1:
665 pop bc
666 pop de
667 pop hl
668 pop ix
669 ret
670
671 ;-------------------------------------------------------------------------------
672
673 DELC:
674 ld a,b
675 or a
676 ret z
677 call DELC1
678 dec hl
679 dec b
680 ld a,(hl)
681 cp ' '
682 ret nc
683 DELC1:
684 call pstr_inl
685 dc BS,' ',BS
686 ret
687
688 DELL:
689 ld a,b ;
690 or a ;
691 ret z ;
692 call DELC ;
693 jr DELL ;
694
695 ;-------------------------------------------------------------------------------
696
697 get_line:
698 push hl ;
699 ld hl,conbuf ;
700 ld b,0 ;
701 inlnxtch:
702 ld a,b ;
703 cp CONBUF_SIZE ;
704 jr z,inl_e ;
705 call incharw ;
706 cp CR ;
707 jr z,inl_e ;Accept line
708 cp LF ;
709 jr z,inl_e ;Accept line
710
711 cp BS ;
712 jr z,gl_1 ;
713 cp DEL ;
714 jr nz,gl_2 ;
715 gl_1:
716 call DELC ;Delete Char
717 jr inlnxtch ;
718 gl_2:
719 cp CNTRX ;
720 jr nz,gl_3 ;
721 call DELL ;Delete Line
722 jr inlnxtch ;
723 gl_3:
724 cp TAB ;
725 jr nz,gl_4 ;
726 ld a,' ' ;
727 gl_4:
728 ld (hl),a ;
729 cp ' ' ;
730 jr nc,gl_5 ;
731 ld a,'^' ;Controll characters
732 call outchar ;
733 ld a,(hl) ;
734 add a,'@' ;
735 gl_5:
736 call outchar ;
737 inc hl ;
738 inc b ;
739 jr inlnxtch ;
740
741 inl_e:
742 ld (hl),0
743 call CRLF ;
744 ld de,conbuf ;
745 pop hl ;
746 ret ;
747
748 ;-------------------------------------------------------------------------------
749
750 get_char_upper:
751 ld a,(de)
752 toupper:
753 cp 'a'
754 ret c
755 cp 'z'+1
756 ccf
757 ret c
758 and 05fh
759 ret
760
761 ;-------------------------------------------------------------------------------
762
763 skipbl0:
764 inc de
765 skipbl:
766 call get_char_upper
767 cp ' '
768 jr z,skipbl0
769 or a
770 ret
771
772 ;-------------------------------------------------------------------------------
773
774 next_arg:
775 call skipbl
776 cp ','
777 ret nz
778 call skipbl0
779 cp a
780 ret
781
782 assert_eol:
783 call skipbl
784 ret z
785 to_error:
786 jp ERROR
787
788 ;-------------------------------------------------------------------------------
789
790 chk_stack:
791 push hl
792 push de
793 ld hl,0
794 add hl,sp
795 ld de,stack-(STACK_SIZE-28)
796 call cp_hl_de
797 pop de
798 pop hl
799 jr c,to_error
800 ret
801
802 ;-------------------------------------------------------------------------------
803
804 add_hl_a2:
805 add a,a
806 add_hl_a:
807 add a,l
808 ld l,a
809 ret nc
810 inc h
811 ret
812
813 cp_hl_de:
814 and a
815 sbc hl,de
816 add hl,de
817 ret
818
819 ;-------------------------------------------------------------------------------
820
821 lookupch:
822 ld b,0
823 l02f5h:
824 ld a,(hl)
825 and a
826 ret z
827 call get_char_upper
828 cp (hl)
829 jr z,l0300h
830 inc hl
831 inc b
832 jr l02f5h
833 l0300h:
834 scf
835 inc de
836 ret
837
838 sub_0303h:
839 ld hl,t_reg_names
840 ld b,07fh
841 l030ch:
842 inc b
843 ld a,(hl)
844 and a
845 ret z
846 call sub_031ch
847 jr nc,l030ch
848 res 7,b
849 ret
850
851 sub_031ch:
852 push bc
853 push de
854 l031eh:
855 call get_char_upper
856 xor (hl)
857 and 07fh
858 jr nz,l0336h
859 bit 7,(hl)
860 inc hl
861 inc de
862 jr z,l031eh
863 scf
864 bit 7,b
865 call z,sub_060ch
866 jr nc,l0339h
867 pop af
868 scf
869 pop bc
870 ret
871 l0336h:
872 call str_sel_next
873 l0339h:
874 pop de
875 and a
876 pop bc
877 ret
878
879 str_sel:
880 inc b
881 jr str_sel2
882 str_sel1:
883 call str_sel_next
884 str_sel2:
885 djnz str_sel1
886 ret
887
888 str_sel_next:
889 ld a,(hl)
890 and a
891 ret z
892 l0348h:
893 ld a,(hl)
894 inc hl
895 and a
896 ret m
897 jr l0348h
898
899 get_arg_range_target:
900 call get_arg_range
901 push hl
902 push bc
903 call next_arg
904 call get_arg_final
905 ex de,hl
906 pop bc
907 pop hl
908 ret
909
910 sub_035dh:
911 call expr
912 jr c,error0
913 ret
914
915 get_arg_final:
916 call sub_035dh
917 l0366h:
918 jp assert_eol
919
920 get_lastarg_def:
921 call get_arg_def
922 jr l0366h
923
924 get_arg_def:
925 push hl
926 call expr
927 jr c,l0375h
928 ex (sp),hl
929 l0375h:
930 pop hl
931 ret
932
933 sub_0377h:
934 call b_037c_start
935 jr l0366h
936
937 b_037c_start:
938 defb 0e6h ;and a,.. clear carry
939 get_arg_range:
940 scf
941 ex af,af'
942 push bc
943 push hl
944 call expr
945 jr nc,l038ch
946 ex af,af'
947 jr c,error0
948 ex af,af'
949 pop hl
950 defb 03eh ;ld a,.. swallow pop af
951 l038ch:
952 pop af
953 call get_range
954 jr nc,l0398h
955 ex af,af'
956 pop bc
957 ret nc
958 error0:
959 jp ERROR
960 l0398h:
961 pop af
962 ret
963
964 get_range:
965 call next_arg
966 cp 'S'
967 jr nz,l03a2h
968 inc de
969 l03a2h:
970 push hl
971 push af ;'S' flag
972 call expr
973 jr c,l03b8h
974 ld b,h
975 ld c,l
976 pop af
977 pop hl
978 jr z,l03b6h ;'S'?
979 ld a,c
980 sub l
981 ld c,a
982 ld a,b
983 sbc a,h
984 ld b,a
985 inc bc
986 l03b6h:
987 and a
988 ret
989 l03b8h:
990 pop af
991 pop hl
992 jr z,error0 ;'S', but no expression following
993 scf
994 ret
995
996 ;-------------------------------------------------------------------------------
997
998 expr:
999 call skipbl
1000 expr1:
1001 call do_factor
1002 ret c
1003 l0433h:
1004 call do_binary_op
1005 push hl
1006 push bc
1007 call do_factor
1008 pop bc
1009 ex de,hl
1010 ex (sp),hl
1011 jr nc,l0447h
1012 pop de
1013 ld a,b
1014 or c
1015 ret z
1016 jp ERROR
1017
1018 l0447h:
1019 ld a,b
1020 or c
1021 push bc
1022 ret nz
1023 pop bc
1024
1025 doop_add:
1026 add hl,de
1027 l044dh:
1028 pop de
1029 jr l0433h
1030
1031 doop_sub:
1032 and a
1033 sbc hl,de
1034 jr l044dh
1035
1036 doop_mlt:
1037 push bc
1038 ld b,h
1039 ld c,l
1040 ld hl,0
1041 ld a,010h
1042 l045dh:
1043 add hl,hl
1044 ex de,hl
1045 add hl,hl
1046 ex de,hl
1047 jr nc,l0464h
1048 add hl,bc
1049 l0464h:
1050 dec a
1051 jr nz,l045dh
1052 pop bc
1053 jr l044dh
1054
1055 doop_div:
1056 call div_hl_de
1057 jr l044dh
1058
1059 doop_mod:
1060 call div_hl_de
1061 ex de,hl
1062 jr l044dh
1063
1064 ; divide x/y
1065 ; hl: x
1066 ; de: y
1067 ; return:
1068 ; hl: q (x/y)
1069 ; de: r (x%y)
1070
1071 div_hl_de:
1072 push bc
1073 ex de,hl ;de: x
1074 ld b,h ;bc: y
1075 ld c,l
1076 ld hl,0 ;hl: r
1077 ld a,16
1078
1079 ; de: x (x shifted out, q shifted in)
1080 ; bc: y
1081 ; hl: r (initially 0)
1082
1083 div_lp:
1084 ex de,hl
1085 add hl,hl ;x <<= 1
1086 ex de,hl
1087 adc hl,hl ;r <<= 1
1088 inc de
1089 or a
1090 sbc hl,bc
1091 jr nc,div_norestore
1092 dec de
1093 add hl,bc
1094 div_norestore:
1095 dec a
1096 jr nz,div_lp
1097 ex de,hl
1098 pop bc
1099 ret
1100
1101 doop_and:
1102 ld a,h
1103 and d
1104 ld h,a
1105 ld a,l
1106 and e
1107 ld l,a
1108 jr l044dh
1109
1110 doop_or:
1111 ld a,h
1112 or d
1113 ld h,a
1114 ld a,l
1115 or e
1116 ld l,a
1117 jr l044dh
1118
1119 doop_xor:
1120 ld a,h
1121 xor d
1122 ld h,a
1123 ld a,l
1124 xor e
1125 ld l,a
1126 jr l044dh
1127
1128 do_binary_op:
1129 push hl
1130 ld hl,tab_op_a
1131 call lookupch
1132 ld a,b
1133 ld hl,tblf_opa
1134 call add_hl_a2
1135 ld c,(hl)
1136 inc hl
1137 ld b,(hl)
1138 pop hl
1139 ret
1140
1141 tab_op_a:
1142 DB '+-*/%&!#',0
1143
1144 tblf_opa:
1145 dw doop_add
1146 dw doop_sub
1147 dw doop_mlt
1148 dw doop_div
1149 dw doop_mod
1150 dw doop_and
1151 dw doop_or
1152 dw doop_xor
1153 dw 0
1154
1155 ;-------------------------------------------------------------------------------
1156
1157 fact_factor:
1158 call do_factor
1159 ret nc
1160 jp ERROR
1161
1162 do_factor:
1163 call chk_stack
1164 call get.number
1165 ret nc
1166 inc de
1167 ld hl,ddtz_base-1
1168 cp 'T'
1169 ret z
1170 ld hl,(high_load)
1171 cp 'H'
1172 ret z
1173 ld hl,(max_load)
1174 cp 'M'
1175 ret z
1176 ld hl,TPA
1177 cp 'L'
1178 ret z
1179 ld hl,(reg.pc)
1180 cp '$'
1181 ret z
1182 cp '-'
1183 jr z,fact_factneg
1184 cp '~'
1185 jr z,fact_factinv
1186 cp '+'
1187 jr z,fact_factor
1188 cp '^'
1189 jr z,fact_reg.CPU
1190 cp '('
1191 jr z,fact_mem
1192 cp '['
1193 jr z,expr_brckt
1194 cp ''''
1195 jr z,fact_factstring
1196 dec de
1197 scf
1198 ret
1199
1200 ;-------------------------------------------------------------------------------
1201
1202 fact_factstring:
1203 ld hl,0
1204 l054bh:
1205 ld a,(de)
1206 cp ''''
1207 jr z,l0557h
1208 and a
1209 ret z
1210 l0552h:
1211 ld h,l
1212 ld l,a
1213 inc de
1214 jr l054bh
1215 l0557h:
1216 inc de
1217 ld a,(de)
1218 cp ''''
1219 jr z,l0552h
1220 sub '.'
1221 or a
1222 ret nz
1223 inc de
1224 set 7,l
1225 ret
1226
1227 fact_reg.CPU:
1228 call sub_0caeh
1229 jr nc,error1
1230 ld a,(hl)
1231 inc hl
1232 ld h,(hl)
1233 ld l,a
1234 and a
1235 bit 0,c
1236 ret nz
1237 ld h,000h
1238 ret
1239
1240 fact_factinv:
1241 call fact_factor
1242 jr cpl.hl
1243
1244 fact_factneg:
1245 call fact_factor
1246 neg.hl:
1247 dec hl
1248 cpl.hl:
1249 ld a,h
1250 cpl
1251 ld h,a
1252 ld a,l
1253 cpl
1254 ld l,a
1255 ret
1256
1257 fact_mem:
1258 call expr1
1259 jr c,error1
1260 ld a,(de)
1261 cp ')'
1262 jr nz,error1
1263 inc de
1264 ld a,(hl)
1265 inc hl
1266 ld h,(hl)
1267 ld l,a
1268 ld a,(de)
1269 inc de
1270 cp '.'
1271 ret z
1272 dec de
1273 xor a
1274 ld h,a
1275 ret
1276
1277 expr_brckt:
1278 call expr1
1279 jr c,error1
1280 ld a,(de)
1281 cp ']'
1282 inc de
1283 ret z
1284 error1:
1285 jp ERROR
1286
1287 ;-------------------------------------------------------------------------------
1288
1289 get.number:
1290 call get.hexdigit
1291 ret c
1292 push de
1293 test_number:
1294 inc de
1295 call get.hexdigit
1296 jr nc,test_number
1297 pop de
1298 cp '.'
1299 jr z,get_dec_number
1300 cp '"'
1301 jr z,get_bin_number
1302 ld hl,0
1303 next_hexdigit:
1304 call get.hexdigit
1305 jr c,hexnum_done
1306 add hl,hl
1307 add hl,hl
1308 add hl,hl
1309 add hl,hl
1310 call add_hl_a
1311 inc de
1312 jr next_hexdigit
1313
1314 hexnum_done:
1315 xor 'H'
1316 ret nz
1317 inc de
1318 ret
1319
1320 get_bin_number:
1321 ld hl,0
1322 next_bindigit:
1323 call get.bindigit
1324 l05dbh:
1325 inc de
1326 jr c,l05e4h
1327 add hl,hl
1328 call add_hl_a
1329 jr next_bindigit
1330 l05e4h:
1331 cp '"'
1332 jr nz,error11
1333 call get.bindigit
1334 jr nc,l05dbh
1335 or a
1336 ret
1337
1338 get_dec_number:
1339 ld hl,0
1340 next_decdigit:
1341 call get.decdigit
1342 inc de
1343 jr c,decnum_done
1344 push bc
1345 add hl,hl
1346 ld b,h
1347 ld c,l
1348 add hl,hl
1349 add hl,hl
1350 add hl,bc
1351 pop bc
1352 call add_hl_a
1353 jr next_decdigit
1354 decnum_done:
1355 cp '.'
1356 ret z
1357 error11:
1358 jp ERROR
1359
1360 sub_060ch:
1361 call get_char_upper
1362 cp 'Z'+1
1363 jr l0614h
1364
1365 get.hexdigit:
1366 ld a,(de)
1367 hex_digit:
1368 call toupper
1369 cp 'F'+1
1370 l0614h:
1371 ccf
1372 ret c
1373 cp 'A'
1374 jr c,l061eh
1375 sub 'A'-10
1376 ret
1377
1378 get.decdigit:
1379 call get_char_upper
1380 l061eh:
1381 cp '9'+1
1382 jr l0625h
1383
1384 get.bindigit:
1385 call get_char_upper
1386 cp '1'+1
1387 l0625h:
1388 ccf
1389 ret c
1390 cp '0'
1391 ret c
1392 sub '0'
1393 ret
1394
1395 ;-------------------------------------------------------------------------------
1396
1397 p_cpustat0:
1398 call assert_eol
1399 p_cpustat:
1400 call p_f
1401 call outbl2
1402 ld hl,b_06e9_start
1403 ld de,b_0709_start
1404 ld b,6
1405 l063eh:
1406 call p_regs
1407 djnz l063eh
1408 call outbl6
1409 push hl
1410 push de
1411 ld iy,(reg.pc)
1412 call p_disas_instr
1413 pop de
1414 pop hl
1415 call crlf
1416 call p_f2
1417 call outbl2
1418 ld b,7
1419 l065bh:
1420 call p_regs
1421 djnz l065bh
1422 jp crlf
1423
1424 p_f:
1425 ld a,(reg.f)
1426 call p_flags
1427 ld a,(reg.iff)
1428 cp 0f3h
1429 jr z,outbl_1
1430 ld a,'E'
1431 jp outchar
1432 p_f2:
1433 ld a,(reg.f2)
1434 call p_flags
1435 jr outbl_1
1436
1437 p_flags:
1438 push hl
1439 ld hl,t_flag_names+7
1440 ld c,a
1441 ld b,8
1442 fl_loop:
1443 ld a,' '
1444 cp (hl)
1445 ld a,c
1446 rlca
1447 ld c,a
1448 jr z,fl_skip
1449 ld a,(hl)
1450 call c,outchar
1451 call nc,outbl
1452 fl_skip:
1453 dec hl
1454 djnz fl_loop
1455 pop hl
1456 ret
1457
1458 p_regs:
1459 push de
1460 call pstr
1461 call pstr_inl
1462 dc '='
1463 ex (sp),hl
1464 ld e,(hl)
1465 inc hl
1466 ld d,(hl)
1467 inc hl
1468 ld a,(hl)
1469 inc hl
1470 push hl
1471 and a
1472 jr z,l06deh
1473 ex de,hl
1474 ld e,(hl)
1475 inc hl
1476 ld d,(hl)
1477 ex de,hl
1478 call out_hl
1479 jr l06e2h
1480 l06deh:
1481 ld a,(de)
1482 call out_hex
1483 l06e2h:
1484 pop de
1485 pop hl
1486 outbl_1:
1487 jp outbl
1488
1489 b_06e9_start:
1490 DC 'A '
1491 DC 'BC '
1492 DC 'DE '
1493 DC 'HL '
1494 DC 'SP'
1495 DC 'PC'
1496 DC 'a'''
1497 DC 'bc'''
1498 DC 'de'''
1499 DC 'hl'''
1500 DC 'IX'
1501 DC 'IY'
1502 DC 'I'
1503 DB 0
1504
1505 b_0709_start:
1506 dw reg.a
1507 db 000h
1508 dw reg.c
1509 db 001h
1510 dw reg.e
1511 db 001h
1512 dw reg.l
1513 db 001h
1514 dw reg_sp
1515 db 001h
1516 dw reg.pc
1517 db 002h
1518 dw reg.a2
1519 db 000h
1520 dw reg.c2
1521 db 001h
1522 dw reg.e2
1523 db 001h
1524 dw reg.l2
1525 db 001h
1526 dw reg.ix
1527 db 001h
1528 dw reg.iy
1529 db 001h
1530 dw reg.i
1531 db 000h
1532 db 000h
1533
1534 ;-------------------------------------------------------------------------------
1535 ; > E addr
1536 ; relocate debugger to addr
1537 ; > ER addr
1538 ; relocate just below addr
1539 ;
1540 ; Move debugger to given address and restart.
1541 ; New location must not overlap with current location.
1542
1543
1544 cmd_E:
1545 call skipbl
1546 sub 'R'
1547 jr nz,$+3
1548 inc de
1549 push af
1550 call get_arg_final
1551
1552 ld bc,prog_size+bitmap_size
1553 pop af
1554 jr nz,cmde_bottom
1555 sbc hl,bc
1556 cmde_bottom:
1557 ld ix,cmde_clr-ddtz_base
1558 ex de,hl ;de = dst
1559 add ix,de
1560 ld hl,ddtz_base ;hl = src
1561
1562 push hl
1563 or a
1564 sbc hl,de
1565 call c,neg.hl ;abs(distance)
1566 or a
1567 sbc hl,bc
1568 jp c,error
1569 pop hl
1570 push hl
1571 push bc
1572 ldir
1573 pop bc
1574 pop hl
1575 jp (ix)
1576
1577 ;-------------------------------------------------------------------------------
1578 ; > G [startaddr] [;breakp..]
1579 ; Go [to start] [with temporary breakpoints]
1580
1581 cmd_G:
1582 sub a
1583 ld (bp_p_cpu_flag),a
1584 call expr
1585 jr c,l0740h
1586 ld (reg.pc),hl
1587 l0740h:
1588 call skipbl
1589 jr z,user_go0
1590 cp ';'
1591 jp nz,ERROR
1592 inc de
1593 ld a,002h
1594 call bp_enter
1595 user_go0:
1596 jp user_go
1597
1598 ;-------------------------------------------------------------------------------
1599
1600 bpl_init:
1601 ld b,BP_CNT
1602 ld ix,bp_tab
1603 ex (sp),hl
1604 ld (pbl_loop_adr),hl
1605 ex (sp),hl
1606 ret
1607
1608 bpl_next:
1609 ld de,BP_SIZE
1610 push af
1611 add ix,de
1612 pop af
1613 dec b
1614 ret z
1615
1616 ex (sp),hl
1617 ld hl,(pbl_loop_adr)
1618 ex (sp),hl
1619 ret
1620
1621 bp_clr_temporary:
1622 call bpl_init
1623
1624 ld a,(ix+000h)
1625 and 0f1h
1626 ld (ix+000h),a
1627
1628 call bpl_next
1629 ret
1630
1631 ;-------------------------------------------------------------------------------
1632 ; > B
1633 ; display all breakpoints
1634 ; > B breakp [breakp..]
1635 ; set breakpoints
1636 ; > BX
1637 ; clear all breakpoints
1638 ; > BX breakp [breakp..]
1639 ; clear breakpoints
1640 ;
1641 ; breakp can be any valid expression
1642
1643 cmd_B:
1644 call skipbl
1645 jr z,bp_print
1646 inc de
1647 cp 'X'
1648 jr z,bp_clr0
1649 dec de
1650 ld a,001h
1651 jp bp_enter
1652
1653 bp_clr0:
1654 call skipbl
1655 jr z,bp_clr_all
1656 bp_clr_next:
1657 call expr
1658 jp c,assert_eol
1659 push de
1660 call bp_clr
1661 pop de
1662 call next_arg
1663 jr bp_clr_next
1664
1665 bp_clr_all:
1666 scf
1667 bp_clr:
1668 call bpl_init
1669
1670 push af
1671 jr c,l07a7h
1672 ld e,(ix+002h)
1673 ld d,(ix+003h)
1674 call cp_hl_de
1675 jr nz,l07aeh
1676 l07a7h:
1677 ld (ix+000h),000h
1678 l07aeh:
1679 pop af
1680 call bpl_next
1681 ret
1682
1683 bp_print:
1684 ld c,0
1685 call bpl_init
1686
1687 bit 0,(ix+000h)
1688 jr z,bp_pr_cont
1689 ld l,(ix+002h)
1690 ld h,(ix+003h)
1691 call out_hl
1692 call outbl2
1693 inc c
1694 bp_pr_cont:
1695 call bpl_next
1696 ld a,c
1697 or a
1698 call nz,crlf
1699 ret
1700
1701 ;-------------------------------------------------------------------------------
1702 ; Add break points to list
1703 ; A = 1 Permanent (B command)
1704 ; A = 2 Temporary (G command)
1705
1706 bp_enter:
1707 ld b,a
1708 call skipbl
1709 ret z
1710
1711 push bc
1712 call expr
1713 jr c,error12
1714 pop bc
1715 bit 0,b
1716 push bc
1717 push de
1718 push hl
1719 call nz,bp_clr
1720 pop hl
1721 call bp_get_freeslot
1722 pop de
1723 ld (ix+002h),l
1724 ld (ix+003h),h
1725 call next_arg
1726 pop af
1727 ld (ix+000h),a
1728 and 00fh
1729 jr bp_enter
1730
1731 bp_get_freeslot:
1732 call bpl_init
1733
1734 ld a,(ix+000h)
1735 and 00fh
1736 ret z
1737
1738 call bpl_next
1739 error12
1740 jp ERROR
1741
1742
1743 ;-------------------------------------------------------------------------------
1744 ; Breakpoint handling routine.
1745
1746 bpddtz:
1747 ld (reg.l),hl
1748 pop hl
1749 dec hl
1750 ld (reg.pc),hl
1751 ld (reg_sp),sp
1752 ld sp,reg.l
1753 push de
1754 push bc
1755 push af
1756 push ix
1757 push iy
1758 ld a,i
1759 call di_or_ei
1760 ld h,a
1761 ld l,000h
1762 push hl
1763 ld a,0f3h ; EI
1764 jp po,l08dfh
1765 ld a,0fbh ; DI
1766 l08dfh:
1767 ld (reg.iff),a
1768 ex af,af'
1769 push af
1770 exx
1771 push bc
1772 push de
1773 push hl
1774 call bp_restore_mem
1775 ld a,(b_21e2_start)
1776 dec a
1777 jr z,l090bh
1778 call inchar ;Keyboard hit?
1779 jr c,do_break ;yes
1780 call sub_0913h
1781 and a
1782 jp z,user_go
1783 and 083h
1784 jp z,l2151h
1785 do_break:
1786 call bp_clr_temporary
1787 call p_cpustat
1788 jp mainloop
1789
1790 l090bh:
1791 ld (b_21e2_start),a
1792 ld c,007h
1793 jp l0a41h
1794
1795 sub_0913h:
1796 ld a,080h
1797 ex af,af'
1798 sub a
1799 ld (bp_p_cpu_flag),a
1800 call bpl_init
1801
1802 ld a,(ix+000h)
1803 and 007h
1804 jr z,l0938h
1805 ld e,(ix+002h)
1806 ld d,(ix+003h)
1807 ld hl,(reg.pc)
1808 call cp_hl_de
1809 jr nz,l0938h
1810 ex af,af'
1811 res 7,a
1812 or (ix+000h)
1813 ex af,af'
1814 l0938h:
1815 call bpl_next
1816 ex af,af'
1817 ret
1818
1819 bp_restore_mem:
1820 call bpl_init
1821
1822 bit 5,(ix+000h)
1823 res 5,(ix+000h)
1824 jr z,l099ah
1825 ld l,(ix+002h)
1826 ld h,(ix+003h)
1827 ld a,(l0003h)
1828 cp (hl)
1829 jr nz,l099ah
1830 ld a,(ix+001h)
1831 ld (hl),a
1832 l099ah:
1833 res 3,(ix+000h)
1834
1835 call bpl_next
1836 ret
1837
1838 bp_tst_@pc:
1839 call bpl_init
1840
1841 ld a,(ix+000h)
1842 and 003h
1843 jr z,bp_tst_e
1844 ld e,(ix+002h)
1845 ld d,(ix+003h)
1846 ld hl,(reg.pc)
1847 call cp_hl_de
1848 ret z
1849 bp_tst_e:
1850 call bpl_next
1851 sub a
1852 inc a
1853 ret
1854
1855 bp_trace_enter:
1856 call bp_get_freeslot
1857 ld (ix+002h),l
1858 ld (ix+003h),h
1859 ld a,(b_21e2_start)
1860 and a
1861 ld a,008h
1862 jr nz,bp_t_e
1863 rra
1864 bp_t_e:
1865 ld (ix+000h),a
1866 ret
1867
1868 bp_set_to_mem:
1869 call bpl_init
1870
1871 ld a,(ix+000h)
1872 and c
1873 jr z,l0a1dh
1874 set 5,(ix+000h)
1875 ld l,(ix+002h)
1876 ld h,(ix+003h)
1877 ld a,(hl)
1878 ld (ix+001h),a
1879 ld a,(l0003h)
1880 ld (hl),a
1881 and 038h
1882 ld h,000h
1883 ld l,a
1884 ld (hl),0c3h
1885 inc hl
1886 ld de,bpddtz
1887 ld (hl),e
1888 inc hl
1889 ld (hl),d
1890 l0a1dh:
1891
1892 call bpl_next
1893 ret
1894
1895 ;-------------------------------------------------------------------------------
1896
1897 user_go:
1898 sub a
1899 ld (b_21e2_start),a
1900 ld a,(bp_p_cpu_flag)
1901 and a
1902 call nz,p_cpustat
1903 call bp_tst_@pc
1904 ld c,007h
1905 jr nz,l0a41h
1906 ld a,001h
1907 ld (b_21e2_start),a
1908 call tc_set_bp
1909 ld c,008h
1910 l0a41h:
1911 call bp_set_to_mem
1912 ld sp,reg.l2
1913 pop hl
1914 pop de
1915 pop bc
1916 pop af
1917 exx
1918 ex af,af'
1919 pop af
1920 ld i,a
1921 pop iy
1922 pop ix
1923 pop af
1924 pop bc
1925 pop de
1926 pop hl
1927 ld sp,(reg_sp)
1928 jp reg.iff
1929
1930 ;-------------------------------------------------------------------------------
1931 ; > Y
1932 ; examine all Y variables
1933 ; > Y[0..9]
1934 ; examine (and substitute) an Y variable
1935
1936
1937 ;-------------------------------------------------------------------------------
1938 ; > X
1939 ; eXamine (display) all cpu registers and
1940 ; the instruction at the current program counter
1941 ; > X register
1942 ; eXamine (and substitute) a register
1943
1944
1945 cmd_X:
1946 call skipbl
1947 call sub_0caeh
1948 jp nc,p_cpustat0
1949 call assert_eol
1950 ld a,b
1951 cp 25
1952 jr z,l0c5fh
1953 cp 26
1954 jr z,l0c4fh
1955 ex de,hl
1956 ld hl,t_reg_names
1957 call pstr_sel
1958 call l0c33h
1959
1960 call outbl
1961 push de
1962 push bc
1963 call get_line
1964 call skipbl
1965 jr z,l0c30h
1966 call get_arg_final
1967 ex de,hl
1968 pop bc
1969 pop hl
1970 ld (hl),e
1971 bit 0,c
1972 ret z
1973 inc hl
1974 ld (hl),d
1975 ret
1976 l0c30h:
1977 pop af
1978 pop hl
1979 ret
1980
1981 l0c33h:
1982 call pstr_inl
1983 dc '='
1984 ld a,(de)
1985 bit 0,c
1986 jp z,out_hex
1987 ld l,a
1988 inc de
1989 ld a,(de)
1990 dec de
1991 ld h,a
1992 jp out_hl
1993
1994 l0c4fh:
1995 call p_f
1996 ld a,0f3h
1997 ld (reg.iff),a
1998 scf
1999 call sub_0c6ah
2000 ld (reg.f),a
2001 ret
2002 l0c5fh:
2003 call p_f2
2004 and a
2005 call sub_0c6ah
2006 ld (reg.f2),a
2007 ret
2008
2009 sub_0c6ah:
2010 push af
2011 call outbl
2012 call assert_eol
2013 call get_line
2014 pop af
2015 ex af,af'
2016 ld b,0
2017 l0c76h:
2018 call skipbl
2019 ld a,b
2020 ret z
2021 push bc
2022 ld hl,t_flag_names
2023 call lookupch
2024 jp nc,ERROR
2025 inc b
2026 xor a
2027 scf
2028 nxt_f:
2029 rla
2030 djnz nxt_f
2031 pop bc
2032 jr c,l0c97h
2033 or b
2034 ld b,a
2035 jr l0c76h
2036
2037 l0c97h:
2038 ex af,af'
2039 jp nc,ERROR
2040 ex af,af'
2041 ld a,0fbh
2042 ld (reg.iff),a
2043 jr l0c76h
2044
2045 t_flag_names:
2046 db 'CNV H ZSE',0
2047
2048 sub_0caeh:
2049 call sub_0303h
2050 ret nc
2051 ld a,b
2052 add a,b
2053 add a,b
2054 ld hl,b_0cfa_start
2055 call add_hl_a
2056 ld c,(hl)
2057 inc hl
2058 ld a,(hl)
2059 inc hl
2060 ld h,(hl)
2061 ld l,a
2062 scf
2063 ret
2064
2065 t_reg_names:
2066 DC 'BC''' ;0
2067 DC 'DE''' ;1
2068 DC 'HL''' ;2
2069 DC 'BC' ;3
2070 DC 'DE' ;4
2071 DC 'HL' ;5
2072 DC 'A''' ;6
2073 DC 'B''' ;7
2074 DC 'C''' ;8
2075 DC 'D''' ;9
2076 DC 'E''' ;10
2077 DC 'H''' ;11
2078 DC 'L''' ;12
2079 DC 'A' ;13
2080 DC 'B' ;14
2081 DC 'C' ;15
2082 DC 'D' ;16
2083 DC 'E' ;17
2084 DC 'H' ;18
2085 DC 'L' ;19
2086 DC 'IX' ;20
2087 DC 'IY' ;21
2088 DC 'SP' ;22
2089 DC 'PC' ;23
2090 DC 'I' ;24
2091 DC 'F''' ;25
2092 DC 'F' ;26
2093 DB 0
2094
2095 b_0cfa_start:
2096 db 003h
2097 dw reg.c2
2098 db 003h
2099 dw reg.e2
2100 db 003h
2101 dw reg.l2
2102 db 003h
2103 dw reg.c
2104 db 003h
2105 dw reg.e
2106 db 003h
2107 dw reg.l
2108 db 000h
2109 dw reg.a2
2110 db 000h
2111 dw reg.b2
2112 db 000h
2113 dw reg.c2
2114 db 000h
2115 dw reg.d2
2116 db 000h
2117 dw reg.e2
2118 db 000h
2119 dw reg.h2
2120 db 000h
2121 dw reg.l2
2122 db 000h
2123 dw reg.a
2124 db 000h
2125 dw reg.b
2126 db 000h
2127 dw reg.c
2128 db 000h
2129 dw reg.d
2130 db 000h
2131 dw reg.e
2132 db 000h
2133 dw reg.h
2134 db 000h
2135 dw reg.l
2136 db 003h
2137 dw reg.ix
2138 db 003h
2139 dw reg.iy
2140 db 003h
2141 dw reg_sp
2142 db 003h
2143 dw reg.pc
2144 db 000h
2145 dw reg.i
2146 db 000h
2147 dw reg.f2
2148 db 000h
2149 dw reg.f
2150
2151 ;-------------------------------------------------------------------------------
2152 ; > S [startaddr]
2153 ; Substitute memory
2154
2155 cmd_S:
2156 ld hl,(last_S)
2157 call get_lastarg_def
2158 l0d60h:
2159 ld (last_S),hl
2160 call out_hl
2161 call outbl
2162 ld a,(hl)
2163 call out_hex
2164 call outbl2
2165 call get_line
2166 call skipbl
2167 inc hl
2168 jr z,l0d60h
2169 dec hl
2170 inc de
2171 cp '.'
2172 jr nz,cmds_dash
2173 call get_char_upper
2174 or a
2175 jr nz,l0d8ah
2176 ret
2177 cmds_dash:
2178 jp z,assert_eol
2179 cp '-'
2180 jr nz,l0d8ah
2181 call get_char_upper
2182 or a
2183 dec hl
2184 jr z,l0d60h
2185 inc hl
2186 l0d8ah:
2187 dec de
2188 call sub_0ef8h
2189 jr l0d60h
2190
2191 ;-------------------------------------------------------------------------------
2192 ; > @
2193 ; examine (substitute) displacement register @
2194
2195 ;cmd_@:
2196
2197 ;-------------------------------------------------------------------------------
2198 ; >>I [port]
2199 ; Input a byte from port
2200
2201 cmd_I:
2202 ld (cmd_rpt),hl
2203 ld hl,(last_I)
2204 call get_lastarg_def
2205 ld (last_I),hl
2206 ld b,h
2207 ld c,l
2208 in a,(c)
2209 push af
2210 call out_hex
2211 call outbl4
2212 pop af
2213 call out.bin.b
2214 jp crlf
2215
2216 ;-------------------------------------------------------------------------------
2217 ; >>O [byte] [port]
2218 ; Output a byte to a port
2219
2220 cmd_O:
2221 ld (cmd_rpt),hl
2222 ld hl,(last_O_val)
2223 call get_arg_def
2224 ld a,l
2225 ld (last_O_val),a
2226 push af
2227 call next_arg
2228 ld hl,(last_O_addr)
2229 call get_lastarg_def
2230 ld (last_O_addr),hl
2231 ld b,h
2232 ld c,l
2233 pop af
2234 out (c),a
2235 ret
2236
2237 ;-------------------------------------------------------------------------------
2238 ; > V startaddr endaddr targetaddr
2239 ; Verify (compare) two memory areas
2240
2241 cmd_V:
2242 call get_arg_range_target
2243 l0dedh:
2244 push bc
2245 ld a,(de)
2246 ld b,(hl)
2247 cp b
2248 jr z,l0e10h
2249 ld c,a
2250 call out_hl
2251 call outbl
2252 ld a,b
2253 call out_hex
2254 call outbl2
2255 ld a,c
2256 call out_hex
2257 call outbl
2258 ex de,hl
2259 call out_hl
2260 ex de,hl
2261 call crlf
2262 l0e10h:
2263 pop bc
2264 inc de
2265 cpi
2266 jp pe,l0dedh
2267 ret
2268
2269 ;-------------------------------------------------------------------------------
2270 ; > M startaddr endaddr destaddr
2271 ; Move memory
2272
2273 cmd_M:
2274 call get_arg_range_target
2275 call cp_hl_de
2276 jr nc,cmdm_up
2277 add hl,bc
2278 ex de,hl
2279 add hl,bc
2280 ex de,hl
2281 dec hl
2282 dec de
2283 lddr
2284 ret
2285 cmdm_up:
2286 ldir
2287 ret
2288
2289 ;-------------------------------------------------------------------------------
2290 ; > H
2291 ; display Highest load address of last filed loaded, Maximum "High"
2292 ; off all loaded files, and Top address of available memory
2293 ; > H expression
2294 ; evaluate expression and display result in hex, decimal and other formats
2295
2296 cmd_H:
2297 call expr
2298 jp c,p_max_high0
2299 call assert_eol
2300 call out_hl
2301 call outbl2
2302 call out_hl_neg
2303 call outbl4
2304 call out.hl.dec
2305 call outbl2
2306 call out_hl_dec_neg
2307 call outbl4
2308 call out.bin.w
2309 call outbl2
2310 ld a,l
2311 call out.ascii
2312 jp crlf
2313
2314 ;-------------------------------------------------------------------------------
2315 ; > Q[J] startaddr endaddr bytes
2316 ; Query memory for a byte string [Justified]
2317
2318 cmd_Q:
2319 call get_arg_range
2320 push bc
2321 push hl
2322 call sub_0ee6h
2323 pop hl
2324 l0e96h:
2325 push hl
2326 push de
2327 push bc
2328 l0edah:
2329 ld a,(de)
2330 cp (hl)
2331 jr nz,l0ee2h
2332 inc de
2333 inc hl
2334 djnz l0edah
2335 l0ee2h:
2336 pop bc
2337 pop de
2338 pop hl
2339 jr nz,l0eb0h
2340 push bc
2341 ld bc,16
2342 and a ;clear carry
2343 call sub_0f58h
2344 pop bc
2345 l0eb0h:
2346 inc hl
2347 ex (sp),hl
2348 dec hl
2349 ld a,h
2350 or l
2351 ex (sp),hl
2352 jr nz,l0e96h
2353 pop bc
2354 ret
2355
2356 ;-------------------------------------------------------------------------------
2357 ; > Z startaddr endaddr bytes
2358 ; Zap (fill) memory with a byte string
2359
2360 cmd_Z:
2361 call get_arg_range
2362 push bc
2363 push hl
2364 call sub_0ee6h
2365 ld a,b
2366 pop hl
2367 pop bc
2368 push hl
2369 ex de,hl
2370 l0ec7h:
2371 ldi
2372 jp po,l0ed3h
2373 dec a
2374 jr nz,l0ec7h
2375 pop hl
2376 ldir
2377 ret
2378 l0ed3h:
2379 pop hl
2380 ret
2381
2382 sub_0ee6h:
2383 ld hl,conbuf
2384 call sub_0ef7h
2385 ld de,conbuf
2386 and a
2387 sbc hl,de
2388 ld b,l
2389 ret nz
2390 jp ERROR
2391
2392 sub_0ef7h: ;from cmd_Q, cmd_Z
2393 db 0e6h ;and 037h (clear carry)
2394 sub_0ef8h: ;from cmd_S
2395 scf
2396 l0ef9h:
2397 push af
2398 call next_arg
2399 cp ''''
2400 jr z,l0f1eh
2401 push hl
2402 call expr
2403 ld a,l
2404 pop hl
2405 jr c,l0f42h
2406 ld (hl),a
2407 inc hl
2408 jr l0f3ah
2409 l0f1eh:
2410 inc de
2411 ld a,(de)
2412 cp ''''
2413 jr z,l0f2bh
2414 or a
2415 jr z,l0f42h
2416 l0f27h:
2417 ld (hl),a
2418 inc hl
2419 jr l0f1eh
2420 l0f2bh:
2421 inc de
2422 ld a,(de)
2423 cp ''''
2424 jr z,l0f27h
2425 cp '.'
2426 jr nz,l0f3ah
2427 inc de
2428 dec hl
2429 set 7,(hl)
2430 inc hl
2431 l0f3ah:
2432 pop af
2433 jr nc,l0ef9h
2434 ld (last_S),hl
2435 jr l0ef9h
2436 l0f42h:
2437 pop af
2438 ret nc
2439 ld (last_S),hl
2440 ret
2441
2442 ;-------------------------------------------------------------------------------
2443 ; >>D [startaddr] [endaddr]
2444 ; Display memory in hex and ASCII
2445
2446 cmd_D:
2447 ld (cmd_rpt),hl
2448 ld hl,(last_D)
2449 ld bc,128
2450 call sub_0377h
2451 scf
2452 sub_0f58h:
2453 push bc
2454 push de
2455 push hl
2456 push af
2457 l0f5ch:
2458 call out_hl
2459 call outbl2
2460 ld de,0
2461 l0f68h:
2462 ld a,(hl)
2463 inc hl
2464 call out_hex
2465 call outbl
2466 dec bc
2467 inc e
2468 ld a,e
2469 cp 010h
2470 jr z,l0f80h
2471 and 003h
2472 call z,outbl
2473 ld a,b
2474 or c
2475 jr nz,l0f68h
2476 l0f80h:
2477 call outbl
2478 and a
2479 sbc hl,de
2480 l0f86h:
2481 ld a,(hl)
2482 call sub_0fa3h
2483 call outchar
2484 inc hl
2485 dec e
2486 jr nz,l0f86h
2487 pop af
2488 push af
2489 jr nc,l0f97h
2490 ld (last_D),hl
2491 l0f97h:
2492 call crlf
2493 ld a,b
2494 or c
2495 jr nz,l0f5ch
2496 pop af
2497 pop hl
2498 pop de
2499 pop bc
2500 ret
2501
2502 sub_0fa3h:
2503 and 07fh
2504 cp 07fh
2505 jr z,l0fach
2506 cp ' '
2507 ret nc
2508 l0fach:
2509 ld a,'.'
2510 ret
2511
2512 ;-------------------------------------------------------------------------------
2513 ; > Fcommandline
2514 ; specifiy filenames and command line
2515
2516 ;cmd_F:
2517
2518 ;-------------------------------------------------------------------------------
2519 ; > R [displacement]
2520 ; Read Intel Hex File from console [add displacement]
2521
2522 cmd_R:
2523 ld hl,0
2524 call get_lastarg_def ;get offset from command line
2525 push hl
2526 ld hl,0
2527 ld (high_load),hl
2528 w_recstart:
2529 call i.getchar
2530 jr z,rdhex_done
2531 cp ':'
2532 jr nz,w_recstart
2533 ld c,0 ;init checksum
2534 call i.gethexbyte ;record len
2535 ld b,a
2536 call i.gethexbyte ;address high
2537 ld h,a
2538 call i.gethexbyte ;address low
2539 ld l,a
2540 call i.gethexbyte ;record type (ignored)
2541 ld a,b
2542 and a ;record len == 0?
2543 jr z,rdhex_done
2544 l16c6h:
2545 call i.gethexbyte
2546 pop de ;offset
2547 push de
2548 push hl
2549 add hl,de
2550 call i.storebyte
2551 pop hl
2552 inc hl
2553 djnz l16c6h ;repeat for record len
2554 call i.gethexbyte ;checksum
2555 ld a,c
2556 and a
2557 jr nz,error2 ;exit if checksum error
2558 jr w_recstart ;next record
2559
2560 rdhex_done:
2561 pop hl
2562 call i.gethexbyte
2563 jp p_max_high
2564
2565 i.gethexbyte:
2566 call sub_16f6h
2567 rlca
2568 rlca
2569 rlca
2570 rlca
2571 ld d,a
2572 call sub_16f6h
2573 add a,d
2574 ld d,a
2575 add a,c
2576 ld c,a
2577 ld a,d
2578 ret
2579
2580 sub_16f6h:
2581 call i.getchar
2582 jr z,error2
2583 call hex_digit
2584 ret nc
2585 error2:
2586 jp ERROR
2587
2588 i.getchar:
2589 call incharw
2590 cp 01ah
2591 ret
2592
2593 i.storebyte:
2594 push af
2595 push de
2596 ld de,TPA ;lowest allowed load address
2597 call cp_hl_de
2598 jr c,error2
2599 ld de,(BDOS+1) ;highest allowed load address
2600 call cp_hl_de
2601 jr nc,error2
2602 ld de,(high_load)
2603 call cp_hl_de
2604 jr c,l1157h
2605 ld (high_load),hl
2606 l1157h:
2607 ld de,(max_load)
2608 call cp_hl_de
2609 jr c,l1163h
2610 ld (max_load),hl
2611 l1163h:
2612 pop de
2613 pop af
2614 ld (hl),a ;store byte
2615 ret
2616
2617 ;-------------------------------------------------------------------------------
2618
2619 p_max_high0:
2620 call assert_eol
2621 p_max_high:
2622 call pstr_inl
2623 DC 'High = '
2624 ld hl,(high_load)
2625 call out_hl
2626 call pstr_inl
2627 DC ' Max = '
2628 ld hl,(max_load)
2629 call out_hl
2630 call pstr_inl
2631 DC ' Top = '
2632 ld hl,ddtz_base-1
2633 call out_hl
2634 jp crlf
2635
2636 ;-------------------------------------------------------------------------------
2637 ; > Wstartaddr endaddr
2638 ; Write a file to disk
2639
2640 ;cmd_W:
2641
2642 ;-------------------------------------------------------------------------------
2643 ; > A [startaddr]
2644 ; Assemble Zilog Z180 mnemonics
2645
2646 ;cmd_A:
2647
2648 ;-------------------------------------------------------------------------------
2649 ; >>L [startaddr] [endaddr]
2650 ; List disassembled code
2651
2652 cmd_L:
2653 ld (cmd_rpt),hl
2654 call expr
2655 jr nc,l18dbh
2656 ld hl,(last_L)
2657 l18dbh:
2658 call next_arg
2659 call get_range
2660 jr nc,l1905h
2661 call assert_eol
2662 ld b,16
2663 l18ebh:
2664 push bc
2665 call cmdl_p_line
2666 pop bc
2667 djnz l18ebh
2668 ret
2669
2670 l1905h:
2671 call assert_eol
2672 ld d,h
2673 ld e,l
2674 add hl,bc
2675 ex de,hl
2676 l190fh:
2677 push de
2678 call cmdl_p_line
2679 pop de
2680 call cp_hl_de
2681 jr c,l190fh
2682 ret
2683
2684 ;-------------------------------------------------------------------------------
2685
2686 cmdl_p_line:
2687 push hl
2688 call out_hl
2689 call outbl2
2690 sub a
2691 ld (con_col),a
2692 push hl
2693 pop iy
2694 call p_disas_instr
2695 call crlf
2696 pop hl
2697 ld c,b
2698 ld b,0
2699 add hl,bc
2700 ld (last_L),hl
2701 ret
2702
2703 ;-------------------------------------------------------------------------------
2704
2705 p_disas_instr:
2706 call disas_get_instrlen
2707 jr nc,l197fh
2708 push bc
2709 ld a,(con_col)
2710 add a,5
2711 ld c,a
2712 call pstr ;print mnemonic
2713 call p_goto_col
2714 call pr_instr_args ;print arguments
2715 pop bc
2716 scf
2717 ret
2718
2719 l197fh:
2720 call pstr_inl
2721 DC '???'
2722 ld b,1
2723 sub a
2724 ret
2725
2726 disas_get_instrlen:
2727 sub a
2728 ld (isprefix_ixiy),a
2729 ld a,(iy+000h)
2730 cp 0edh
2731 jr z,disas_pfx.ED
2732 cp 0ddh
2733 jr z,l19abh
2734 cp 0fdh
2735 jr z,l19afh
2736 sub_19a0h:
2737 ld a,(iy+000h)
2738 cp 0cbh
2739 jr z,disas_pfx.CB
2740 jr disas_nopfx
2741 l19abh:
2742 ld a,1
2743 jr l19b1h
2744 l19afh:
2745 ld a,2
2746 l19b1h:
2747 ld (isprefix_ixiy),a
2748 call disas_pfx.DDFD
2749 ret nc
2750 push bc
2751 call sub_19a0h
2752 pop af
2753 add a,b
2754 ld b,a
2755 scf
2756 ret
2757
2758 ;-------------------------------------------------------------------------------
2759
2760 disas_nopfx:
2761 ld hl,b_1b54_start ;2 byte opcodes
2762 call lookup_op_arg
2763 ld b,2
2764 ret c
2765 ld hl,b_1ab6_start ;1 byte opcodes (no parameters)
2766 call lookup_op
2767 ld b,1
2768 ret c
2769 ld hl,b_1ad1_start ;1 byte opcodes
2770 call lookup_op_arg
2771 ld b,1
2772 ret c
2773 ld hl,b_1b9b_start ;3 byte opcodes
2774 call lookup_op_arg
2775 ld b,3
2776 ret
2777
2778 ;-------------------------------------------------------------------------------
2779
2780 disas_pfx.ED:
2781 inc iy
2782 ld hl,l228bh
2783 call lookup_op_arg
2784 ld b,3
2785 ret c
2786 ld hl,b_1c40_start
2787 call lookup_op_arg
2788 ld b,4
2789 ret c
2790
2791 ld hl,b_1bc9_start ;1 byte opcode, no arguments
2792 call lookup_op
2793 jr c,da_ed1
2794
2795 ld hl,b_1bf4_start
2796 call lookup_op_arg
2797 ret nc
2798
2799 ld a,e
2800 cp a_noarg
2801 jr nz,da_ed0
2802 ld c,(iy+0)
2803 ld a,c
2804 rra
2805 and 0ch
2806 ld b,a
2807 ld a,c
2808 and 03h
2809 call str_sel_ab
2810
2811 da_ed0:
2812 scf
2813 da_ed1:
2814 ld b,2
2815 ret
2816
2817 ;-------------------------------------------------------------------------------
2818
2819 disas_pfx.CB:
2820 push iy
2821 inc iy
2822 ld a,(isprefix_ixiy)
2823 and a
2824 jr z,l1a42h
2825 inc iy
2826 l1a42h:
2827 ld hl,b_1c55_start
2828 call lookup_op_arg
2829 pop iy
2830 ld b,2
2831 ret
2832
2833 ;-------------------------------------------------------------------------------
2834
2835 disas_pfx.DDFD:
2836 inc iy
2837 ld hl,b_19ef_start
2838 call test_DDFD
2839 ld b,002h
2840 ret c
2841 ld hl,l1a0ah
2842 call test_DDFD
2843 ld b,001h
2844 ret c
2845 ld a,(iy+000h)
2846 cp 0cbh
2847 jr nz,l19edh
2848 ld a,(iy+002h)
2849 cp 036h
2850 ret z
2851 and 007h
2852 cp 006h
2853 jr nz,l19edh
2854 ld b,002h
2855 scf
2856 ret
2857 l19edh:
2858 and a
2859 ret
2860
2861 ;-------------------------------------------------------------------------------
2862 ; DD/FD 3 byte (ix+d)/(iy+d)
2863 b_19ef_start:
2864 db 034h
2865 db 035h
2866 db 036h
2867 db 046h
2868 db 04eh
2869 db 056h
2870 db 05eh
2871 db 066h
2872 db 06eh
2873 db 070h
2874 db 071h
2875 db 072h
2876 db 073h
2877 db 074h
2878 db 075h
2879 db 077h
2880 db 07eh
2881 db 086h
2882 db 08eh
2883 db 096h
2884 db 09eh
2885 db 0a6h
2886 db 0aeh
2887 db 0b6h
2888 db 0beh
2889 db 0
2890
2891 ; DD/FD 2 byte
2892 l1a0ah:
2893 db 009h
2894 db 019h
2895 db 021h
2896 db 022h
2897 db 023h
2898 db 029h
2899 db 02ah
2900 db 02bh
2901 db 039h
2902 db 0e1h
2903 db 0e3h
2904 db 0e5h
2905 db 0e9h
2906 db 0f9h
2907 db 0
2908
2909 ;-------------------------------------------------------------------------------
2910
2911 test_DDFD:
2912 ld a,(hl)
2913 and a
2914 ret z
2915 inc hl
2916 cp (iy+000h)
2917 jr nz,test_DDFD
2918 scf
2919 ret
2920
2921 lookup_op:
2922 ld a,(hl)
2923 inc hl
2924 cp 0ffh
2925 ret z
2926 cp (iy+000h)
2927 jr z,l1a7fh
2928 inc hl
2929 jr lookup_op
2930 l1a7fh:
2931 ld b,(hl)
2932 ld e,a_noarg
2933 jr get_mnemonic
2934
2935 lookup_op_arg:
2936 call lookup_branch_op
2937 ret nc
2938 ld a,e
2939 ld e,d
2940 cp a,0ffh
2941 ret z ;carry clear
2942 ld b,a
2943
2944 get_mnemonic:
2945 ld hl,t_MNEMONICS
2946 bit 7,b
2947 jr z,get_m1
2948 res 7,b
2949 ld a,(iy+000h)
2950 rra
2951 rra
2952 rra
2953 and 07h
2954 str_sel_ab:
2955 add b
2956 ld b,a
2957 get_m1:
2958 call str_sel
2959 scf
2960 ret
2961
2962 lookup_branch_op ;TODO
2963 ld a,(hl)
2964 and a
2965 ret z
2966 inc hl
2967 and (iy+000h)
2968 cp (hl)
2969 inc hl
2970 jr z,l1aa8_br
2971 inc hl
2972 inc hl
2973 jr lookup_branch_op
2974
2975 l1aa8_br:
2976 ld e,(hl)
2977 inc hl
2978 ld d,(hl)
2979 scf
2980 ret
2981
2982 ;-------------------------------------------------------------------------------
2983 ; 1 byte opcodes (no parameters)
2984 ; Format: db opcode, t_MNEMONICS-index
2985 b_1ab6_start:
2986 db 076h,i_HALT ;halt
2987 db 0d9h,i_EXX ;exx
2988 db 0f3h,i_DI ;di
2989 db 0fbh,i_EI ;ei
2990 db 000h,i_NOP ;nop
2991 ; db 007h,i_RLCA ;rlca
2992 ; db 00fh,i_RRCA ;rrca
2993 ; db 017h,i_RLA ;rla
2994 ; db 01fh,i_RRA ;rra
2995 ; db 027h,i_DAA ;daa
2996 ; db 02fh,i_CPL ;cpl
2997 ; db 037h,i_SCF ;scf
2998 ; db 03fh,i_CCF ;ccf
2999 db 0c9h,i_RET ;ret
3000 db 0ffh
3001
3002
3003 ; 1 byte opcodes
3004 ; Format: db mask, match, t_MNEMONICS-index
3005 ; dw argument formating function
3006 b_1ad1_start:
3007 db 0c0h,040h,i_LD ;ld r[y],r[z]
3008 db a_rr
3009
3010 db 0c0h,080h,i_ADD+080h ;add a,r[z]
3011 db a_r
3012
3013 ; db 0f8h,080h,i_ADD ;add a,r[z]
3014 ; db a_ar
3015 ; db 0f8h,088h,i_ADC ;adc a,r[z]
3016 ; db a_ar
3017 ; db 0f8h,090h,i_SUB ;sub r[z]
3018 ; db a_r
3019 ; db 0f8h,098h,i_SBC ;sbc a,r[z]
3020 ; db a_ar
3021 ; db 0f8h,0a0h,i_AND ;and r[z]
3022 ; db a_r
3023 ; db 0f8h,0a8h,i_XOR ;xor r[z]
3024 ; db a_r
3025 ; db 0f8h,0b0h,i_OR ;or r[z]
3026 ; db a_r
3027 ; db 0f8h,0b8h,i_CP ;cp r[z]
3028 ; db a_r
3029
3030 db 0c7h,0c0h,i_RET ;ret cc
3031 db a_cc
3032 db 0c7h,0c7h,i_RST ;rst
3033 db a_rst
3034 db 0cfh,0c1h,i_POP ;pop rp2
3035 db a_p2
3036 db 0cfh,0c5h,i_PUSH ;push rp2
3037 db a_p2
3038 db 0ffh,0e3h,i_EX ;ex (sp),hl
3039 db a_esphl
3040 db 0ffh,0e9h,i_JP ;jp (hl)
3041 db a_hl
3042 db 0ffh,0ebh,i_EX ;ex de,hl
3043 db a_dehl
3044 db 0ffh,0f9h,i_LD ;ld sp,hl
3045 db a_lsphl
3046 db 0cfh,003h,i_INC ;inc rp
3047 db a_p
3048 db 0cfh,00bh,i_DEC ;dec rp
3049 db a_p
3050 db 0c7h,004h,i_INC ;inc r[y]
3051 db a_ry
3052 db 0c7h,005h,i_DEC ;dec r[y]
3053 db a_ry
3054 db 0ffh,008h,i_EX ;ex af,af'
3055 db a_eaf
3056 db 0cfh,009h,i_ADD ;add hl,rp
3057 db a_hlp
3058 db 0efh,002h,i_LD ;ld (rp),a ;rp=bc,de
3059 db a_pa
3060 db 0efh,00ah,i_LD ;ld a,(rp) ;rp=bc,de
3061 db a_ap
3062
3063 db 0c7h,007h,i_RLCA+080h;rlca
3064 db a_noarg
3065
3066 db 0
3067
3068 ; 2 byte opcodes
3069 b_1b54_start:
3070 db 0c7h,006h,i_LD ;ld r[y],nn
3071 db a_rn
3072
3073 db 0c7h,0c6h,i_ADD+080h ;add a,r[z]
3074 db a_n
3075
3076 ; db 0ffh,0c6h,i_ADD ;add a,nn
3077 ; db a_an
3078 ; db 0ffh,0ceh,i_ADC ;adc a,nn
3079 ; db a_an
3080 ; db 0ffh,0d6h,i_SUB ;sub nn
3081 ; db a_n
3082 ; db 0ffh,0deh,i_SBC ;sbc a,nn
3083 ; db a_an
3084 ; db 0ffh,0e6h,i_AND ;and nn
3085 ; db a_n
3086 ; db 0ffh,0eeh,i_XOR ;xor nn
3087 ; db a_n
3088 ; db 0ffh,0f6h,i_OR ;or nn
3089 ; db a_n
3090 ; db 0ffh,0feh,i_CP ;cp nn
3091 ; db a_n
3092
3093 db 0ffh,010h,i_DJNZ ;djnz
3094 db a_j
3095 db 0ffh,018h,i_JR ;jr
3096 db a_j
3097 db 0e7h,020h,i_JR ;jr cc,
3098 db a_ccj
3099 db 0ffh,0d3h,i_OUT ;out (nn),a
3100 db a_ma
3101 db 0ffh,0dbh,i_IN ;in a,(nn)
3102 db a_am
3103 db 0
3104
3105 ; 3 byte opcodes
3106 b_1b9b_start:
3107 db 0c7h,0c2h,i_JP ;jp cc,mn
3108 db a_ccnn
3109 db 0c7h,0c4h,i_CALL ;call cc,mn
3110 db a_ccnn
3111 db 0cfh,001h,i_LD ;ld ww,mn
3112 db a_rnn
3113 db 0ffh,0c3h,i_JP ;jp mn
3114 db a_nn
3115 db 0ffh,0cdh,i_CALL ;call mn
3116 db a_nn
3117 db 0ffh,022h,i_LD ;ld (mn),hl
3118 db a_mmhl
3119 db 0ffh,02ah,i_LD ;ld hl,(mn)
3120 db a_hlmm
3121 db 0ffh,032h,i_LD ;ld (mn),a
3122 db a_mma
3123 db 0ffh,03ah,i_LD ;ld a,(mn)
3124 db a_amm
3125 db 0
3126
3127 ; Prefix ED + 1 byte opcode, no arguments
3128 ; Format: opcode, t_MNEMONICS index
3129 b_1bc9_start:
3130 db 044h,i_NEG ;neg
3131 db 045h,i_RETN ;retn
3132 db 04dh,i_RETI ;reti
3133 db 067h,i_RRD ;rrd
3134 db 06fh,i_RLD ;rld
3135 ; db 0a0h,i_LDI ;ldi
3136 ; db 0a1h,i_CPI ;cpi
3137 ; db 0a2h,i_INI ;ini
3138 ; db 0a3h,i_OUTI ;outi
3139 ; db 0a8h,i_LDD ;ldd
3140 ; db 0a9h,i_CPD ;cpd
3141 ; db 0aah,i_IND ;ind
3142 ; db 0abh,i_OUTD ;outd
3143 ; db 0b0h,i_LDIR ;ldir
3144 ; db 0b1h,i_CPIR ;cpir
3145 ; db 0b2h,i_INIR ;inir
3146 ; db 0b3h,i_OTIR ;otir
3147 ; db 0b8h,i_LDDR ;lddr
3148 ; db 0b9h,i_CPDR ;cpdr
3149 ; db 0bah,i_INDR ;indr
3150 ; db 0bbh,i_OTDR ;otdr
3151 db 08bh,i_OTDM ;otdm
3152 db 09bh,i_OTDMR ;otdmr
3153 db 083h,i_OTIM ;otim
3154 db 093h,i_OTIMR ;otimr
3155 db 076h,i_SLP ;slp
3156 db 0ffh ;<end mark>
3157
3158 b_1bf4_start:
3159 db 0e4h,0a0h,i_LDI
3160 db a_noarg
3161 db 0ffh,070h,i_IN ;in (c) ;
3162 db a_c
3163 db 0c7h,040h,i_IN ;in r,(c) ;r=b,c,d,e,h,l,a
3164 db a_rc
3165 db 0ffh,071h,0ffh ;out (c),0 ;
3166 db a_cr
3167 db 0c7h,041h,i_OUT ;out (c),r ;r=b,c,d,e,h,l,a
3168 db a_cr
3169 db 0cfh,042h,i_SBC ;sbc hl,rp
3170 db a_hlp
3171 db 0cfh,04ah,i_ADC ;adc hl,rp
3172 db a_hlp
3173 db 0ffh,046h,i_IM ;im 0
3174 db a_im0
3175 db 0ffh,056h,i_IM ;im 1
3176 db a_im1
3177 db 0ffh,05eh,i_IM ;im 2
3178 db a_im2
3179 db 0e7h,047h,i_LD ;ld i,a ... ld a,r
3180 db a_ai
3181 db 0cfh,04ch,i_MLT ;mlt rr
3182 db a_p
3183 db 0c7h,004h,i_TST ;tst r
3184 db a_ry
3185 db 0
3186
3187 l228bh:
3188 db 0ffh,030h,i_IN0 ;in0 (m)
3189 db a_m
3190 db 0c7h,000h,i_IN0 ;in0 r,(m) ;r=b,c,d,e,h,l,a
3191 db a_rm
3192 db 0ffh,031h,0ffh ;out0 (m),0
3193 db a_mr
3194 db 0c7h,001h,i_OUT0 ;out0 (m),r ;r=b,c,d,e
3195 db a_mr
3196 db 0ffh,064h,i_TST ;tst m
3197 db a_n
3198 db 0ffh,074h,i_TSTIO ;tstio m
3199 db a_n
3200 db 0
3201
3202 ; Prefix ED + 1 byte opcode + 2 byte address
3203 ; Format: db mask, match, t_MNEMONICS-index
3204 ; dw argument formating function
3205 b_1c40_start:
3206 db 0cfh,043h,i_LD ;ld (mn),ww ;ww=bc,de,hl,sp
3207 db a_mmp
3208 db 0cfh,04bh,i_LD ;ld ww,(mn) ;ww=bc,de,hl,sp
3209 db a_pmm
3210 db 0
3211
3212 ; CB
3213 b_1c55_start:
3214 db 0c0h,000h,i_RLC+080h ;rlc g
3215 db a_cbr
3216
3217 ; db 0f8h,000h,i_RLC ;rlc g
3218 ; db a_cbr
3219 ; db 0f8h,008h,i_RRC ;rrc g
3220 ; db a_cbr
3221 ; db 0f8h,010h,i_RL ;rl g
3222 ; db a_cbr
3223 ; db 0f8h,018h,i_RR ;rr g
3224 ; db a_cbr
3225 ; db 0f8h,020h,i_SLA ;sla g
3226 ; db a_cbr
3227 ; db 0f8h,028h,i_SRA ;sra g
3228 ; db a_cbr
3229 ; db 0f8h,038h,i_SRL ;srl g
3230 ; db a_cbr
3231 db 0c0h,040h,i_BIT ;bit b,g
3232 db a_bcbr
3233 db 0c0h,080h,i_RES ;res b,g
3234 db a_bcbr
3235 db 0c0h,0c0h,i_SET ;set b,g
3236 db a_bcbr
3237 db 0
3238
3239 ;-------------------------------------------------------------------------------
3240 ;-------------------------------------------------------------------------------
3241
3242
3243 pr_instr_args:
3244 ld hl,t_argf
3245 ld d,0
3246 add hl,de
3247 pria_l:
3248 ld a,(hl) ;get next token
3249 inc hl
3250 or a
3251 ret z ;
3252 jp m,pria_1
3253 call outchar ;print as normal character
3254 jr pria_l
3255
3256 pria_1: ;
3257 push hl
3258 ld hl,do_arg_n
3259 and 07fh
3260 call add_hl_a2
3261 ld a,(hl)
3262 inc hl
3263 ld h,(hl)
3264 ld l,a
3265 ld a,(iy+000h)
3266 call CALL_HL
3267 pop hl
3268 jr pria_l
3269
3270 ;
3271 ; http://www.z80.info/decoding.htm
3272 ;
3273 ; | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
3274 ; | x | y | z |
3275 ; | p | q |
3276 ;
3277
3278 t_argf:
3279 ; 1 byte opcodes
3280 a_rr equ $-t_argf
3281 db fi_ry,',' ;ld r[y],r[z]
3282 a_r equ $-t_argf
3283 db fi_rz,0 ;op r[z]
3284 ;a_ar equ $-t_argf
3285 ; db 'A,',fi_rz,0 ;op A,r[z]
3286 a_cc equ $-t_argf
3287 db fi_ccy,0 ;op cc[y]
3288 a_rst equ $-t_argf
3289 db fi_rst,0 ;rst y*8
3290 a_p2 equ $-t_argf
3291 db fi_rp2,0 ;rp2[p]
3292 a_esphl equ $-t_argf
3293 db '(SP),',fi_hlixiy,0 ;ex (sp),hl
3294 a_hl equ $-t_argf
3295 db '(',fi_hlixiy,')',0 ;jp (hl)
3296 a_dehl equ $-t_argf
3297 db 'DE,HL',0
3298 a_lsphl equ $-t_argf
3299 db 'SP,',fi_hlixiy,0 ;ld SP,HL
3300 a_eaf equ $-t_argf
3301 db 'AF,AF''',0 ;ex af,af'
3302 a_hlp equ $-t_argf
3303 db fi_hlixiy,',' ;add hl,rp
3304 a_p equ $-t_argf
3305 db fi_rp,0 ;rp[p]
3306 a_pa equ $-t_argf
3307 db '(',fi_rp,'),A',0 ;ld (rp),a ;rp=bc,de
3308 a_ap equ $-t_argf
3309 db 'A,(',fi_rp,')',0 ;ld a,(rp) ;rp=bc,de
3310
3311 ; 2 byte opcodes
3312 a_rn equ $-t_argf
3313 db fi_ry,',',fi_n,0 ;ld r[y],n
3314 ;a_an equ $-t_argf
3315 ; db 'A,' ;op a,n
3316 a_n equ $-t_argf
3317 db fi_n,0 ;op n
3318 a_ccj equ $-t_argf
3319 db fi_ccy2,',' ;jr cc,j ;cc = nz,z,nc,c
3320 a_j equ $-t_argf
3321 db fi_j,0 ;jr j
3322 a_ma equ $-t_argf
3323 db '(',fi_n,'),A',0 ;out (n),a
3324 a_am equ $-t_argf
3325 db 'A,(',fi_n,')',0 ;in a,(n)
3326
3327 ; 3 byte opcodes
3328 a_ccnn equ $-t_argf
3329 db fi_ccy,',',fi_nn,0 ;op cc[y],nn
3330 a_rnn equ $-t_argf
3331 db fi_rp,',' ;ld rp[p],nn
3332 a_nn equ $-t_argf
3333 db fi_nn,0 ;jp nn
3334 a_mmhl equ $-t_argf
3335 db '(',fi_nn,'),',fi_hlixiy,0 ;ld (nn),hl
3336 a_hlmm equ $-t_argf
3337 db fi_hlixiy,',(',fi_nn,')',0 ;ld hl,(nn)
3338 a_mma equ $-t_argf
3339 db '(',fi_nn,'),A',0 ;ld (nn),a
3340 a_amm equ $-t_argf
3341 db 'A,(',fi_nn,')',0 ;ld a,(nn)
3342
3343 ; Prefix ED + 1 byte opcode
3344 a_rc equ $-t_argf
3345 db fi_ry,',' ;in r[y],(c)
3346 a_c equ $-t_argf
3347 db '(C)',0 ;in (c)
3348 a_cr equ $-t_argf
3349 db '(C),' ;out (c),r[y]
3350 a_ry equ $-t_argf
3351 db fi_ry,0 ;inc r[y]
3352 a_im0 equ $-t_argf
3353 db '0',0 ;im 0
3354 a_im1 equ $-t_argf
3355 db '1',0 ;im 1
3356 a_im2 equ $-t_argf
3357 db '2',0 ;im 2
3358 a_ai equ $-t_argf
3359 db fi_ir,0 ;ld a,i ... r,a
3360
3361 ; Prefix ED + 2 byte (opcode + immediate)
3362 a_rm equ $-t_argf
3363 db fi_ry,',' ;in0 r[y],(n)
3364 a_m equ $-t_argf
3365 db '(',fi_n,')',0 ;in0 (n)
3366 a_mr equ $-t_argf
3367 db '(',fi_n,'),',fi_ry,0 ;out0 (n),r[y]
3368
3369 ; Prefix ED + 3 byte (opcode + address)
3370 a_mmp equ $-t_argf
3371 db '(',fi_nn,'),',fi_rp,0 ;ld (nn),rp
3372 a_pmm equ $-t_argf
3373 db fi_rp,',(',fi_nn,')',0 ;ld rp,(nn)
3374
3375 ; Prefix CB + 1 byte opcode
3376 a_bcbr equ $-t_argf
3377 db fi_y,',' ;op y,r[z]
3378 a_cbr equ $-t_argf
3379 db fi_rz_cb,0 ;op r[z]
3380 a_noarg equ $-t_argf
3381 db 0
3382
3383
3384 ;-------------------------------------------------------------------------------
3385
3386 argpf_index defl 0
3387
3388 argpf macro x
3389 fi_&x equ 80h+argpf_index
3390 dw p_&x
3391 argpf_index defl argpf_index+1
3392 endm
3393
3394 do_arg_n:
3395 argpf ry
3396 argpf rz
3397 argpf ccy
3398 argpf ccy2
3399 argpf rst
3400 argpf rp
3401 argpf rp2
3402 argpf hlixiy
3403 argpf n
3404 argpf j
3405 argpf nn
3406 argpf ir
3407 argpf rz_cb
3408 argpf y
3409
3410
3411 p_n:
3412 ld a,(isprefix_ixiy)
3413 and a
3414 ld a,(iy+001h)
3415 jr z,out_hex_0
3416 ld a,(iy+002h)
3417 jr out_hex_0
3418
3419 p_rst:
3420 and 038h
3421 out_hex_0:
3422 jp out_hex
3423
3424
3425 p_j:
3426 ld c,(iy+001h)
3427 ld a,c
3428 rla
3429 sbc a,a
3430 ld b,a
3431 push iy
3432 pop hl
3433 add hl,bc
3434 inc hl
3435 inc hl
3436 jr out_hl_0
3437
3438 p_nn:
3439 ld l,(iy+001h)
3440 ld h,(iy+002h)
3441 out_hl_0:
3442 jp out_hl
3443
3444 p_ir:
3445 rra
3446 rra
3447 rra
3448 and 03
3449 ld hl,t_arg_IR
3450 jr p_arg
3451
3452
3453 get_cb_opc:
3454 ld a,(isprefix_ixiy)
3455 and a
3456 ld a,(iy+001h)
3457 ret z
3458 ld a,(iy+002h)
3459 ret
3460
3461 p_y:
3462 call get_cb_opc
3463 rra
3464 rra
3465 rra
3466 and 007h
3467 jp out_dgt
3468
3469 p_rz_cb:
3470 call get_cb_opc
3471 jr p_rz
3472
3473 p_ry:
3474 rra
3475 rra
3476 rra
3477 p_rz:
3478 and 007h
3479 cp 006h
3480 ld b,a
3481 ld hl,t_arg_r
3482 jr nz,p_arg0
3483 ld a,(isprefix_ixiy)
3484 and a
3485 jr z,p_arg0
3486 ld hl,t_lp_IXIY
3487 dec a
3488 call p_arg
3489 ld a,(iy+001h)
3490 push af
3491 rlca
3492 ld a,'+'
3493 jr nc,l1e61h
3494 pop af
3495 neg
3496 push af
3497 ld a,'-'
3498 l1e61h:
3499 call outchar
3500 pop af
3501 call out_hex
3502 ld a,')'
3503 jp outchar
3504
3505 p_rp2:
3506 ld hl,t_arg_rp2
3507 db 0ddh ;swallow t_arg_rp in ix
3508 p_rp:
3509 ld hl,t_arg_rp
3510 rra
3511 rra
3512 rra
3513 rra
3514 and 003h
3515 cp 002h
3516 jr nz,p_arg
3517 p_hlixiy:
3518 ld a,(isprefix_ixiy)
3519 ld hl,t_HL.IX.IY
3520 jr p_arg
3521
3522 p_ccy2:
3523 and 018h
3524 p_ccy:
3525 rra
3526 rra
3527 rra
3528 and 007h
3529 ld hl,t_arg_cc
3530 p_arg:
3531 ld b,a
3532 p_arg0:
3533 ;fall thru
3534
3535 pstr_sel:
3536 call str_sel
3537 ;fall thru
3538 pstr:
3539 ld a,(hl)
3540 inc hl
3541 and a
3542 ret z
3543 call outchar
3544 ret m
3545 jr pstr
3546
3547 pstr_inl:
3548 ex (sp),hl
3549 call pstr
3550 ex (sp),hl
3551 ret
3552
3553 ;-------------------------------------------------------------------------------
3554
3555 opc macro x
3556
3557 i_&x equ opc_index
3558 ;o_&x equ $-opc_tabstart
3559 dc '&x'
3560 opc_index defl opc_index+1
3561 endm
3562
3563 t_MNEMONICS:
3564 ;opc_tabstart defl $
3565 opc_index defl 0
3566 ; 1-byte other
3567 opc NOP
3568 opc LD
3569 opc INC
3570 opc DEC
3571 opc DJNZ
3572 opc JR
3573 opc HALT
3574
3575 opc RLCA
3576 opc RRCA
3577 opc RLA
3578 opc RRA
3579 opc DAA
3580 opc CPL
3581 opc SCF
3582 opc CCF
3583
3584 ; 1-byte "alu"
3585 opc ADD
3586 opc ADC
3587 opc SUB
3588 opc SBC
3589 opc AND
3590 opc XOR
3591 opc OR
3592 opc CP
3593
3594 opc RET
3595 opc POP
3596 opc JP
3597 opc CALL
3598 opc PUSH
3599 opc RST
3600 opc OUT
3601 opc EXX
3602 opc IN
3603 opc EX
3604 opc DI
3605 opc EI
3606 ; CB
3607 opc RLC
3608 opc RRC
3609 opc RL
3610 opc RR
3611 opc SLA
3612 opc SRA
3613 opc SLL
3614 opc SRL
3615 opc BIT
3616 opc RES
3617 opc SET
3618
3619 ; ED
3620 opc NEG
3621 opc RETN
3622 opc RETI
3623 opc IM
3624 opc RRD
3625 opc RLD
3626
3627 ; Block instructions
3628 opc LDI
3629 opc CPI
3630 opc INI
3631 opc OUTI
3632 opc LDD
3633 opc CPD
3634 opc IND
3635 opc OUTD
3636 opc LDIR
3637 opc CPIR
3638 opc INIR
3639 opc OTIR
3640 opc LDDR
3641 opc CPDR
3642 opc INDR
3643 opc OTDR
3644
3645 ; Z180
3646 opc IN0
3647 opc OUT0
3648 opc TST
3649 opc MLT
3650 opc TSTIO
3651 opc SLP
3652 opc OTIM
3653 opc OTDM
3654 opc OTIMR
3655 opc OTDMR
3656
3657 DB 0
3658
3659 t_arg_r:
3660 DC 'B'
3661 DC 'C'
3662 DC 'D'
3663 DC 'E'
3664 DC 'H'
3665 DC 'L'
3666 DC '(HL)'
3667 DC 'A'
3668 DB 0
3669 t_arg_rp:
3670 DC 'BC'
3671 DC 'DE'
3672 DC 'HL'
3673 DC 'SP'
3674 DB 0
3675 t_arg_rp2:
3676 DC 'BC'
3677 DC 'DE'
3678 DC 'HL'
3679 DC 'AF'
3680 DB 0
3681 t_HL.IX.IY:
3682 DC 'HL'
3683 DC 'IX'
3684 DC 'IY'
3685 DB 0
3686 t_arg_cc:
3687 DC 'NZ'
3688 DC 'Z'
3689 DC 'NC'
3690 DC 'C'
3691 DC 'PO'
3692 DC 'PE'
3693 DC 'P'
3694 DC 'M'
3695 DB 0
3696
3697 t_lp_IXIY:
3698 DC '(IX'
3699 DC '(IY'
3700
3701 t_arg_IR:
3702 DC 'I,A'
3703 DC 'R,A'
3704 DC 'A,I'
3705 DC 'A,R'
3706 db 0
3707
3708
3709 ;-------------------------------------------------------------------------------
3710
3711 tc_set_bp:
3712 ld hl,(reg.pc)
3713 ld a,h
3714 or l
3715 jr z,l2037h
3716 ld de,BDOS
3717 and a
3718 sbc hl,de
3719 ld hl,l20edh ;set break after BDOS call
3720 jr z,l2031h
3721 ld iy,(reg.pc)
3722 call disas_get_instrlen
3723 jp nc,ERROR
3724 ld c,b
3725 ld b,0
3726 ld hl,(reg.pc)
3727 add hl,bc
3728 call bp_trace_enter
3729 ld iy,(reg.pc)
3730 ld hl,t_op_branch
3731 call lookup_branch_op
3732 ccf
3733 ret c
3734 ex de,hl
3735 l2031h:
3736 call CALL_HL
3737 call c,bp_trace_enter
3738 l2037h:
3739 scf
3740 ret
3741
3742 ;-------------------------------------------------------------------------------
3743
3744 t_op_branch:
3745 db 0ffh,0ddh ;Prefix DD
3746 dw l20a7h
3747 db 0ffh,0fdh ;Prefix FD
3748 dw l20ach
3749 db 0ffh,0edh ;Prefix ED
3750 dw l20b8h
3751
3752 db 0ffh,0cdh ;call mn
3753 dw l2080h
3754 db 0ffh,0c3h ;jp mn
3755 dw l208bh
3756 db 0ffh,0e9h ;jp ()
3757 dw l20a2h
3758 db 0ffh,0c9h ;ret
3759 dw l20dch
3760 db 0ffh,0cfh ;rst 8
3761 dw l2115h
3762 db 0c7h,0c7h ;rst n
3763 dw l20f9h
3764 db 0c7h,0c4h ;call cc,mn
3765 dw l2080h
3766 db 0f7h,010h ;djnz d; jr d
3767 dw l2093h
3768 db 0e7h,020h ;jr cc,d
3769 dw l2093h
3770 db 0c7h,0c2h ;jp cc,mn
3771 dw l208bh
3772 db 0c7h,0c0h ;ret cc
3773 dw l20c5h
3774 db 0
3775
3776 ;-------------------------------------------------------------------------------
3777 ; call mn call cc,mn
3778 l2080h:
3779
3780 ; jp mn jp cc,mn
3781 l208bh:
3782 ld l,(iy+001h)
3783 ld h,(iy+002h)
3784 scf
3785 ret
3786
3787 l2093h:
3788 ld c,(iy+001h)
3789 ld a,c
3790 rla
3791 sbc a,a
3792 ld b,a
3793 ld hl,(reg.pc)
3794 add hl,bc
3795 inc hl
3796 inc hl
3797 scf
3798 ret
3799
3800 ; jp (hl)
3801 l20a2h:
3802 ld hl,(reg.l)
3803 scf
3804 ret
3805
3806 ; Prefix DD
3807 l20a7h:
3808 ld hl,(reg.ix)
3809 jr l20afh
3810 ; Prefix FD
3811 l20ach:
3812 ld hl,(reg.iy)
3813 l20afh:
3814 ld a,(iy+001h)
3815 cp 0e9h ; jp (ix); jp (iy)
3816 scf
3817 ret z
3818 and a
3819 ret
3820
3821 ; Prefix ED
3822 l20b8h:
3823 ld a,(iy+001h)
3824 cp 04dh ; reti
3825 jr z,l20dch
3826 cp 045h ; retn
3827 jr z,l20dch
3828 and a
3829 ret
3830 l20c5h:
3831 ld a,(iy+000h)
3832 ld (l20d7h),a
3833 ld hl,(reg.f)
3834 push hl
3835 pop af
3836 call l20d7h
3837 scf
3838 jr c,l20dch
3839 ret
3840 l20d7h:
3841 nop
3842 and a
3843 pop hl
3844 inc hl
3845 jp (hl)
3846
3847 l20dch:
3848 l20edh:
3849 ld hl,(reg_sp) ;break on return address
3850 ld e,(hl)
3851 inc hl
3852 ld d,(hl)
3853 ex de,hl
3854 call bp_trace_enter
3855 l2115h:
3856 and a
3857 ret
3858
3859 l20f9h:
3860 ld a,(l0003h)
3861 cp (iy+000h)
3862 ret z
3863 ld a,(iy+000h)
3864 and 038h
3865 ld l,a
3866 ld h,000h
3867 ld a,(b_21e2_start)
3868 and a
3869 ret z
3870 scf
3871 ret
3872
3873 ;-------------------------------------------------------------------------------
3874 ; >>C[N][J] [steps]
3875 ; >>C[N][J] W expression
3876 ; >>C[N][J] U expression
3877 ; trace over Calls [No list] [Jumps only] /.While./.Until.
3878
3879
3880 ;-------------------------------------------------------------------------------
3881 ; >>T[N][J] [steps]
3882 ; >>T[N][J] W expression
3883 ; >>T[N][J] U expression
3884 ; Trace [no List] [Jumps only] / .While. / .Until.
3885
3886 cmd_T:
3887 ld (cmd_rpt),hl
3888 ld hl,1 ;default: 1 step
3889 call get_lastarg_def
3890 ld (trace_cnt_or_ptr),hl
3891 sub a
3892 ld (bp_p_cpu_flag),a
3893 call tc_set_bp
3894 jr user_go1
3895
3896 l2151h:
3897 call bp_clr_temporary
3898 ld hl,(trace_cnt_or_ptr)
3899 dec hl
3900 ld (trace_cnt_or_ptr),hl
3901 ld a,h
3902 or l
3903 jp z,do_break
3904
3905 call tc_set_bp
3906 jp nc,do_break
3907 sbc a,a
3908 ld (bp_p_cpu_flag),a
3909 user_go1:
3910 jp user_go
3911
3912 ;-------------------------------------------------------------------------------
3913
3914 con_col:
3915 db 0
3916
3917 ;-------------------------------------------------------------------------------
3918
3919 b_21e2_start:
3920 db 0
3921 trace_cnt_or_ptr:
3922 dw 0
3923
3924 bp_p_cpu_flag:
3925 db 0
3926
3927 bp_tab:
3928 rept BP_CNT
3929 rept BP_SIZE
3930 db 0
3931 endm
3932 endm
3933
3934 ;-------------------------------------------------------------------------------
3935
3936 last_S:
3937 dw TPA
3938
3939 last_I:
3940 dw 0
3941
3942 last_O_addr:
3943 dw 0
3944 last_O_val:
3945 db 0
3946
3947 last_D:
3948 dw TPA
3949
3950 high_load:
3951 dw TPA
3952 max_load:
3953 dw TPA
3954
3955 isprefix_ixiy:
3956 db 0
3957 last_L:
3958 dw TPA
3959
3960 pbl_loop_adr:
3961 dw 0addeh
3962
3963 ;-------------------------------------------------------------------------------
3964
3965 conbuf::
3966 ds CONBUF_SIZE+1
3967
3968 ;-------------------------------------------------------------------------------
3969
3970 rept (STACK_SIZE+3)/4
3971 db 0deh,0adh,0beh,0efh
3972 endm
3973 stack::
3974 reg.l2: db 000h
3975 reg.h2: db 000h
3976 reg.e2: db 000h
3977 reg.d2: db 000h
3978 reg.c2: db 000h
3979 reg.b2: db 000h
3980 reg.f2: db 000h
3981 reg.a2: db 000h
3982 db 000h
3983 reg.i: db 000h
3984 reg.iy: dw 0000h
3985 reg.ix: dw 0000h
3986 reg.f: db 000h
3987 reg.a: db 000h
3988 reg.c: db 000h
3989 reg.b: db 000h
3990 reg.e: db 000h
3991 reg.d: db 000h
3992 reg.l: db 000h
3993 reg.h: db 000h
3994 reg_sp: dw TPA
3995 reg.iff:
3996 db 0f3h
3997 db 0c3h
3998 reg.pc: dw TPA
3999
4000 cmd_rpt:dw mainloop
4001
4002 ;-------------------------------------------------------------------------------
4003
4004 ddtz_size equ $-ddtz_base
4005 prog_size equ $-start
4006 ddtz_end::
4007
4008 ;-------------------------------------------------------------------------------
4009
4010 end