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