]> cloudbase.mooo.com Git - ddt180.git/blob - ddt180.z80
220c07485a3b105a066155cea4dba57345ffae43
[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 8 ;Size of a breakpoint record
66 YREG_CNT equ 10 ;Number of Y registers (0..9)
67
68 SYMCASE_SENS equ 0 ;Symbols are case sensitive
69 SYMCASE_CONV equ 1 ;Convert case when symbols are loaded
70 SYMCASE_LOWER equ 2 ;Convert to lower case if set, else to upper case
71
72 ;-------------------------------------------------------------------------------
73
74 ddtz_base:
75 jp ddtz_bdos
76 l0003h:
77 rst 30h
78 di_or_ei:
79 nop
80 ret
81 ddtz_bdos:
82 jp 0
83 screen_width:
84 db 80
85 symlen_max:
86 db 16
87
88 symattrib:
89 db 0
90
91
92 current_cseg defl $ - current_cseg
93 .phase current_phase + current_cseg
94 signon:
95 db 'Symbolic DDTZ/180'
96 db ' - Version '
97 maclib version.inc
98 defvers
99 db CR,LF,'$'
100 msgz80:
101 db 'Z80 or better required!',cr,lf,'$'
102
103 current_phase defl $
104 .dephase
105 current_cseg defl $
106 ds STACK_SIZE - (current_phase - signon)
107
108
109 stack:
110 reg.l2: db 000h
111 reg.h2: db 000h
112 reg.e2: db 000h
113 reg.d2: db 000h
114 reg.c2: db 000h
115 reg.b2: db 000h
116 reg.f2: db 000h
117 reg.a2: db 000h
118 l004eh: db 000h
119 reg.i: db 000h
120 reg.iy: dw 0000h
121 reg.ix: dw 0000h
122 reg.f: db 000h
123 reg.a: db 000h
124 reg.c: db 000h
125 reg.b: db 000h
126 reg.e: db 000h
127 reg.d: db 000h
128 reg.l: db 000h
129 reg.h: db 000h
130 reg_sp: dw TPA
131 reg.iff:
132 db 0f3h
133 db 0c3h
134 reg.pc: dw TPA
135 var.$: dw 0000h
136 var.@: dw 0
137
138 error_func:dw p_msg_error
139 cmd_rpt:dw mainloop
140
141 ;-------------------------------------------------------------------------------
142
143 conbuf:
144 db CONBUF_SIZE
145
146 ld sp,stack
147 exx
148 ld de,ddtz_base
149 or a
150 sbc hl,de
151 add hl,de
152 jr c,l0079h
153 ex de,hl
154 l0079h:
155 ld de,TPA
156 l007ch:
157 dec hl
158 ld (hl),000h
159 ld a,h
160 sub d
161 ld b,a
162 ld a,l
163 sub e
164 or b
165 jr nz,l007ch
166 ld a,i
167 ld (reg.i),a
168 ld a,0f3h
169 jp po,l0093h
170 ld a,0fbh
171 l0093h:
172 ld (reg.iff),a
173 call di_or_ei
174 ld hl,ddtz_base
175 ld l,000h
176 ld (reg_sp),hl
177 call cpy_fcb2
178 ld a,(dfcb1+1)
179 cp ' '
180 ld hl,0
181 call nz,read_file
182 jr mainloop
183
184 ds CONBUF_SIZE + 3 - ($ - conbuf)
185
186 ;-------------------------------------------------------------------------------
187
188 CMDTAB:
189 dw cmd_@ ;examine/substitute the displacement register @
190 dw cmd_A ;Assemble
191 dw cmd_B ;Breakpoints display/set/clear
192 dw cmd_C ;trace over Calls
193 dw cmd_D ;Display memory in hex and ascii
194 dw ERROR ;
195 dw cmd_F ;specify Filename and command line
196 dw cmd_G ;Go
197 dw cmd_H ;compute Hex and other expressions
198 dw cmd_I ;Input a byte from port
199 dw ERROR ;
200 dw ERROR ;
201 dw cmd_L ;List disassembled code
202 dw cmd_M ;Move memory [and verify]
203 dw ERROR ;
204 dw cmd_O ;Output a byte to port
205 dw ERROR ;
206 dw cmd_Q ;Qery memory for byte string
207 dw cmd_R ;Read binary or hex file and/or symbol file
208 dw cmd_S ;Substitute memory
209 dw cmd_T ;Trace
210 dw ERROR ;
211 dw cmd_V ;Verify (compare) two memory areas
212 dw cmd_W ;Write a file to disk
213 dw cmd_X ;eXamine [and substitute] registers
214 dw cmd_Y ;examine [and substitute] Y variables
215 dw cmd_Z ;Zap (fill) memory with a byte string
216
217 mainloop:
218 ld sp,stack
219 ld hl,p_msg_error
220 ld (error_func),hl
221 ld hl,(reg.pc)
222 ld (var.$),hl
223 call bp_clr_temporary
224 ld hl,(cmd_rpt)
225 ld de,mainloop
226 call cp_hl_de
227 ld a,'>'
228 call outchar
229 call nz,outchar
230 call z,outbl
231 call get_line
232 call skipbl
233 jr z,exe_hl
234 ld hl,mainloop
235 ld (cmd_rpt),hl
236 inc de
237 sub '@'
238 jr c,ERROR
239 cp 'Z'+1-'@'
240 jr nc,ERROR
241 add a,a
242 ld hl,CMDTAB
243 call add_hl_a
244 ld a,(hl)
245 inc hl
246 ld h,(hl)
247 ld l,a
248 jr exe_hl
249
250 ERROR:
251 ld hl,(error_func)
252 exe_hl:
253 call CALL_HL
254 jr mainloop
255
256 ;-------------------------------------------------------------------------------
257
258 p_msg_error:
259 call pstr_inl
260 dc '?'
261 ;fall thru
262 crlf:
263 call pstr_inl
264 db CR,LF+80h
265 call inchar
266 ld a,0
267 ld (con_col),a
268 jr c,mainloop
269 ret
270
271 out.hl.@:
272 call out_hl
273 push de
274 push hl
275 ld de,(var.@)
276 ld a,d
277 or e
278 jr z,l01bfh
279 call outbl
280 call pstr_inl
281 dc '@'
282 and a
283 sbc hl,de
284 call out_hl
285 l01bfh:
286 pop hl
287 pop de
288 ret
289
290 sub_01d9h:
291 call pstr_inl
292 dc '-'
293 dec hl
294 jp cpl.hl
295
296 out_hl_dec_neg:
297 push hl
298 call sub_01d9h
299 defb 03eh ;ld a,.. swallow push hl
300 out.hl.dec:
301 push hl
302 ld b,006h
303 call sub_01f9h
304 pop hl
305 call pstr_inl
306 dc '.'
307 l01f3h:
308 call outbl
309 djnz l01f3h
310 ret
311
312 sub_01f9h:
313 dec b
314 push de
315 ld de,10
316 call div_hl_de
317 ld a,h
318 or l
319 call nz,sub_01f9h
320 ld a,e
321 pop de
322 jr out_dgt
323
324 out_hl_neg:
325 push hl
326 call sub_01d9h
327 call out_hl
328 pop hl
329 ret
330
331 out_hl:
332 ld a,h
333 call out_hex
334 ld a,l
335
336 out_hex:
337 push af
338 rra
339 rra
340 rra
341 rra
342 call out_dgt
343 pop af
344
345 out_dgt:
346 or 0f0h
347 daa
348 add a,0a0h
349 adc a,040h
350 jr outchar
351
352 out.bin.w:
353 ld a,h
354 call out.bin.b
355 ld a,l
356 out.bin.b:
357 ld b,8
358 l01c9h:
359 rlca
360 push af
361 ld a,'0'/2
362 adc a,a
363 call outchar
364 pop af
365 djnz l01c9h
366 ld a,'"'
367 jr outchar
368
369 out.ascii:
370 push bc
371 ld c,a
372 res 7,a
373 cp ' '
374 push af
375 call nc,outbl
376 call outquote
377 pop af
378 jr nc,l0242h
379 sub 0c0h
380 ld b,a
381 call pstr_inl
382 dc '^'
383 ld a,b
384 l0242h:
385 call outchar
386 cp ''''
387 call z,outchar
388 call outquote
389 sla c
390 pop bc
391 ret nc
392 ld a,'.'
393 jr outchar
394
395 outbl6:
396 call outbl2
397 outbl4:
398 call outbl2
399 outbl2:
400 call outbl
401 outbl:
402 ld a,' '
403 jr outchar
404
405 outquote:
406 ld a,''''
407 outchar:
408 push ix
409 push iy
410 push hl
411 push de
412 push bc
413 push af
414 and 07fh
415 ld e,a
416 ld c,BDOS_COUT
417 call ddtz_bdos
418 ld hl,con_col
419 inc (hl)
420 pop af
421 pop bc
422 pop de
423 pop hl
424 pop iy
425 pop ix
426 ret
427
428 pstr:
429 ld a,(hl)
430 inc hl
431 and a
432 ret z
433 call outchar
434 and a
435 ret m
436 jr pstr
437
438 pstr_inl:
439 ex (sp),hl
440 call pstr
441 ex (sp),hl
442 ret
443
444 p_align_@_sym:
445 push de
446 ld de,(var.@)
447 ld a,d
448 or e
449 pop de
450 ld a,(symlen_cur)
451 jr z,$+4
452 add a,6
453 add a,c
454 ld c,a
455 p_goto_col:
456 ld a,(con_col)
457 cp c
458 ret nc
459 ret z
460 call outbl
461 jr p_goto_col
462
463 ;-------------------------------------------------------------------------------
464
465 inchar:
466 push ix
467 push hl
468 push de
469 push bc
470 ld c,BDOS_CSTAT
471 call ddtz_bdos
472 and a
473 jr z,l0284h
474 ld c,BDOS_CIN
475 call ddtz_bdos
476 scf
477 l0284h:
478 pop bc
479 pop de
480 pop hl
481 pop ix
482 ret
483
484 get_line:
485 push hl
486 ld de,conbuf
487 ld c,BDOS_CBUF
488 call ddtz_bdos
489 call crlf
490 ld hl,conbuf+1
491 ld e,(hl)
492 xor a
493 ld d,a
494 inc hl
495 ex de,hl
496 add hl,de
497 ld (hl),a
498 pop hl
499 ret
500
501 ;-------------------------------------------------------------------------------
502
503 get_char_upper:
504 ld a,(de)
505 toupper:
506 cp 'a'
507 ret c
508 cp 'z'+1
509 ccf
510 ret c
511 and 05fh
512 ret
513
514 tolower:
515 cp 'A'
516 ret c
517 cp 'Z'+1
518 ccf
519 ret c
520 or 020h
521 ret
522
523 ;-------------------------------------------------------------------------------
524
525 skipbl0:
526 inc de
527 skipbl:
528 call get_char_upper
529 call test_whitespace
530 jr z,skipbl0
531 or a
532 ret
533
534 next_arg:
535 call skipbl
536 cp ','
537 ret nz
538 inc de
539 call skipbl
540 cp a
541 ret
542
543 assert_eol:
544 call skipbl
545 ret z
546 to_error:
547 jp ERROR
548
549 ;-------------------------------------------------------------------------------
550
551 chk_stack:
552 push hl
553 push de
554 ld hl,0
555 add hl,sp
556 ld de,stack-(STACK_SIZE-28)
557 call cp_hl_de
558 pop de
559 pop hl
560 jr c,to_error
561 ret
562
563 ;-------------------------------------------------------------------------------
564
565 add_hl_a:
566 add a,l
567 ld l,a
568 ret nc
569 inc h
570 ret
571
572 cp_hl_de:
573 and a
574 sbc hl,de
575 add hl,de
576 ret
577
578 sub_hl_a1:
579 dec hl
580 sub_hl_a:
581 push bc
582 ld c,a
583 ld b,0
584 or a
585 sbc hl,bc
586 pop bc
587 ret
588
589 ;-------------------------------------------------------------------------------
590
591 sym_getname:
592 push de
593 push hl
594 ld hl,ddtz_base+2
595 sgn_l:
596 ld d,(hl)
597 dec hl
598 ld e,(hl)
599 dec hl
600 ld a,(hl)
601 cp 0c3h
602 jr z,sgn_e
603
604 ex (sp),hl
605 call cp_hl_de
606 jr z,sgn_e
607 ex (sp),hl
608 call sub_hl_a1
609 jr sgn_l
610 sgn_e:
611 sub 0c3h
612 pop hl
613 pop de
614 ret
615
616 p_symstr:
617 push bc
618 ld b,(hl)
619 pss_l:
620 dec hl
621 ld a,(hl)
622 call outchar
623 djnz pss_l
624 dec hl
625 pop bc
626 ret
627
628 p_symbol:
629 if 0
630 ld a,(dash_flag)
631 or a
632 ret nz
633 endif
634 push hl
635 call sym_getname
636 call nz,p_symstr
637 pop hl
638 ret
639
640 p_label:
641 if 0
642 ld a,(dash_flag)
643 or a
644 ret nz
645 endif
646 push hl
647 call sym_getname
648 jr z,pl_e
649 call p_symstr
650 call pstr_inl
651 dc ':'
652 call crlf
653 pl_e:
654 pop hl
655 ret
656
657 ;-------------------------------------------------------------------------------
658
659 lookupch:
660 ld b,0
661 l02f5h:
662 ld a,(hl)
663 and a
664 ret z
665 call get_char_upper
666 cp (hl)
667 jr z,l0300h
668 inc hl
669 inc b
670 jr l02f5h
671 l0300h:
672 scf
673 inc de
674 ret
675
676 sub_0303h:
677 ld hl,t_reg_names
678 ld b,07fh
679 jr l030ch
680
681 sub_030ah:
682 ld b,0ffh
683 l030ch:
684 inc b
685 ld a,(hl)
686 and a
687 ret z
688 call sub_031ch
689 jr nc,l030ch
690 res 7,b
691 ret
692
693 sub_0318h:
694 push bc
695 res 7,b
696 defb 03eh ;ld a,nn
697 sub_031ch:
698 push bc
699 push de
700 l031eh:
701 call get_char_upper
702 xor (hl)
703 and 07fh
704 jr nz,l0336h
705 bit 7,(hl)
706 inc hl
707 inc de
708 jr z,l031eh
709 scf
710 bit 7,b
711 call z,sub_060ch
712 jr nc,l0339h
713 pop af
714 scf
715 pop bc
716 ret
717 l0336h:
718 call sub_0345h
719 l0339h:
720 pop de
721 and a
722 pop bc
723 ret
724
725 sel_dc_string:
726 inc b
727 l033eh:
728 dec b
729 ret z
730 call sub_0345h
731 jr l033eh
732
733 sub_0345h:
734 ld a,(hl)
735 and a
736 ret z
737 l0348h:
738 ld a,(hl)
739 inc hl
740 and a
741 ret m
742 jr l0348h
743
744 sub_034eh:
745 call get_arg_range
746 push hl
747 push bc
748 call next_arg
749 call sub_0363h
750 ex de,hl
751 pop bc
752 pop hl
753 ret
754
755 sub_035dh:
756 call expr
757 jr c,error0
758 ret
759
760 sub_0363h:
761 call sub_035dh
762 l0366h:
763 jp assert_eol
764
765 get_lastarg_def:
766 call get_arg_def
767 jr l0366h
768
769 get_arg_def:
770 push hl
771 call expr
772 jr c,l0375h
773 ex (sp),hl
774 l0375h:
775 pop hl
776 ret
777
778 sub_0377h:
779 call b_037c_start
780 jr l0366h
781
782 b_037c_start:
783 defb 0e6h ;and a,.. clear carry
784 get_arg_range:
785 scf
786 ex af,af'
787 push bc
788 push hl
789 call expr
790 jr nc,l038ch
791 ex af,af'
792 jr c,error0
793 ex af,af'
794 pop hl
795 defb 03eh ;ld a,.. swallow pop af
796 l038ch:
797 pop af
798 call get_range
799 jr nc,l0398h
800 ex af,af'
801 pop bc
802 ret nc
803 error0:
804 jp ERROR
805 l0398h:
806 pop af
807 ret
808
809 get_range:
810 call next_arg
811 cp 'S'
812 jr nz,l03a2h
813 inc de
814 l03a2h:
815 push hl
816 push af ;'S' flag
817 call expr
818 jr c,l03b8h
819 ld b,h
820 ld c,l
821 pop af
822 pop hl
823 jr z,l03b6h ;'S'?
824 ld a,c
825 sub l
826 ld c,a
827 ld a,b
828 sbc a,h
829 ld b,a
830 inc bc
831 l03b6h:
832 and a
833 ret
834 l03b8h:
835 pop af
836 pop hl
837 jr z,error0 ;'S', but no expression following
838 scf
839 ret
840
841 ;-------------------------------------------------------------------------------
842
843 expr:
844 call skipbl
845 expr1:
846 call do_subexpr
847 ret c
848 call do_rel_op
849 ret nc
850 push bc
851 push hl
852 call do_subexpr
853 jr c,error0
854 ex de,hl
855 ex (sp),hl
856 and a
857 sbc hl,de
858 ld hl,0ffffh
859 pop de
860 ret
861
862 ;-------------------------------------------------------------------------------
863
864 do_op_eq:
865 jr z,l03edh
866 jr l03ech
867 do_op_ne:
868 jr nz,l03edh
869 jr l03ech
870 do_op_le:
871 jr z,l03edh
872 do_op_lt:
873 jr c,l03edh
874 jr l03ech
875 do_op_gt:
876 jr z,l03ech
877 do_op_ge:
878 jr nc,l03edh
879 l03ech:
880 inc hl
881 l03edh:
882 and a
883 ret
884 do_rel_op:
885 push hl
886 ld hl,tab_eq_le_ge
887 call lookupch
888 jr nc,l041dh
889 ld a,b
890 or a
891 jr z,l0411h
892 ld a,(de)
893 cp '='
894 jr nz,l0406h
895 inc de
896 inc b
897 inc b
898 jr l0411h
899 l0406h:
900 bit 0,b
901 jr z,l0411h
902 cp '>'
903 jr nz,l0411h
904 inc de
905 ld b,005h
906 l0411h:
907 ld hl,tab_func_eqlege
908 ld a,b
909 add a,a
910 call add_hl_a
911 ld c,(hl)
912 inc hl
913 ld b,(hl)
914 scf
915 l041dh:
916 pop hl
917 ret
918
919 tab_eq_le_ge:
920 db '=<>',0
921
922 tab_func_eqlege:
923 dw do_op_eq
924 dw do_op_lt
925 dw do_op_gt
926 dw do_op_le
927 dw do_op_ge
928 dw do_op_ne
929
930 do_subexpr:
931 call do_factor
932 ret c
933 l0433h:
934 call do_binary_op
935 push hl
936 push bc
937 call do_factor
938 pop bc
939 ex de,hl
940 ex (sp),hl
941 jr nc,l0447h
942 pop de
943 ld a,b
944 or c
945 ret z
946 jp ERROR
947
948 l0447h:
949 ld a,b
950 or c
951 push bc
952 ret nz
953 pop bc
954
955 doop_add:
956 add hl,de
957 l044dh:
958 pop de
959 jr l0433h
960
961 doop_sub:
962 and a
963 sbc hl,de
964 jr l044dh
965
966 doop_mlt:
967 push bc
968 ld b,h
969 ld c,l
970 ld hl,0
971 ld a,010h
972 l045dh:
973 add hl,hl
974 ex de,hl
975 add hl,hl
976 ex de,hl
977 jr nc,l0464h
978 add hl,bc
979 l0464h:
980 dec a
981 jr nz,l045dh
982 pop bc
983 jr l044dh
984
985 doop_div:
986 call div_hl_de
987 jr l044dh
988
989 doop_mod:
990 call div_hl_de
991 ex de,hl
992 jr l044dh
993
994 ; divide x/y
995 ; hl: x
996 ; de: y
997 ; return:
998 ; hl: q (x/y)
999 ; de: r (x%y)
1000
1001 div_hl_de:
1002 push bc
1003 ex de,hl ;de: x
1004 ld b,h ;bc: y
1005 ld c,l
1006 ld hl,0 ;hl: r
1007 ld a,16
1008
1009 ; de: x (x shifted out, q shifted in)
1010 ; bc: y
1011 ; hl: r (initially 0)
1012
1013 div_lp:
1014 ex de,hl
1015 add hl,hl ;x <<= 1
1016 ex de,hl
1017 adc hl,hl ;r <<= 1
1018 inc de
1019 or a
1020 sbc hl,bc
1021 jr nc,div_norestore
1022 dec de
1023 add hl,bc
1024 div_norestore:
1025 dec a
1026 jr nz,div_lp
1027 ex de,hl
1028 pop bc
1029 ret
1030
1031 doop_and:
1032 ld a,h
1033 and d
1034 ld h,a
1035 ld a,l
1036 and e
1037 ld l,a
1038 jr l044dh
1039
1040 doop_or:
1041 ld a,h
1042 or d
1043 ld h,a
1044 ld a,l
1045 or e
1046 ld l,a
1047 jr l044dh
1048
1049 doop_xor:
1050 ld a,h
1051 xor d
1052 ld h,a
1053 ld a,l
1054 xor e
1055 ld l,a
1056 jr l044dh
1057
1058 do_binary_op:
1059 push hl
1060 ld hl,tab_op_a
1061 call lookupch
1062 ld a,b
1063 ld hl,tblf_opa
1064 add a,a
1065 call add_hl_a
1066 ld c,(hl)
1067 inc hl
1068 ld b,(hl)
1069 pop hl
1070 ret
1071
1072 tab_op_a:
1073 DB '+-*/%&!#',0
1074
1075 tblf_opa:
1076 dw doop_add
1077 dw doop_sub
1078 dw doop_mlt
1079 dw doop_div
1080 dw doop_mod
1081 dw doop_and
1082 dw doop_or
1083 dw doop_xor
1084 dw 0
1085
1086 ;-------------------------------------------------------------------------------
1087
1088 fact_factor:
1089 call do_factor
1090 ret nc
1091 jp ERROR
1092
1093 do_factor:
1094 call chk_stack
1095 call get.number
1096 ret nc
1097 inc de
1098 ld hl,(BDOS+1)
1099 cp 'T'
1100 ret z
1101 ld hl,(high_load)
1102 cp 'H'
1103 ret z
1104 ld hl,(max_load)
1105 cp 'M'
1106 ret z
1107 ld hl,TPA
1108 cp 'L'
1109 ret z
1110 ld hl,(var.@)
1111 cp '@'
1112 ret z
1113 ld hl,(var.$)
1114 cp '$'
1115 ret z
1116 ld hl,ddtz_base
1117 cp 'Z'
1118 ret z
1119 cp '-'
1120 jr z,fact_factneg
1121 cp '~'
1122 jr z,fact_factinv
1123 cp '+'
1124 jr z,fact_factor
1125 cp '^'
1126 jr z,fact_reg.CPU
1127 cp 'Y'
1128 jr z,fact_reg.Y
1129 cp '('
1130 jr z,fact_mem
1131 cp '['
1132 jr z,expr_brckt
1133 cp ''''
1134 jr z,fact_factstring
1135 cp '.'
1136 jr z,fact_symbol
1137 dec de
1138 scf
1139 ret
1140
1141 ;-------------------------------------------------------------------------------
1142
1143 fact_reg.Y:
1144 call get.decdigit
1145 jr c,error1
1146 inc de
1147 get_y_val:
1148 add a,a
1149 ld hl,reg_Y
1150 call add_hl_a
1151 ld a,(hl)
1152 inc hl
1153 ld h,(hl)
1154 ld l,a
1155 and a
1156 ret
1157
1158 fact_factstring:
1159 ld hl,0
1160 l054bh:
1161 ld a,(de)
1162 cp ''''
1163 jr z,l0557h
1164 and a
1165 ret z
1166 l0552h:
1167 ld h,l
1168 ld l,a
1169 inc de
1170 jr l054bh
1171 l0557h:
1172 inc de
1173 ld a,(de)
1174 cp ''''
1175 jr z,l0552h
1176 sub '.'
1177 or a
1178 ret nz
1179 inc de
1180 set 7,l
1181 ret
1182
1183 fact_reg.CPU:
1184 call sub_0caeh
1185 jr nc,error1
1186 ld a,(hl)
1187 inc hl
1188 ld h,(hl)
1189 ld l,a
1190 and a
1191 bit 0,c
1192 ret nz
1193 ld h,000h
1194 ret
1195
1196 fact_factneg:
1197 call fact_factor
1198 dec hl
1199 cpl.hl:
1200 ld a,h
1201 cpl
1202 ld h,a
1203 ld a,l
1204 cpl
1205 ld l,a
1206 ret
1207
1208 fact_factinv:
1209 call fact_factor
1210 jr cpl.hl
1211
1212 fact_mem:
1213 call expr1
1214 jr c,error1
1215 ld a,(de)
1216 cp ')'
1217 jr nz,error1
1218 inc de
1219 ld a,(hl)
1220 inc hl
1221 ld h,(hl)
1222 ld l,a
1223 ld a,(de)
1224 inc de
1225 cp '.'
1226 ret z
1227 dec de
1228 xor a
1229 ld h,a
1230 ret
1231
1232 expr_brckt:
1233 call expr1
1234 jr c,error1
1235 ld a,(de)
1236 cp ']'
1237 inc de
1238 ret z
1239 error1:
1240 jp ERROR
1241
1242 fact_symbol:
1243 push bc
1244 ld hl,ddtz_base ;symtbl start
1245 ld a,(symattrib)
1246 ld c,07fh
1247 rra
1248 jr c,fs_nxtsym
1249 res 5,c
1250
1251 fs_nxtsym:
1252 ld a,(hl) ;symlen
1253 cp 0c3h
1254 jr z,error1
1255 ld b,a ;symlen
1256 inc b
1257 push hl ;symtbl ptr
1258 push de ;inpsym ptr
1259 fs_nxtchar:
1260 ld a,(de)
1261 djnz fs_3
1262 call test_sym_char
1263 jr z,fs_cont
1264 pop hl ;inpsym ptr (discard)
1265 inc de
1266 cp a,':'
1267 jr z,fs_cont_1
1268 dec de
1269
1270 pop hl ;symtbl ptr
1271 inc hl
1272 ld a,(hl) ;symval h
1273 inc hl
1274 ld h,(hl) ;symval l
1275 ld l,a
1276 or a ;clear carry
1277 pop bc
1278 ret
1279
1280 fs_3:
1281 inc de
1282 dec hl
1283 xor (hl)
1284 and c
1285 jr z,fs_nxtchar
1286 fs_cont: ;start over
1287 pop de ;inpsym ptr
1288 fs_cont_1:
1289 pop hl ;symtbl ptr
1290 ld a,(hl)
1291 add a,3
1292 call sub_hl_a
1293 jr fs_nxtsym
1294
1295 ;-------------------------------------------------------------------------------
1296
1297 get.number:
1298 call get.hexdigit
1299 ret c
1300 push de
1301 test_number:
1302 inc de
1303 call get.hexdigit
1304 jr nc,test_number
1305 pop de
1306 cp '.'
1307 jr z,get_dec_number
1308 cp '"'
1309 jr z,get_bin_number
1310 ld hl,0
1311 next_hexdigit:
1312 call get.hexdigit
1313 jr c,hexnum_done
1314 add hl,hl
1315 add hl,hl
1316 add hl,hl
1317 add hl,hl
1318 call add_hl_a
1319 inc de
1320 jr next_hexdigit
1321
1322 hexnum_done:
1323 xor 'H'
1324 ret nz
1325 inc de
1326 ret
1327
1328 get_bin_number:
1329 ld hl,0
1330 next_bindigit:
1331 call get.bindigit
1332 l05dbh:
1333 inc de
1334 jr c,l05e4h
1335 add hl,hl
1336 call add_hl_a
1337 jr next_bindigit
1338 l05e4h:
1339 cp '"'
1340 jr nz,error11
1341 call get.bindigit
1342 jr nc,l05dbh
1343 or a
1344 ret
1345
1346 get_dec_number:
1347 ld hl,0
1348 next_decdigit:
1349 call get.decdigit
1350 inc de
1351 jr c,decnum_done
1352 push bc
1353 add hl,hl
1354 ld b,h
1355 ld c,l
1356 add hl,hl
1357 add hl,hl
1358 add hl,bc
1359 pop bc
1360 call add_hl_a
1361 jr next_decdigit
1362 decnum_done:
1363 cp '.'
1364 ret z
1365 error11:
1366 jp ERROR
1367
1368 sub_060ch:
1369 call get_char_upper
1370 cp 'Z'+1
1371 jr l0614h
1372
1373 get.hexdigit:
1374 ld a,(de)
1375 hex_digit:
1376 call toupper
1377 cp 'F'+1
1378 l0614h:
1379 ccf
1380 ret c
1381 cp 'A'
1382 jr c,l061eh
1383 sub 'A'-10
1384 ret
1385
1386 get.decdigit:
1387 call get_char_upper
1388 l061eh:
1389 cp '9'+1
1390 jr l0625h
1391
1392 get.bindigit:
1393 call get_char_upper
1394 cp '1'+1
1395 l0625h:
1396 ccf
1397 ret c
1398 cp '0'
1399 ret c
1400 sub '0'
1401 ret
1402
1403 ;-------------------------------------------------------------------------------
1404
1405 p_cpustat0:
1406 call assert_eol
1407 p_cpustat:
1408 call p_f
1409 call outbl2
1410 ld hl,b_06e9_start
1411 ld de,b_0709_start
1412 ld b,6
1413 l063eh:
1414 call p_regs
1415 djnz l063eh
1416 push hl
1417 push de
1418 ld iy,(reg.pc)
1419 call p_disas_instr
1420 pop de
1421 ex (sp),hl
1422 push af
1423 call crlf
1424 call p_f2
1425 call outbl2
1426 ld b,7
1427 l065bh:
1428 call p_regs
1429 djnz l065bh
1430 pop af
1431 pop hl
1432 call nz,outbl6
1433 call nz,p_offset
1434 jp crlf
1435
1436 p_f:
1437 ld a,(reg.f)
1438 call p_flags
1439 ld a,(reg.iff)
1440 cp 0f3h
1441 jp z,outbl
1442 ld a,'E'
1443 jp outchar
1444 p_f2:
1445 ld a,(reg.f2)
1446 call p_flags
1447 jp outbl
1448
1449 p_flags:
1450 push hl
1451 ld hl,t_flag_names+7
1452 ld c,a
1453 ld b,8
1454 fl_loop:
1455 ld a,' '
1456 cp (hl)
1457 ld a,c
1458 rlca
1459 ld c,a
1460 jr z,fl_skip
1461 ld a,(hl)
1462 call c,outchar
1463 call nc,outbl
1464 fl_skip:
1465 dec hl
1466 djnz fl_loop
1467 pop hl
1468 ret
1469
1470 p_regs:
1471 push de
1472 call pstr
1473 call pstr_inl
1474 dc '='
1475 ex (sp),hl
1476 ld e,(hl)
1477 inc hl
1478 ld d,(hl)
1479 inc hl
1480 ld a,(hl)
1481 inc hl
1482 push hl
1483 and a
1484 jr z,l06deh
1485 ex de,hl
1486 ld e,(hl)
1487 inc hl
1488 ld d,(hl)
1489 ex de,hl
1490 dec a
1491 jr z,l06d9h
1492 call out.hl.@
1493 call z,outbl6
1494 jr l06e2h
1495 l06d9h:
1496 call out_hl
1497 jr l06e2h
1498 l06deh:
1499 ld a,(de)
1500 call out_hex
1501 l06e2h:
1502 call outbl
1503 pop de
1504 pop hl
1505 ret
1506
1507 b_06e9_start:
1508 DC 'A '
1509 DC 'BC '
1510 DC 'DE '
1511 DC 'HL '
1512 DC 'SP'
1513 DC 'PC'
1514 DC 'a'''
1515 DC 'bc'''
1516 DC 'de'''
1517 DC 'hl'''
1518 DC 'IX'
1519 DC 'IY'
1520 DC 'I'
1521 DB 0
1522
1523 b_0709_start:
1524 dw reg.a
1525 db 000h
1526 dw reg.c
1527 db 001h
1528 dw reg.e
1529 db 001h
1530 dw reg.l
1531 db 001h
1532 dw reg_sp
1533 db 001h
1534 dw reg.pc
1535 db 002h
1536 dw reg.a2
1537 db 000h
1538 dw reg.c2
1539 db 001h
1540 dw reg.e2
1541 db 001h
1542 dw reg.l2
1543 db 001h
1544 dw reg.ix
1545 db 001h
1546 dw reg.iy
1547 db 001h
1548 dw reg.i
1549 db 000h
1550 db 000h
1551
1552 ;-------------------------------------------------------------------------------
1553 ; > G [startaddr] [;breakp..]
1554 ; Go [to start] [with temporary breakpoints]
1555
1556 cmd_G:
1557 sub a
1558 ld (trace_call_flag),a
1559 ld (bp_p_cpu_flag),a
1560 call expr
1561 jr c,l0740h
1562 ld (reg.pc),hl
1563 l0740h:
1564 call skipbl
1565 jr z,user_go0
1566 cp ';'
1567 jp nz,ERROR
1568 inc de
1569 ld a,002h
1570 call bp_enter
1571 user_go0:
1572 jp user_go
1573
1574 ;-------------------------------------------------------------------------------
1575
1576 bpl_init:
1577 ld b,BP_CNT
1578 ld ix,bp_tab
1579 ex (sp),hl
1580 ld (pbl_loop_adr),hl
1581 ex (sp),hl
1582 ret
1583
1584 bpl_next:
1585 ld de,BP_SIZE
1586 push af
1587 add ix,de
1588 pop af
1589 dec b
1590 ret z
1591
1592 ex (sp),hl
1593 ld hl,(pbl_loop_adr)
1594 ex (sp),hl
1595 ret
1596
1597 bp_clr_temporary:
1598 call bpl_init
1599
1600 ld a,(ix+000h)
1601 and 0f1h
1602 ld (ix+000h),a
1603 call bp_clr_condition
1604
1605 call bpl_next
1606 ret
1607
1608 ;-------------------------------------------------------------------------------
1609 ; > B
1610 ; display all breakpoints
1611 ; > B breakp [breakp..]
1612 ; set breakpoints
1613 ; > BX
1614 ; clear all breakpoints
1615 ; > BX address [address..]
1616 ; clear breakpoints
1617 ;
1618 ; where breakp is:
1619 ; [R] expression [I condition]
1620
1621 cmd_B:
1622 call skipbl
1623 jr z,bp_print
1624 inc de
1625 cp 'X'
1626 jr z,bp_clr0
1627 dec de
1628 ld a,001h
1629 jp bp_enter
1630
1631 bp_clr0:
1632 call skipbl
1633 jr z,bp_clr_all
1634 bp_clr_next:
1635 call expr
1636 jp c,assert_eol
1637 push de
1638 call bp_clr
1639 pop de
1640 call next_arg
1641 jr bp_clr_next
1642
1643 bp_clr_all:
1644 scf
1645 bp_clr:
1646 call bpl_init
1647
1648 push af
1649 jr c,l07a7h
1650 ld e,(ix+002h)
1651 ld d,(ix+003h)
1652 call cp_hl_de
1653 jr nz,l07aeh
1654 l07a7h:
1655 ld (ix+000h),000h
1656 call bp_clr_condition
1657 l07aeh:
1658 pop af
1659 call bpl_next
1660 ret
1661
1662 bp_print:
1663 call bpl_init
1664
1665 bit 0,(ix+000h)
1666 jr z,bp_pr_cont
1667 ld a,'R'
1668 bit 4,(ix+000h)
1669 jr nz,l07cdh
1670 ld a,' '
1671 l07cdh:
1672 call outchar
1673 call outbl
1674 ld l,(ix+002h)
1675 ld h,(ix+003h)
1676 call out.hl.@
1677 call outbl
1678 call p_symbol
1679 ld c,9
1680 call p_align_@_sym
1681 call pstr_inl
1682 dc ':'
1683 ld l,(ix+004h)
1684 ld h,(ix+005h)
1685 call out_hl
1686 ld l,(ix+006h)
1687 ld h,(ix+007h)
1688 ld a,h
1689 or l
1690 jr z,l0805h
1691 call outbl4
1692 call pstr_inl
1693 dc 'I '
1694 call pstr
1695 l0805h:
1696 call crlf
1697 bp_pr_cont:
1698 call bpl_next
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 cp 'R'
1711 jr nz,bp_e_1
1712 inc de
1713 set 4,b
1714 bp_e_1:
1715 push bc
1716 call expr
1717 jr c,error12
1718 pop bc
1719 bit 0,b
1720 push bc
1721 push de
1722 push hl
1723 call nz,bp_clr
1724 pop hl
1725 call bp_get_freeslot
1726 pop de
1727 ld (ix+002h),l
1728 ld (ix+003h),h
1729 call bp_get_count
1730 ld (ix+004h),l
1731 ld (ix+005h),h
1732 call bp_get_condition
1733 ld (ix+006h),l
1734 ld (ix+007h),h
1735 call next_arg
1736 pop af
1737 ld (ix+000h),a
1738 and 00fh
1739 jr bp_enter
1740
1741 bp_get_freeslot:
1742 call bpl_init
1743
1744 ld a,(ix+000h)
1745 and 00fh
1746 ret z
1747
1748 call bpl_next
1749 error12
1750 jp ERROR
1751
1752 bp_get_count:
1753 call skipbl
1754 ld hl,1
1755 cp ':'
1756 ret nz
1757 inc de
1758 call expr
1759 jr c,error12
1760 ret
1761
1762 bp_get_condition:
1763 call skipbl
1764 cp 'I'
1765 ld hl,0
1766 ret nz
1767 inc de
1768 call skipbl
1769 push de
1770 call expr
1771 jr c,error12
1772 ex de,hl
1773 pop de
1774 push de
1775 sbc hl,de
1776 ld b,h
1777 ld c,l
1778 ld hl,(expr_p1)
1779 push hl
1780 add hl,bc
1781 ld de,expr_bufe
1782 call cp_hl_de
1783 jr nc,error12
1784 pop de
1785 pop hl
1786 push de
1787 ldir
1788 ex de,hl
1789 ld (hl),c ; trailing 0
1790 inc hl
1791 ld (expr_p1),hl
1792 pop hl
1793 ret
1794
1795 ;-------------------------------------------------------------------------------
1796 ; Breakpoint handling routine.
1797
1798 bpddtz:
1799 ld (reg.l),hl
1800 pop hl
1801 dec hl
1802 ld (reg.pc),hl
1803 ld (reg_sp),sp
1804 ld sp,reg.l
1805 push de
1806 push bc
1807 push af
1808 push ix
1809 push iy
1810 ld a,i
1811 call di_or_ei
1812 ld h,a
1813 ld l,000h
1814 push hl
1815 ld a,0f3h ; EI
1816 jp po,l08dfh
1817 ld a,0fbh ; DI
1818 l08dfh:
1819 ld (reg.iff),a
1820 ex af,af'
1821 push af
1822 exx
1823 push bc
1824 push de
1825 push hl
1826 call bp_restore_mem
1827 ld a,(b_21e2_start)
1828 dec a
1829 jr z,l090bh
1830 call inchar ;Keyboard hit?
1831 jr c,do_break ;yes
1832 call sub_0913h
1833 and a
1834 jp z,user_go
1835 and 083h
1836 jp z,l2151h
1837 do_break:
1838 call bp_clr_temporary
1839 call p_cpustat
1840 jp mainloop
1841
1842 l090bh:
1843 ld (b_21e2_start),a
1844 ld c,007h
1845 jp l0a41h
1846
1847 sub_0913h:
1848 ld a,080h
1849 ex af,af'
1850 sub a
1851 ld (bp_p_cpu_flag),a
1852 call bpl_init
1853
1854 ld a,(ix+000h)
1855 and 007h
1856 jr z,l0938h
1857 ld e,(ix+002h)
1858 ld d,(ix+003h)
1859 ld hl,(reg.pc)
1860 call cp_hl_de
1861 push bc
1862 call z,sub_0942h
1863 pop bc
1864 l0938h:
1865
1866 call bpl_next
1867 ex af,af'
1868 ret
1869
1870 sub_0942h:
1871 ex af,af'
1872 res 7,a
1873 ex af,af'
1874 ld e,(ix+006h)
1875 ld d,(ix+007h)
1876 ld a,d
1877 or e
1878 ld hl,0ffffh
1879 call nz,expr
1880 ld a,h
1881 or l
1882 jr z,l0969h
1883 ld e,(ix+004h)
1884 ld d,(ix+005h)
1885 dec de
1886 ld a,d
1887 or e
1888 jr z,l0974h
1889 ld (ix+004h),e
1890 ld (ix+005h),d
1891 l0969h:
1892 bit 4,(ix+000h)
1893 ret z
1894 ld a,001h
1895 ld (bp_p_cpu_flag),a
1896 ret
1897 l0974h:
1898 ex af,af'
1899 or (ix+000h)
1900 ex af,af'
1901 ret
1902
1903 bp_restore_mem:
1904 call bpl_init
1905
1906 bit 5,(ix+000h)
1907 res 5,(ix+000h)
1908 jr z,l099ah
1909 ld l,(ix+002h)
1910 ld h,(ix+003h)
1911 ld a,(l0003h)
1912 cp (hl)
1913 jr nz,l099ah
1914 ld a,(ix+001h)
1915 ld (hl),a
1916 l099ah:
1917 res 3,(ix+000h)
1918
1919 call bpl_next
1920 ret
1921
1922 bp_tst_@pc:
1923 call bpl_init
1924
1925 ld a,(ix+000h)
1926 and 003h
1927 jr z,bp_tst_e
1928 ld e,(ix+002h)
1929 ld d,(ix+003h)
1930 ld hl,(reg.pc)
1931 call cp_hl_de
1932 ret z
1933 bp_tst_e:
1934 call bpl_next
1935 sub a
1936 inc a
1937 ret
1938
1939 bp_trace_enter:
1940 call bp_get_freeslot
1941 ld (ix+004h),001h
1942 ld (ix+005h),000h
1943 ld (ix+002h),l
1944 ld (ix+003h),h
1945 ld (ix+006h),000h
1946 ld (ix+007h),000h
1947 ld a,(b_21e2_start)
1948 and a
1949 ld a,008h
1950 jr nz,bp_t_e
1951 rra
1952 bp_t_e:
1953 ld (ix+000h),a
1954 ret
1955
1956 bp_set_to_mem:
1957 call bpl_init
1958
1959 ld a,(ix+000h)
1960 and c
1961 jr z,l0a1dh
1962 set 5,(ix+000h)
1963 ld l,(ix+002h)
1964 ld h,(ix+003h)
1965 ld a,(hl)
1966 ld (ix+001h),a
1967 ld a,(l0003h)
1968 ld (hl),a
1969 and 038h
1970 ld h,000h
1971 ld l,a
1972 ld (hl),0c3h
1973 inc hl
1974 ld de,bpddtz
1975 ld (hl),e
1976 inc hl
1977 ld (hl),d
1978 l0a1dh:
1979
1980 call bpl_next
1981 ret
1982
1983 ;-------------------------------------------------------------------------------
1984
1985 user_go:
1986 sub a
1987 ld (b_21e2_start),a
1988 ld a,(bp_p_cpu_flag)
1989 and a
1990 call nz,p_cpustat
1991 call bp_tst_@pc
1992 ld c,007h
1993 jr nz,l0a41h
1994 ld a,001h
1995 ld (b_21e2_start),a
1996 call tc_set_bp
1997 ld c,008h
1998 l0a41h:
1999 call bp_set_to_mem
2000 ld sp,reg.l2
2001 pop hl
2002 pop de
2003 pop bc
2004 pop af
2005 exx
2006 ex af,af'
2007 pop af
2008 ld i,a
2009 pop iy
2010 pop ix
2011 pop af
2012 pop bc
2013 pop de
2014 pop hl
2015 ld sp,(reg_sp)
2016 jp reg.iff
2017
2018 ;-------------------------------------------------------------------------------
2019
2020 bp_clr_condition:
2021 ld a,(ix+000h)
2022 and 003h
2023 ret nz
2024 ld e,(ix+006h)
2025 ld d,(ix+007h)
2026 ld a,d
2027 or e
2028 ret z
2029 push bc
2030 ld h,d
2031 ld l,e
2032 sub a
2033 ld (ix+006h),a
2034 ld (ix+007h),a
2035 ld bc,0ffffh
2036 cpir
2037 l0a7dh:
2038 push de
2039 ld de,(expr_p1)
2040 call cp_hl_de
2041 pop de
2042 jr nc,l0a93h
2043 call sub_0a99h
2044 l0a8bh:
2045 ld a,(hl)
2046 ldi
2047 and a
2048 jr nz,l0a8bh
2049 jr l0a7dh
2050 l0a93h:
2051 ld (expr_p1),de
2052 pop bc
2053 ret
2054
2055 sub_0a99h:
2056 ld iy,bp_tab
2057 push de
2058 l0a9eh:
2059 ld e,(iy+006h)
2060 ld d,(iy+007h)
2061 call cp_hl_de
2062 jr z,l0ab0h
2063 ld de,BP_SIZE
2064 add iy,de
2065 jr l0a9eh
2066 l0ab0h:
2067 pop de
2068 ld (iy+006h),e
2069 ld (iy+007h),d
2070 ret
2071
2072 ;-------------------------------------------------------------------------------
2073 ; > Y
2074 ; examine all Y variables
2075 ; > Y[0..9]
2076 ; examine (and substitute) an Y variable
2077
2078 cmd_Y:
2079 call get.decdigit
2080 jr c,l0bc3h
2081 inc de
2082 push af
2083 call assert_eol
2084 pop af
2085 call sub_0bdch
2086 jp l0c15h
2087 l0bc3h:
2088 call assert_eol
2089 xor a
2090 l0bc7h:
2091 push af
2092 call sub_0bdch
2093 call outbl
2094 pop af
2095 push af
2096 call get_y_val
2097 call p_symbol
2098 pop af
2099 inc a
2100 push af
2101 rra
2102 push af
2103 ld c,11
2104 call c,p_align_@_sym
2105 pop af
2106 call nc,crlf
2107 pop af
2108 cp YREG_CNT
2109 jr c,l0bc7h
2110 ret
2111
2112 sub_0bdch:
2113 ld c,a
2114 ld b,0
2115 add a,'0'+080h
2116 ld de,msg_Y+1
2117 ld (de),a
2118 dec de
2119 ld hl,reg_Y
2120 add hl,bc
2121 add hl,bc
2122 ex de,hl
2123 ld c,003h
2124 jp l0c33h
2125
2126 ;-------------------------------------------------------------------------------
2127 ; > X
2128 ; eXamine (display) all cpu registers and
2129 ; the instruction at the current program counter
2130 ; > X register
2131 ; eXamine (and substitute) a register
2132
2133
2134 cmd_X:
2135 call skipbl
2136 call sub_0caeh
2137 jp nc,p_cpustat0
2138 call assert_eol
2139 ld a,b
2140 cp 01eh
2141 jr z,l0c5fh
2142 cp 01fh
2143 jr z,l0c4fh
2144 cp 01dh
2145 jp z,ERROR
2146 ex de,hl
2147 ld hl,t_reg_names
2148 call sel_dc_string
2149 l0c12h:
2150 call l0c33h
2151 l0c15h:
2152 call outbl
2153 push de
2154 push bc
2155 call get_line
2156 call skipbl
2157 jr z,l0c30h
2158 call sub_0363h
2159 ex de,hl
2160 pop bc
2161 pop hl
2162 ld (hl),e
2163 bit 0,c
2164 ret z
2165 inc hl
2166 ld (hl),d
2167 ret
2168 l0c30h:
2169 pop af
2170 pop hl
2171 ret
2172
2173 l0c33h:
2174 call pstr
2175 call pstr_inl
2176 dc '='
2177 ld a,(de)
2178 bit 0,c
2179 jp z,out_hex
2180 ld l,a
2181 inc de
2182 ld a,(de)
2183 dec de
2184 ld h,a
2185 bit 1,c
2186 jp z,out_hl
2187 jp out.hl.@
2188
2189 l0c4fh:
2190 call p_f
2191 ld a,0f3h
2192 ld (reg.iff),a
2193 scf
2194 call sub_0c6ah
2195 ld (reg.f),a
2196 ret
2197 l0c5fh:
2198 call p_f2
2199 and a
2200 call sub_0c6ah
2201 ld (reg.f2),a
2202 ret
2203
2204 sub_0c6ah:
2205 push af
2206 call outbl
2207 call assert_eol
2208 call get_line
2209 pop af
2210 ex af,af'
2211 ld b,0
2212 l0c76h:
2213 call skipbl
2214 ld a,b
2215 ret z
2216 push bc
2217 ld hl,t_flag_names
2218 call lookupch
2219 jp nc,ERROR
2220 inc b
2221 xor a
2222 scf
2223 nxt_f:
2224 rla
2225 djnz nxt_f
2226 pop bc
2227 jr c,l0c97h
2228 or b
2229 ld b,a
2230 jr l0c76h
2231
2232 l0c97h:
2233 ex af,af'
2234 jp nc,ERROR
2235 ex af,af'
2236 ld a,0fbh
2237 ld (reg.iff),a
2238 jr l0c76h
2239
2240 t_flag_names:
2241 db 'CNV H ZSE',0
2242
2243 sub_0caeh:
2244 call sub_0303h
2245 ret nc
2246 ld a,b
2247 add a,b
2248 add a,b
2249 ld hl,b_0cfa_start
2250 call add_hl_a
2251 ld c,(hl)
2252 inc hl
2253 ld a,(hl)
2254 inc hl
2255 ld h,(hl)
2256 ld l,a
2257 scf
2258 ret
2259
2260 t_reg_names:
2261 DC 'BC'''
2262 DC 'DE'''
2263 DC 'HL'''
2264 DC 'BC'
2265 DC 'DE'
2266 DC 'HL'
2267 DC 'A'''
2268 DC 'B'''
2269 DC 'C'''
2270 DC 'D'''
2271 DC 'E'''
2272 DC 'H'''
2273 DC 'L'''
2274 DC 'A'
2275 DC 'B'
2276 DC 'C'
2277 DC 'D'
2278 DC 'E'
2279 DC 'H'
2280 DC 'L'
2281 DC 'IX'
2282 DC 'IY'
2283 DC 'SP'
2284 DC 'PC'
2285 DC 'X'
2286 DC 'Y'
2287 DC 'S'
2288 DC 'P'
2289 DC 'I'
2290 DC 'IP'
2291 DC 'F'''
2292 DC 'F'
2293 DB 0
2294
2295 b_0cfa_start:
2296 db 003h
2297 dw reg.c2
2298 db 003h
2299 dw reg.e2
2300 db 003h
2301 dw reg.l2
2302 db 003h
2303 dw reg.c
2304 db 003h
2305 dw reg.e
2306 db 003h
2307 dw reg.l
2308 db 000h
2309 dw reg.a2
2310 db 000h
2311 dw reg.b2
2312 db 000h
2313 dw reg.c2
2314 db 000h
2315 dw reg.d2
2316 db 000h
2317 dw reg.e2
2318 db 000h
2319 dw reg.h2
2320 db 000h
2321 dw reg.l2
2322 db 000h
2323 dw reg.a
2324 db 000h
2325 dw reg.b
2326 db 000h
2327 dw reg.c
2328 db 000h
2329 dw reg.d
2330 db 000h
2331 dw reg.e
2332 db 000h
2333 dw reg.h
2334 db 000h
2335 dw reg.l
2336 db 003h
2337 dw reg.ix
2338 db 003h
2339 dw reg.iy
2340 db 003h
2341 dw reg_sp
2342 db 003h
2343 dw reg.pc
2344 db 003h
2345 dw reg.ix
2346 db 003h
2347 dw reg.iy
2348 db 003h
2349 dw reg_sp
2350 db 003h
2351 dw reg.pc
2352 db 000h
2353 dw reg.i
2354 db 003h
2355 dw l004eh
2356 db 000h
2357 dw reg.f2
2358 db 000h
2359 dw reg.f
2360
2361 ;-------------------------------------------------------------------------------
2362 ; > S [startaddr]
2363 ; Substitute memory
2364
2365 cmd_S:
2366 ld hl,(last_S)
2367 call get_lastarg_def
2368 l0d60h:
2369 ld (last_S),hl
2370 call out.hl.@
2371 call outbl
2372 ld a,(hl)
2373 call out_hex
2374 call outbl2
2375 call get_line
2376 call skipbl
2377 inc hl
2378 jr z,l0d60h
2379 dec hl
2380 inc de
2381 cp '.'
2382 jr nz,cmds_dash
2383 call get_char_upper
2384 or a
2385 jr nz,l0d8ah
2386 ret
2387 cmds_dash:
2388 jp z,assert_eol
2389 cp '-'
2390 jr nz,l0d8ah
2391 call get_char_upper
2392 or a
2393 dec hl
2394 jr z,l0d60h
2395 inc hl
2396 l0d8ah:
2397 dec de
2398 call sub_0ef8h
2399 jr l0d60h
2400
2401 ;-------------------------------------------------------------------------------
2402 ; > @
2403 ; examine (substitute) displacement register @
2404
2405 cmd_@:
2406 call assert_eol
2407 ld hl,msg_@
2408 ld de,var.@
2409 ld c,001h
2410 jp l0c12h
2411
2412 msg_@:
2413 dc '@'
2414
2415 ;-------------------------------------------------------------------------------
2416 ; >>I [port]
2417 ; Input a byte from port
2418
2419 cmd_I:
2420 ld hl,cmd_I
2421 ld (cmd_rpt),hl
2422 ld hl,(last_I)
2423 call get_lastarg_def
2424 ld (last_I),hl
2425 ld b,h
2426 ld c,l
2427 in a,(c)
2428 push af
2429 call out_hex
2430 call outbl4
2431 pop af
2432 call out.bin.b
2433 jp crlf
2434
2435 ;-------------------------------------------------------------------------------
2436 ; >>O [byte] [port]
2437 ; Output a byte to a port
2438
2439 cmd_O:
2440 ld hl,cmd_O
2441 ld (cmd_rpt),hl
2442 ld hl,(last_O_val)
2443 call get_arg_def
2444 ld a,l
2445 ld (last_O_val),a
2446 push af
2447 call next_arg
2448 ld hl,(last_O_addr)
2449 call get_lastarg_def
2450 ld (last_O_addr),hl
2451 ld b,h
2452 ld c,l
2453 pop af
2454 out (c),a
2455 ret
2456
2457 ;-------------------------------------------------------------------------------
2458 ; > Vstartaddr endaddr targetaddr
2459 ; Verify (compare) two memory areas
2460
2461 cmd_V:
2462 call sub_034eh
2463 l0dedh:
2464 push bc
2465 ld a,(de)
2466 ld b,(hl)
2467 cp b
2468 jr z,l0e10h
2469 ld c,a
2470 call out.hl.@
2471 call outbl
2472 ld a,b
2473 call out_hex
2474 call outbl2
2475 ld a,c
2476 call out_hex
2477 call outbl
2478 ex de,hl
2479 call out.hl.@
2480 ex de,hl
2481 call crlf
2482 l0e10h:
2483 pop bc
2484 inc hl
2485 inc de
2486 dec bc
2487 ld a,b
2488 or c
2489 jr nz,l0dedh
2490 ret
2491
2492 ;-------------------------------------------------------------------------------
2493 ; > M[V] startaddr endaddr destaddr
2494 ; Move memory [and verify]
2495
2496 cmd_M:
2497 call get_char_upper
2498 cp 'V'
2499 jr nz,l0e1fh
2500 inc de
2501 l0e1fh:
2502 push af
2503 call sub_034eh
2504 push hl
2505 push de
2506 push bc
2507 call cp_hl_de
2508 jr nc,cmdm_up
2509 add hl,bc
2510 ex de,hl
2511 add hl,bc
2512 ex de,hl
2513 dec hl
2514 dec de
2515 lddr
2516 db 01h ;swallow ldir instruction (ld bc,...)
2517 cmdm_up:
2518 ldir
2519 pop bc
2520 pop de
2521 pop hl
2522 pop af
2523 jr z,l0dedh
2524 ret
2525
2526 ;-------------------------------------------------------------------------------
2527 ; > H
2528 ; display Highest load address of last filed loaded, Maximum "High"
2529 ; off all loaded files, and Top address of available memory
2530 ; > HS
2531 ; display symbol list
2532 ; > H expression
2533 ; evaluate expression and display result in hex, decimal and other formats
2534 ; > H expression expression
2535 ; display sum und difference of expressions
2536
2537 cmd_H:
2538 call get_char_upper
2539 cp 'S'
2540 jr z,p_sym_list
2541
2542 call expr
2543 jp c,p_max_high0
2544 call next_arg
2545 push hl
2546 call expr
2547 push af
2548 call assert_eol
2549 pop af
2550 ex de,hl
2551 pop hl
2552 jr c,l0e5eh
2553 push hl
2554 push de
2555 add hl,de
2556 call l0e5eh
2557 pop de
2558 pop hl
2559 and a
2560 sbc hl,de
2561 l0e5eh:
2562 call out_hl
2563 call outbl2
2564 call out_hl_neg
2565 call outbl4
2566 call out.hl.dec
2567 call outbl2
2568 call out_hl_dec_neg
2569 call outbl4
2570 call out.bin.w
2571 call outbl
2572 ld a,l
2573 call out.ascii
2574 call outbl2
2575 call p_symbol
2576 jp crlf
2577
2578 p_sym_list:
2579 inc de
2580 call assert_eol
2581 ld a,(symlen_cur)
2582 add a,7
2583 ld b,a
2584 ld c,0
2585 ld hl,ddtz_base+2
2586 psym_nxtsym:
2587 ld d,(hl)
2588 dec hl
2589 ld e,(hl)
2590 dec hl
2591 ld a,(hl)
2592 cp 0c3h
2593 jr z,psym_e
2594
2595 call p_goto_col
2596 ex de,hl
2597 call out_hl
2598 call outbl
2599 ex de,hl
2600 call p_symstr
2601
2602 ld a,c
2603 add b
2604 ld c,a
2605 ld a,(screen_width)
2606 sub b
2607 cp c
2608 jr nc,psym_nxtsym
2609
2610 call crlf
2611 ld c,0
2612 jr psym_nxtsym
2613
2614 psym_e:
2615 ld a,c
2616 or a
2617 ret z
2618 jp crlf
2619
2620
2621 ;-------------------------------------------------------------------------------
2622 ; > Q[J] startaddr endaddr bytes
2623 ; Query memory for a byte string [Justified]
2624
2625 cmd_Q:
2626 call get_char_upper
2627 sub 'J'
2628 ld (cmd_Q_jopt),a
2629 jr nz,l0e8dh
2630 inc de
2631 l0e8dh:
2632 call get_arg_range
2633 push bc
2634 push hl
2635 call sub_0ee6h
2636 pop hl
2637 l0e96h:
2638 call sub_0ed7h
2639 jr nz,l0eb0h
2640 push bc
2641 push hl
2642 ld a,(cmd_Q_jopt)
2643 or a
2644 jr nz,l0ea7h
2645 ld bc,-8
2646 add hl,bc
2647 l0ea7h:
2648 ld bc,16
2649 and a
2650 call sub_0f58h
2651 pop hl
2652 pop bc
2653 l0eb0h:
2654 inc hl
2655 ex (sp),hl
2656 dec hl
2657 ld a,h
2658 or l
2659 ex (sp),hl
2660 jr nz,l0e96h
2661 pop bc
2662 ret
2663
2664 ;-------------------------------------------------------------------------------
2665 ; > Z startaddr endaddr bytes
2666 ; Zap (fill) memory with a byte string
2667
2668 cmd_Z:
2669 call get_arg_range
2670 push bc
2671 push hl
2672 call sub_0ee6h
2673 ld a,b
2674 pop hl
2675 pop bc
2676 push hl
2677 ex de,hl
2678 l0ec7h:
2679 ldi
2680 jp po,l0ed3h
2681 dec a
2682 jr nz,l0ec7h
2683 pop hl
2684 ldir
2685 ret
2686 l0ed3h:
2687 pop hl
2688 ret
2689
2690 sub_0ed7h:
2691 push hl
2692 push de
2693 push bc
2694 l0edah:
2695 ld a,(de)
2696 cp (hl)
2697 jr nz,l0ee2h
2698 inc de
2699 inc hl
2700 djnz l0edah
2701 l0ee2h:
2702 pop bc
2703 pop de
2704 pop hl
2705 ret
2706
2707 sub_0ee6h:
2708 ld hl,conbuf+1
2709 call sub_0ef7h
2710 ld de,conbuf+1
2711 and a
2712 sbc hl,de
2713 ld b,l
2714 ret nz
2715 jp ERROR
2716
2717 sub_0ef7h:
2718 db 0e6h ; and 037h (clear carry)
2719 sub_0ef8h:
2720 scf
2721 l0ef9h:
2722 push af
2723 call next_arg
2724 cp 'W'
2725 jr nz,l0f0eh
2726 inc de
2727 push hl
2728 call sub_035dh
2729 ex de,hl
2730 ex (sp),hl
2731 ld (hl),e
2732 inc hl
2733 ld a,d
2734 pop de
2735 jr l0f1ah
2736 l0f0eh:
2737 cp ''''
2738 jr z,l0f1eh
2739 push hl
2740 call expr
2741 ld a,l
2742 pop hl
2743 jr c,l0f42h
2744 l0f1ah:
2745 ld (hl),a
2746 inc hl
2747 jr l0f3ah
2748 l0f1eh:
2749 inc de
2750 ld a,(de)
2751 cp ''''
2752 jr z,l0f2bh
2753 or a
2754 jr z,l0f42h
2755 l0f27h:
2756 ld (hl),a
2757 inc hl
2758 jr l0f1eh
2759 l0f2bh:
2760 inc de
2761 ld a,(de)
2762 cp ''''
2763 jr z,l0f27h
2764 cp '.'
2765 jr nz,l0f3ah
2766 inc de
2767 dec hl
2768 set 7,(hl)
2769 inc hl
2770 l0f3ah:
2771 pop af
2772 jr nc,l0ef9h
2773 ld (last_S),hl
2774 jr l0ef9h
2775 l0f42h:
2776 pop af
2777 ret nc
2778 ld (last_S),hl
2779 ret
2780
2781 ;-------------------------------------------------------------------------------
2782 ; >>D [startaddr] [endaddr]
2783 ; Display memory in hex and ASCII
2784
2785 cmd_D:
2786 ld hl,cmd_D
2787 ld (cmd_rpt),hl
2788 ld hl,(last_D)
2789 ld bc,128
2790 call sub_0377h
2791 scf
2792 sub_0f58h:
2793 push bc
2794 push de
2795 push hl
2796 push af
2797 l0f5ch:
2798 call out.hl.@
2799 call z,outbl2
2800 call outbl
2801 ld de,0
2802 l0f68h:
2803 ld a,(hl)
2804 inc hl
2805 call out_hex
2806 call outbl
2807 dec bc
2808 inc e
2809 ld a,e
2810 cp 010h
2811 jr z,l0f80h
2812 and 003h
2813 call z,outbl
2814 ld a,b
2815 or c
2816 jr nz,l0f68h
2817 l0f80h:
2818 call outbl
2819 and a
2820 sbc hl,de
2821 l0f86h:
2822 ld a,(hl)
2823 call sub_0fa3h
2824 call outchar
2825 inc hl
2826 dec e
2827 jr nz,l0f86h
2828 pop af
2829 push af
2830 jr nc,l0f97h
2831 ld (last_D),hl
2832 l0f97h:
2833 call crlf
2834 ld a,b
2835 or c
2836 jr nz,l0f5ch
2837 pop af
2838 pop hl
2839 pop de
2840 pop bc
2841 ret
2842
2843 sub_0fa3h:
2844 and 07fh
2845 cp 07fh
2846 jr z,l0fach
2847 cp ' '
2848 ret nc
2849 l0fach:
2850 ld a,'.'
2851 ret
2852
2853 ;-------------------------------------------------------------------------------
2854 ; > Fcommandline
2855 ; specifiy filenames and command line
2856
2857 cmd_F:
2858 push de
2859 ld hl,DMA_BUF+1
2860 ld (hl),' '
2861 inc hl
2862 l0fb6h:
2863 call get_char_upper
2864 ld (hl),a
2865 inc hl
2866 inc de
2867 and a
2868 jr nz,l0fb6h
2869 ld a,l
2870 sub DMA_BUF+2
2871 ld (DMA_BUF),a
2872 pop hl
2873 ld de,dfcb1
2874 call parse_filename
2875 ld de,dfcb2
2876 call parse_filename
2877 ;fall thru
2878
2879 cpy_fcb2:
2880 ld hl,dfcb2
2881 ld de,fcbsym
2882 ld bc,16
2883 ldir
2884 ret
2885
2886 parse_filename:
2887 call sub_102ch
2888 push de
2889 push bc
2890 ld b,(hl)
2891 inc hl
2892 ld a,(hl)
2893 cp ':'
2894 jr nz,l0fe1h
2895 inc hl
2896 ld a,b
2897 sub 040h
2898 and 01fh
2899 jr l0fe3h
2900 l0fe1h:
2901 dec hl
2902 xor a
2903 l0fe3h:
2904 ld (de),a
2905 inc de
2906 ld b,8
2907 call sub_0ff2h
2908 ld b,3
2909 call sub_0ff2h
2910 pop bc
2911 pop de
2912 ret
2913
2914 sub_0ff2h:
2915 call sub_1012h
2916 jr z,l0ffeh
2917 inc hl
2918 ld (de),a
2919 inc de
2920 djnz sub_0ff2h
2921 jr l1003h
2922 l0ffeh:
2923 ld a,c
2924 l0fffh:
2925 ld (de),a
2926 inc de
2927 djnz l0fffh
2928 l1003h:
2929 call sub_1012h
2930 inc hl
2931 jr nz,l1003h
2932 cp '*'
2933 jr z,l1003h
2934 cp '.'
2935 ret z
2936 dec hl
2937 ret
2938
2939 sub_1012h:
2940 ld a,(hl)
2941 ld c,' '
2942 and 01fh
2943 ret z
2944 ld a,(hl)
2945 cp ' '
2946 ret z
2947 call sub_1043h
2948 ret z
2949 cp '/'
2950 ret z
2951 cp '.'
2952 ret z
2953 ld c,'?'
2954 call toupper
2955 cp '*'
2956 ret
2957
2958 l102bh:
2959 inc hl
2960 sub_102ch:
2961 ld a,(hl)
2962 cp '/'
2963 jr z,l103bh
2964 call sub_1043h
2965 jr z,l102bh
2966 l1036h:
2967 cp ' '
2968 jr z,l102bh
2969 ret
2970
2971 l103bh:
2972 ld a,(hl)
2973 cp ' '+1
2974 jr c,l1036h
2975 inc hl
2976 jr l103bh
2977
2978 sub_1043h:
2979 cp '='
2980 ret z
2981 cp '_'
2982 ret z
2983 cp ','
2984 ret
2985
2986 ;-------------------------------------------------------------------------------
2987
2988 setup_fcb:
2989 push de
2990 ld hl,12
2991 add hl,de
2992 xor a
2993 ld b,21
2994 l1052h:
2995 ld (hl),a
2996 inc hl
2997 djnz l1052h
2998 ld de,DMA_BUF
2999 ld c,BDOS_SETDMA
3000 call ddtz_bdos
3001 pop de
3002 ret
3003
3004 ;-------------------------------------------------------------------------------
3005
3006 file_open:
3007 ld (cur_fcb),de
3008 call setup_fcb
3009 ld c,BDOS_OPEN
3010 call ddtz_bdos
3011 inc a
3012 jp z,ERROR
3013 ld a,080h
3014 ld (cmdR_rindex),a
3015 ret
3016
3017 read_byte:
3018 ld a,(cmdR_rindex)
3019 cp 080h
3020 jr nz,l1111h
3021 call read_sector
3022 ld a,01ah
3023 ret z
3024 sub a
3025 l1111h:
3026 inc a
3027 ld (cmdR_rindex),a
3028 push hl
3029 add a,07fh
3030 ld l,a
3031 ld h,000h
3032 ld a,(hl)
3033 pop hl
3034 cp 01ah
3035 ret
3036
3037 read_sector:
3038 push hl
3039 push de
3040 push bc
3041 ld de,(cur_fcb)
3042 ld c,BDOS_READ
3043 call ddtz_bdos
3044 sub a,1
3045 jr z,l1132h
3046 jr nc,error2
3047 l1132h:
3048 pop bc
3049 pop de
3050 pop hl
3051 ret
3052
3053 cmdR_storebyte:
3054 push af
3055 push de
3056 ld de,TPA
3057 call cp_hl_de
3058 jr c,error2
3059 ld de,(BDOS+1)
3060 call cp_hl_de
3061 jr nc,error2
3062 ld de,(high_load)
3063 call cp_hl_de
3064 jr c,l1157h
3065 ld (high_load),hl
3066 l1157h:
3067 ld de,(max_load)
3068 call cp_hl_de
3069 jr c,l1163h
3070 ld (max_load),hl
3071 l1163h:
3072 pop de
3073 pop af
3074 ld (hl),a
3075 ret
3076
3077 strncmp:
3078 ld a,(de)
3079 cp (hl)
3080 inc de
3081 inc hl
3082 ret nz
3083 djnz strncmp
3084 ret
3085
3086 str_hex:
3087 db 'HEX'
3088
3089 read_hexchar:
3090 call read_hexdigit
3091 rlca
3092 rlca
3093 rlca
3094 rlca
3095 ld d,a
3096 call read_hexdigit
3097 add a,d
3098 ld d,a
3099 add a,c
3100 ld c,a
3101 ld a,d
3102 ret
3103
3104 read_hexdigit:
3105 call read_byte
3106 jr z,error2
3107 hex_digit_v:
3108 call hex_digit
3109 ret nc
3110 error2:
3111 jp ERROR
3112
3113 read_hexbyte:
3114 call read_byte
3115 read_hexbyte0:
3116 push bc
3117 call hex_digit_v
3118 rlca
3119 rlca
3120 rlca
3121 rlca
3122 ld c,a
3123 call read_byte
3124 call hex_digit_v
3125 or c
3126 pop bc
3127 ret
3128
3129 ;-------------------------------------------------------------------------------
3130 ; > R [displacement]
3131 ; Read a binary or hex file and or symbol file [add displacement]
3132
3133 cmd_R:
3134 ld hl,0
3135 call get_lastarg_def
3136 read_file:
3137 ld de,dfcb1+1
3138 ld a,(de)
3139 cp '?'
3140 jr z,read_symfile
3141 dec de
3142 push hl
3143 ld hl,0
3144 ld (high_load),hl
3145 call file_open
3146 ld hl,dfcb1+9
3147 ld de,str_hex
3148 ld b,3
3149 call strncmp
3150 pop hl
3151 jr z,read_hexfile
3152 ld de,TPA
3153 push hl
3154 add hl,de
3155 l108eh:
3156 call read_sector
3157 jr nz,read_file_nxt
3158 pop hl
3159 jr read_symfile
3160
3161 read_file_nxt:
3162 ld de,DMA_BUF
3163 ld b,080h
3164 l109ah:
3165 ld a,(de)
3166 call cmdR_storebyte
3167 inc de
3168 inc hl
3169 djnz l109ah
3170 jr l108eh
3171
3172 read_hexfile:
3173 push hl
3174 l10aeh:
3175 call read_byte ; RECORD MARK
3176 jr z,rdhex_done
3177 cp ':'
3178 jr nz,l10aeh
3179 ld c,0
3180 call read_hexchar ; RECLEN
3181 ld b,a
3182 call read_hexchar ; LOAD ADDR H
3183 ld h,a
3184 call read_hexchar ; LOAD ADDR L
3185 ld l,a
3186 ld a,b
3187 and a
3188 jr z,rdhex_done
3189 call read_hexchar ; RECTYP
3190 l10cch:
3191 call read_hexchar ; DATA
3192 pop de
3193 push de
3194 push hl
3195 add hl,de
3196 call cmdR_storebyte
3197 pop hl
3198 inc hl
3199 djnz l10cch
3200 call read_hexchar ; CHKSUM
3201 ld a,c
3202 and a
3203 jr nz,error3
3204 jr l10aeh
3205 rdhex_done:
3206 pop hl
3207 jr read_symfile
3208
3209 read_symfile:
3210 ld de,fcbsym+1
3211 ld a,(de)
3212 cp ' '
3213 jp z,p_max_high
3214
3215 push hl ; offset
3216 call pstr_inl
3217 db 'SYMBOLS',CR,LF+80h
3218
3219 dec de
3220 call file_open
3221 ld a,(symattrib)
3222 ld c,a
3223 rs_1:
3224 call read_byte
3225 rs_2:
3226 pop de ; offset
3227 cp 1ah
3228 jp z,p_max_high
3229 push de ; offset
3230 cp '!'
3231 jr c,rs_1
3232 call read_hexbyte0 ; symval H
3233 ld h,a
3234 call read_hexbyte ; symval L
3235 ld l,a
3236 add hl,de
3237 call read_byte
3238 cp ' '
3239 jr z,rs_4
3240 rs_3: call read_byte
3241 cp ' '
3242 jr nc,rs_3
3243 jr rs_2
3244
3245 rs_4:
3246 push hl ; symval
3247 ld hl,(BDOS+1) ;
3248 ld b,0 ; setup symlen
3249 rs_5:
3250 dec hl ;
3251 call read_byte ; next char of symbol name
3252 call test_sym_char ; valid char?
3253 jr nz,rs_6
3254 bit SYMCASE_CONV,c
3255 jr z,rs_51
3256 call toupper
3257 bit SYMCASE_LOWER,c
3258 call nz,tolower
3259 rs_51:
3260 ld (hl),a ;
3261 inc b ; symlen++
3262 ld a,(symlen_max) ;
3263 cp b ;
3264 jr nc,rs_5 ;
3265 error3:
3266 jp ERROR ;
3267
3268 rs_6:
3269 call test_symterm_ch
3270 jr nz,error3
3271
3272 push bc ; symlen
3273 ex de,hl ;
3274 ld hl,(BDOS+1) ;
3275 inc hl ;
3276 ld c,(hl) ;
3277 inc hl ;
3278 ld b,(hl) ;
3279 ex de,hl
3280 ld (hl),b ;
3281 dec hl ;
3282 ld (hl),c ;
3283 dec hl ;
3284 ld (hl),0c3h ;
3285
3286 ld de,(max_load) ;
3287 call cp_hl_de ;
3288 jr c,error3 ;
3289 ld de,(reg_sp) ;
3290 call cp_hl_de ;
3291 jr nc,rs_61 ;
3292 ld (reg_sp),hl ;
3293 rs_61:
3294 ld de,(BDOS+1) ;
3295 ld (BDOS+1),hl ;
3296 ex de,hl ;
3297 pop bc ; symlen
3298 ld (hl),b ;
3299 inc hl ;
3300 pop de ; symval
3301 ld (hl),e ;
3302 inc hl ;
3303 ld (hl),d ;
3304 ld a,b ;
3305 ld hl,symlen_cur ;
3306 cp (hl) ; new max?
3307 jr c,$+3 ;
3308 ld (hl),a ;
3309 jp rs_1 ;
3310
3311
3312 ; test for valid character for symbols
3313 ; return z if valid
3314
3315 test_sym_char:
3316 cp '$'
3317 ret z
3318 cp '%'
3319 ret z
3320 cp '.'
3321 ret z
3322 cp '_'
3323 ret z
3324 call test_alphanum
3325 ret c ; cy == 1 --> z == 0
3326 cp a ; return z
3327 ret
3328
3329
3330 ; check if char is in [0..9,?,@,A..Z,a..z]
3331 ; return cy if invalid
3332 ; return nc if valid alfanumeric char
3333
3334 test_alphanum:
3335 cp 'z'
3336 ret z
3337 ccf
3338 ret c
3339 cp 'a'
3340 ret nc
3341 cp 'Z'
3342 ret z
3343 ccf
3344 ret c
3345 cp '?'
3346 ret nc
3347 test_numeral:
3348 cp '9'
3349 ret z
3350 ccf
3351 ret c
3352 cp '0'
3353 ret
3354
3355 test_symterm_ch:
3356 cp CR
3357 ret z
3358 cp LF
3359 ret z
3360 test_whitespace:
3361 cp ' '
3362 ret z
3363 cp TAB
3364 ret
3365
3366 ;-------------------------------------------------------------------------------
3367
3368 p_max_high0:
3369 call assert_eol
3370 p_max_high:
3371 call pstr_inl
3372 DC 'High = '
3373 ld hl,(high_load)
3374 call out_hl
3375 call pstr_inl
3376 DC ' Max = '
3377 ld hl,(max_load)
3378 call out_hl
3379 call pstr_inl
3380 DC ' Top = '
3381 ld hl,(BDOS+1)
3382 call out_hl
3383 jp crlf
3384
3385 ;-------------------------------------------------------------------------------
3386 ; > Wstartaddr endaddr
3387 ; Write a file to disk
3388
3389 cmd_W:
3390 call get_arg_range
3391 call assert_eol
3392 push hl
3393 ld a,c
3394 add a,07fh
3395 jr nc,l11adh
3396 inc b
3397 l11adh:
3398 and 080h
3399 ld c,a
3400 push bc
3401 ld a,(dfcb1+1)
3402 cp ' '
3403 jr z,error4
3404 ld de,dfcb1
3405 call setup_fcb
3406 push de
3407 ld c,BDOS_DELETE
3408 call ddtz_bdos
3409 pop de
3410 ld c,BDOS_CREATE
3411 call ddtz_bdos
3412 inc a
3413 jr z,error4
3414 pop bc
3415 pop hl
3416 l11cch:
3417 ld a,b
3418 or c
3419 jr z,close_file
3420 push bc
3421 ld de,080h ; DMA_BUF
3422 ld b,d
3423 ld c,e
3424 ldir
3425 call write_sector
3426 ex (sp),hl
3427 ld bc,0ff80h
3428 add hl,bc
3429 ex (sp),hl
3430 pop bc
3431 jr l11cch
3432
3433 write_sector:
3434 push hl
3435 ld de,dfcb1
3436 ld c,BDOS_WRITE
3437 call ddtz_bdos
3438 pop hl
3439 and a
3440 ret z
3441 call close_file
3442 error4:
3443 jp ERROR
3444
3445 close_file:
3446 ld de,dfcb1
3447 ld c,BDOS_CLOSE
3448 jp ddtz_bdos
3449
3450 ;-------------------------------------------------------------------------------
3451 ; > A [startaddr]
3452 ; Assemble Zilog Z180 mnemonics
3453
3454 cmd_A:
3455 ld hl,(last_A)
3456 call get_lastarg_def
3457 ld (last_A),hl
3458 ld (cmd_A_prev),hl
3459 ld hl,cmda_restart
3460 ld (error_func),hl
3461 ld (l1262h),sp
3462 cmda_loop:
3463 ld hl,(last_A)
3464 ld (var.$),hl
3465 push hl
3466 call p_disas_line
3467 ld c,19
3468 call p_align_@_sym
3469 ld c,b
3470 push bc
3471 call get_line
3472 pop bc
3473 pop hl
3474 call skipbl
3475 cp '.'
3476 ret z
3477 cp '-'
3478 jr nz,l124bh
3479 ld hl,(cmd_A_prev)
3480 jr cmda_lpend
3481 l124bh:
3482 push hl
3483 pop iy
3484 push hl
3485 and a
3486 call nz,asemble_line
3487 ld b,0
3488 pop hl
3489 ld (cmd_A_prev),hl
3490 add hl,bc
3491 cmda_lpend:
3492 ld (last_A),hl
3493 jr cmda_loop
3494
3495 cmda_restart:
3496 call p_msg_error
3497 ld sp,(l1262h)
3498 jr cmda_loop
3499
3500 asemble_line:
3501 call skipbl
3502 ld hl,t_MNEMONICS
3503 call sub_030ah
3504 jr nc,error4
3505 call skipbl
3506 push de
3507 ld a,b
3508 add a,b
3509 add a,b
3510 ld hl,b_1289_start
3511 call add_hl_a
3512 ld e,(hl)
3513 inc hl
3514 ld d,(hl)
3515 inc hl
3516 ld b,(hl)
3517 ex de,hl
3518 pop de
3519
3520 CALL_HL:
3521 jp (hl)
3522
3523 ;-------------------------------------------------------------------------------
3524
3525 b_1289_start:
3526 dw as.ADC_SBC ;ADC
3527 db 088h ;
3528 dw as.ADD ;ADD
3529 db 080h ;
3530 dw as.AND_CP_OR_SUB_XOR ;AND
3531 db 0a0h ;
3532 dw as.BITOP ;BIT
3533 db 040h ;
3534 dw as.CALL ;CALL
3535 db 0c4h ;
3536 dw as.opc.noarg ;CCF
3537 db 03fh ;
3538 dw as.AND_CP_OR_SUB_XOR ;CP
3539 db 0b8h ;
3540 dw gen.opc.ED2 ;CPD
3541 db 0a9h ;
3542 dw gen.opc.ED2 ;CPDR
3543 db 0b9h ;
3544 dw gen.opc.ED2 ;CPI
3545 db 0a1h ;
3546 dw gen.opc.ED2 ;CPIR
3547 db 0b1h ;
3548 dw as.opc.noarg ;CPL
3549 db 02fh ;
3550 dw as.opc.noarg ;DAA
3551 db 027h ;
3552 dw as.DEC_INC ;DEC
3553 db 005h ;
3554 dw as.opc.noarg ;DI
3555 db 0f3h ;
3556 dw as.DJNZ ;DJNZ
3557 db 010h ;
3558 dw as.opc.noarg ;EI
3559 db 0fbh ;
3560 dw as.EX ;EX
3561 db 0e3h ;
3562 dw as.opc.noarg ;EXX
3563 db 0d9h ;
3564 dw as.opc.noarg ;HALT
3565 db 076h ;
3566 dw as.IM ;IM
3567 db 046h ;
3568 dw as.IN ;IN
3569 db 040h ;
3570 dw as.DEC_INC ;INC
3571 db 004h ;
3572 dw gen.opc.ED2 ;IND
3573 db 0aah ;
3574 dw gen.opc.ED2 ;INDR
3575 db 0bah ;
3576 dw gen.opc.ED2 ;INI
3577 db 0a2h ;
3578 dw gen.opc.ED2 ;INIR
3579 db 0b2h ;
3580 dw as.JP ;JP
3581 db 0c2h ;
3582 dw as.JR ;JR
3583 db 020h ;
3584 dw as.LD ;LD
3585 db 040h ;
3586 dw gen.opc.ED2 ;LDD
3587 db 0a8h ;
3588 dw gen.opc.ED2 ;LDDR
3589 db 0b8h ;
3590 dw gen.opc.ED2 ;LDI
3591 db 0a0h ;
3592 dw gen.opc.ED2 ;LDIR
3593 db 0b0h ;
3594 dw gen.opc.ED2 ;NEG
3595 db 044h ;
3596 dw as.opc.noarg ;NOP
3597 db 000h ;
3598 dw as.AND_CP_OR_SUB_XOR ;OR
3599 db 0b0h ;
3600 dw gen.opc.ED2 ;OTDR
3601 db 0bbh ;
3602 dw gen.opc.ED2 ;OTIR
3603 db 0b3h ;
3604 dw as.OUT ;OUT
3605 db 041h ;
3606 dw gen.opc.ED2 ;OUTD
3607 db 0abh ;
3608 dw gen.opc.ED2 ;OUTI
3609 db 0a3h ;
3610 dw as.POP_PUSH ;POP
3611 db 0c1h ;
3612 dw as.POP_PUSH ;PUSH
3613 db 0c5h ;
3614 dw as.BITOP ;RES
3615 db 080h ;
3616 dw as.RET ;RET
3617 db 0c0h ;
3618 dw gen.opc.ED2 ;RETI
3619 db 04dh ;
3620 dw gen.opc.ED2 ;RETN
3621 db 045h ;
3622 dw as.SHIFTOP ;RL
3623 db 010h ;
3624 dw as.opc.noarg ;RLA
3625 db 017h ;
3626 dw as.SHIFTOP ;RLC
3627 db 000h ;
3628 dw as.opc.noarg ;RLCA
3629 db 007h ;
3630 dw gen.opc.ED2 ;RLD
3631 db 06fh ;
3632 dw as.SHIFTOP ;RR
3633 db 018h ;
3634 dw as.opc.noarg ;RRA
3635 db 01fh ;
3636 dw as.SHIFTOP ;RRC
3637 db 008h ;
3638 dw as.opc.noarg ;RRCA
3639 db 00fh ;
3640 dw gen.opc.ED2 ;RRD
3641 db 067h ;
3642 dw as.RST ;RST
3643 db 0c7h ;
3644 dw as.ADC_SBC ;SBC
3645 db 098h ;
3646 dw as.opc.noarg ;SCF
3647 db 037h ;
3648 dw as.BITOP ;SET
3649 db 0c0h ;
3650 dw as.SHIFTOP ;SLA
3651 db 020h ;
3652 dw as.SHIFTOP ;SRA
3653 db 028h ;
3654 dw as.SHIFTOP ;SRL
3655 db 038h ;
3656 dw as.AND_CP_OR_SUB_XOR ;SUB
3657 db 090h ;
3658 dw as.AND_CP_OR_SUB_XOR ;XOR
3659 db 0a8h ;
3660
3661 dw as.IN0 ;IN0
3662 db 000h ;
3663 dw as.MLT ;MLT
3664 db 04ch ;
3665 dw gen.opc.ED2 ;OTDM
3666 db 08bh ;
3667 dw gen.opc.ED2 ;OTDMR
3668 db 09bh ;
3669 dw gen.opc.ED2 ;OTIM
3670 db 083h ;
3671 dw gen.opc.ED2 ;OTIMR
3672 db 093h ;
3673 dw as.OUTO ;OUT0
3674 db 001h ;
3675 dw gen.opc.ED2 ;SLP
3676 db 076h ;
3677 dw as.TST ;TST
3678 db 004h ;
3679 dw as.TSTIO ;TSTIO
3680 db 074h ;
3681
3682 ;-------------------------------------------------------------------------------
3683
3684 as.TST:
3685 call arg.r_HL_A ;
3686 jr nc,as.tst_0
3687 rlca
3688 rlca
3689 rlca
3690 add a,b
3691 ld b,a
3692 jp gen.opc.ED2
3693 as.tst_0:
3694 ld b,064h
3695 as.TSTIO:
3696 call arg.imm_8bit ;
3697 jr as.store_io0
3698
3699 as.IN0:
3700 call arg.r_HL_A ;
3701 jr nc,error5
3702 cp 006h
3703 jr z,error5
3704 rlca
3705 rlca
3706 rlca
3707 add a,b
3708 ld b,a
3709 call assert_comma ;
3710 call arg.addr_8bit ;
3711 jr as.store_io0
3712
3713 as.OUTO:
3714 call arg.addr_8bit ;
3715 call assert_comma ;
3716 call arg.r_HL_A ;
3717 jr nc,error5
3718 cp 006h
3719 jr z,error5
3720 rlca
3721 rlca
3722 rlca
3723 add a,b
3724 ld b,a
3725
3726 as.store_io0:
3727 call assert_eol
3728 ld (iy+000h),0edh
3729 ld (iy+001h),b
3730 ld (iy+002h),l
3731 ld c,003h
3732 ret
3733
3734 as.MLT:
3735 call arg.ww ;
3736 jr nc,error5
3737 add a,b
3738 ld b,a
3739 jp gen.opc.ED2
3740
3741 error5:
3742 jp ERROR
3743
3744 as.LD:
3745 call arg.r_HL_A
3746 jr c,l13d4h
3747 call arg.IDX_displcmnt
3748 jp c,l1471h
3749 call arg.ww
3750 jp c,l149ch
3751 call arg.IX_IY
3752 jp c,l14f5h
3753 call get_char_upper
3754 cp 'I'
3755 jp z,l1511h
3756 cp 'R'
3757 jp z,l1519h
3758 cp '('
3759 jr nz,error5
3760 inc de
3761 call arg.ww
3762 jp c,l1528h
3763 call test_expr
3764 call test_paren_close
3765 call assert_comma
3766 call arg.ww
3767 jr c,l13c2h
3768 call arg.IX_IY
3769 jr nc,l13aah
3770 ld b,022h
3771 l1395h:
3772 call assert_eol
3773 ld a,(prefix_ixiy)
3774 l139bh:
3775 ld (iy+000h),a
3776 ld (iy+001h),b
3777 ld (iy+002h),l
3778 ld (iy+003h),h
3779 ld c,004h
3780 ret
3781
3782 l13aah:
3783 call get_char_upper
3784 cp 'A'
3785 jr nz,error5
3786 inc de
3787 ld b,032h
3788
3789 as.store_3:
3790 call assert_eol
3791 ld (iy+000h),b
3792 ld (iy+001h),l
3793 ld (iy+002h),h
3794 ld c,003h
3795 ret
3796
3797 l13c2h:
3798 cp 020h
3799 jr z,l13d0h
3800 add a,043h
3801 ld b,a
3802 l13c9h:
3803 call assert_eol
3804 ld a,0edh
3805 jr l139bh
3806 l13d0h:
3807 ld b,022h
3808 jr as.store_3
3809
3810 l13d4h:
3811 ld b,a
3812 call assert_comma
3813 call arg.r_HL_A
3814 jr nc,l13f0h
3815 push af
3816 ld a,b
3817 rlca
3818 rlca
3819 rlca
3820 ld b,a
3821 pop af
3822 add a,b
3823 add a,040h
3824 cp 076h
3825 jr z,error60
3826 l13ech:
3827 ld b,a
3828 jp as.opc.noarg
3829
3830 l13f0h:
3831 call arg.IDX_displcmnt
3832 jr nc,l1413h
3833 ld a,b
3834 rlca
3835 rlca
3836 rlca
3837 add a,046h
3838 cp 076h
3839 jr z,error60
3840
3841 l1400h:
3842 ld b,a
3843 call assert_eol
3844 ld (iy+001h),b
3845 ld (iy+002h),c
3846 ld a,(prefix_ixiy)
3847 ld (iy+000h),a
3848 ld c,003h
3849 ret
3850
3851 l1413h:
3852 call get_char_upper
3853 cp 'I'
3854 jr z,l1426h
3855 cp 'R'
3856 jr nz,l1432h
3857 ld a,b
3858 cp 007h
3859 jr nz,error60
3860 ld b,05fh
3861 jr l142eh
3862
3863 l1426h:
3864 ld a,b
3865 cp 007h
3866 jr nz,error60
3867 ld b,057h
3868 l142eh:
3869 inc de
3870 jp gen.opc.ED2
3871 l1432h:
3872 cp '('
3873 jr z,l144ch
3874 call arg.imm_8bit
3875 ld a,b
3876 rlca
3877 rlca
3878 rlca
3879 add a,006h
3880 l143fh:
3881 ld b,a
3882 as.store_2:
3883 call assert_eol
3884 ld (iy+000h),b
3885 ld (iy+001h),l
3886 ld c,002h
3887 ret
3888 l144ch:
3889 inc de
3890 ld a,b
3891 cp 007h
3892 jr nz,error60
3893 call arg.ww
3894 jr nc,l1466h
3895 cp 030h
3896 jr nc,error60
3897 add a,00ah
3898 ld b,a
3899 call test_paren_close
3900 jp as.opc.noarg
3901
3902 error60:
3903 jp error
3904
3905 l1466h:
3906 call test_expr
3907 call test_paren_close
3908 ld b,03ah
3909 jp as.store_3
3910
3911 l1471h:
3912 call assert_comma
3913 call arg.r_HL_A
3914 jr nc,l1483h
3915 cp 006h
3916 jr z,error60
3917 add a,070h
3918 jp l1400h
3919
3920 l1483h:
3921 call arg.imm_8bit
3922 call assert_eol
3923 ld a,(prefix_ixiy)
3924 ld (iy+000h),a
3925 ld (iy+001h),036h
3926 ld (iy+002h),c
3927 ld (iy+003h),l
3928 ld c,004h
3929 ret
3930 l149ch:
3931 ld b,a
3932 call assert_comma
3933 ld hl,t_HL.AF
3934 call sub_0318h
3935 jr c,l14c3h
3936 call arg.IX_IY
3937 jr nc,l14cch
3938 ld a,b
3939 cp 030h
3940 jr nz,error6
3941 ld b,0f9h
3942 l14b4h:
3943 call assert_eol
3944 ld a,(prefix_ixiy)
3945 ld (iy+000h),a
3946 ld (iy+001h),b
3947 ld c,002h
3948 ret
3949
3950 l14c3h:
3951 ld a,b
3952 cp 030h
3953 jr nz,error6
3954 ld b,0f9h
3955 jr as.opc.noarg ;14ca
3956
3957 l14cch:
3958 call get_char_upper
3959 cp '('
3960 jr nz,l14e8h
3961 inc de
3962 call test_expr
3963 call test_paren_close
3964 ld a,b
3965 cp 020h
3966 jr z,l14e3h
3967 add a,04bh
3968 ld b,a
3969 jp l13c9h
3970
3971 l14e3h:
3972 ld b,02ah
3973 jp as.store_3
3974
3975 l14e8h:
3976 call test_expr
3977 call assert_eol
3978 ld a,001h
3979 add a,b
3980 ld b,a
3981 jp as.store_3
3982 l14f5h:
3983 call assert_comma
3984 call get_char_upper
3985 cp '('
3986 jr nz,l1509h
3987 inc de
3988 call test_expr
3989 call test_paren_close
3990 ld b,02ah
3991 jp l1395h
3992
3993 l1509h:
3994 call test_expr
3995 ld b,021h
3996 jp l1395h
3997
3998 l1511h:
3999 inc de
4000 call assert_comma
4001 ld b,047h
4002 jr l151fh
4003
4004 l1519h:
4005 inc de
4006 call assert_comma
4007 ld b,04fh
4008 l151fh:
4009 call get_char_upper
4010 inc de
4011 cp 'A'
4012 jr z,gen.opc.ED2
4013 error6:
4014 jp ERROR
4015
4016 l1528h:
4017 cp 020h
4018 jr nc,error6
4019 add a,002h
4020 ld b,a
4021 call test_paren_close
4022 call assert_comma
4023 call get_char_upper
4024 cp 'A'
4025 jr nz,error6
4026 inc de
4027 as.opc.noarg:
4028 call assert_eol
4029 ld (iy+000h),b
4030 ld c,001h
4031 ret
4032
4033 gen.opc.ED2:
4034 call assert_eol
4035 ld (iy+000h),0edh
4036 ld (iy+001h),b
4037 ld c,002h
4038 ret
4039
4040 as.ADC_SBC:
4041 ld hl,t_HL.AF
4042 call sub_0318h
4043 jr nc,as.AND_CP_OR_SUB_XOR
4044 call assert_comma
4045 call arg.ww
4046 jr nc,error6
4047 push af
4048 ld a,b
4049 cp 088h
4050 ld b,04ah
4051 jr z,l156ch
4052 ld b,042h
4053 l156ch:
4054 pop af
4055 add a,b
4056 l156eh:
4057 ld b,a
4058 jr gen.opc.ED2
4059
4060 as.ADD:
4061 ld hl,t_HL.AF
4062 call sub_0318h
4063 jr c,l159ah
4064 call arg.IX_IY
4065 jr nc,as.AND_CP_OR_SUB_XOR
4066 call assert_comma
4067 ld hl,t_BC.DE.IX.SP
4068 ld a,(prefix_ixiy)
4069 cp 0fdh
4070 jr nz,l158eh
4071 ld hl,t_BC.DE.IY.SP
4072 l158eh:
4073 call arg.reg_16bit
4074 jr nc,error6
4075 add a,009h
4076 l1596h:
4077 ld b,a
4078 jp l14b4h
4079 l159ah:
4080 call assert_comma
4081 call arg.ww
4082 error61nc:
4083 jr nc,error6
4084 add a,009h
4085 jp l13ech
4086 as.AND_CP_OR_SUB_XOR:
4087 call get_char_upper
4088 cp 'A'
4089 jr nz,l15b8h
4090 push de
4091 inc de
4092 call next_arg
4093 jr z,l15b7h
4094 pop de
4095 jr l15b8h
4096 l15b7h:
4097 pop af
4098 l15b8h:
4099 call arg.r_HL_A
4100 jr c,l15cbh
4101 call arg.IDX_displcmnt
4102 jr c,l15cfh
4103 call arg.imm_8bit
4104 ld a,b
4105 add a,046h
4106 jp l143fh
4107 l15cbh:
4108 add a,b
4109 jp l13ech
4110 l15cfh:
4111 ld a,b
4112 add a,006h
4113 jp l1400h
4114
4115 as.SHIFTOP:
4116 call arg.r_HL_A
4117 jr c,l15fah
4118 call arg.IDX_displcmnt
4119 jr nc,error61nc
4120 ld a,b
4121 add a,006h
4122 ld b,a
4123 l15e4h:
4124 call assert_eol
4125 ld a,(prefix_ixiy)
4126 ld (iy+000h),a
4127 ld (iy+001h),0cbh
4128 ld (iy+002h),c
4129 ld (iy+003h),b
4130 ld c,004h
4131 ret
4132
4133 l15fah:
4134 add a,b
4135 l15fbh:
4136 ld b,a
4137 call assert_eol
4138 ld (iy+001h),b
4139 ld (iy+000h),0cbh
4140 ld c,002h
4141 ret
4142
4143 as.BITOP:
4144 call arg.bit
4145 call assert_comma
4146 call arg.r_HL_A
4147 jr c,l1624h
4148 call arg.IDX_displcmnt
4149 jr nc,error61nc
4150 ld a,l
4151 rlca
4152 rlca
4153 rlca
4154 add a,006h
4155 add a,b
4156 ld b,a
4157 jr l15e4h
4158 l1624h:
4159 add a,b
4160 ld b,a
4161 ld a,l
4162 rlca
4163 rlca
4164 rlca
4165 add a,b
4166 jr l15fbh
4167
4168 as.CALL:
4169 push de
4170 call arg.cc_ZCPS
4171 jr nc,l163ch
4172 add a,b
4173 ld b,a
4174 call next_arg
4175 jr z,l163eh
4176 pop de
4177 push de
4178 l163ch:
4179 ld b,0cdh
4180 l163eh:
4181 pop af
4182 call test_expr
4183 jp as.store_3
4184
4185 as.RET:
4186 call arg.cc_ZCPS
4187 jr nc,l164eh
4188 add a,b
4189 ld b,a
4190 jr l1650h
4191 l164eh:
4192 ld b,0c9h
4193 l1650h:
4194 jp as.opc.noarg
4195
4196 as.JP:
4197 push de
4198 call arg.cc_ZCPS
4199 jr c,l1666h
4200 l1659h:
4201 pop de
4202 ld hl,l168ch
4203 call sub_030ah
4204 jr c,l1674h
4205 ld b,0c3h
4206 jr l166eh
4207
4208 l1666h:
4209 add a,b
4210 ld b,a
4211 call next_arg
4212 jr nz,l1659h
4213 pop af
4214 l166eh:
4215 call test_expr
4216 jp as.store_3
4217 l1674h:
4218 call assert_eol
4219 ld a,b
4220 and a
4221 jr nz,l1680h
4222 ld b,0e9h
4223 jp as.opc.noarg
4224 l1680h:
4225 ld b,0ddh
4226 dec a
4227 jr z,l1687h
4228 ld b,0fdh
4229 l1687h:
4230 ld l,0e9h
4231 jp as.store_2
4232
4233 l168ch:
4234 DC '(HL)'
4235 DC '(IX)'
4236 DC '(IY)'
4237 DB 0
4238
4239 as.DJNZ:
4240 call next_arg
4241 ld b,010h
4242 jr l16aeh
4243 as.JR:
4244 call arg.cc_ZC
4245 jr c,l16a9h
4246 ld b,018h
4247 jr l16aeh
4248 l16a9h:
4249 add a,b
4250 ld b,a
4251 call assert_comma
4252 l16aeh:
4253 call arg.j_displ
4254 jp as.store_2
4255
4256 as.IM:
4257 call arg.imm_8bit
4258 ld a,l
4259 cp 003h
4260 jr nc,error7
4261 and a
4262 jr z,l16c7h
4263 ld b,056h
4264 cp 001h
4265 jr z,l16c7h
4266 ld b,05eh
4267 l16c7h:
4268 jp gen.opc.ED2
4269
4270 as.RST:
4271 call arg.imm_8bit
4272 ld a,l
4273 push af
4274 add a,b
4275 ld b,a
4276 pop af
4277 and 0c7h
4278 jr nz,error7
4279 jp as.opc.noarg
4280
4281 as.POP_PUSH:
4282 call arg.IX_IY
4283 jr c,l16e7h
4284 call arg.zz
4285 jr nc,error7
4286 add a,b
4287 jp l13ech
4288 l16e7h:
4289 ld a,b
4290 add a,020h
4291 jp l1596h
4292
4293 as.IN:
4294 call arg.r_HL_A
4295 jr nc,error7
4296 cp 006h
4297 jr z,error7
4298 rlca
4299 rlca
4300 rlca
4301 add a,b
4302 ld b,a
4303 cp 078h
4304 jr nz,l170fh
4305 call assert_comma
4306 call sub_171bh
4307 jr c,l1715h
4308 call arg.addr_8bit
4309 ld b,0dbh
4310 jp as.store_2
4311 l170fh:
4312 call assert_comma
4313 call sub_171bh
4314 l1715h:
4315 jp c,gen.opc.ED2
4316 error7:
4317 jp ERROR
4318
4319 sub_171bh:
4320 ld hl,t__C_
4321 jp sub_0318h
4322
4323 as.OUT:
4324 call sub_171bh
4325 jr nc,l1739h
4326 call assert_comma
4327 call arg.r_HL_A
4328 jr nc,error7
4329 cp 006h
4330 jr z,error7
4331 rlca
4332 rlca
4333 rlca
4334 add a,b
4335 jp l156eh
4336
4337 l1739h:
4338 call arg.addr_8bit
4339 call assert_comma
4340 cp 'A'
4341 jr nz,error7
4342 inc de
4343 ld b,0d3h
4344 jp as.store_2
4345
4346 as.EX:
4347 ld hl,b_176d_start
4348 call sub_030ah
4349 jr nc,error7
4350 ld c,b
4351 call assert_eol
4352 ld b,000h
4353 ld hl,l178eh
4354 add hl,bc
4355 add hl,bc
4356 ld a,(hl)
4357 ld (iy+000h),a
4358 ld c,001h
4359 inc hl
4360 ld a,(hl)
4361 and a
4362 ret z
4363 ld (iy+001h),a
4364 ld c,002h
4365 ret
4366
4367 b_176d_start:
4368 DC 'AF,AF'''
4369 l1773h:
4370 DC 'DE,HL'
4371 DC '(SP),HL'
4372 DC '(SP),IX'
4373 DC '(SP),IY'
4374 db 0
4375 l178eh:
4376 db 008h,000h
4377 db 0ebh,000h
4378 db 0e3h,000h
4379 db 0ddh,0e3h
4380 db 0fdh,0e3h
4381
4382 as.DEC_INC:
4383 call arg.IX_IY
4384 jr c,l17b3h
4385 call arg.ww
4386 jr c,l17bfh
4387 call arg.r_HL_A
4388 jr c,l17cch
4389 call arg.IDX_displcmnt
4390 jr nc,error8
4391 ld a,b
4392 add a,030h
4393 jp l1400h
4394 l17b3h:
4395 ld a,b
4396 ld b,023h
4397 cp 004h
4398 jr z,l17bch
4399 ld b,02bh
4400 l17bch:
4401 jp l14b4h
4402 l17bfh:
4403 push af
4404 ld a,b
4405 ld b,003h
4406 cp 004h
4407 jr z,l17c9h
4408 ld b,00bh
4409 l17c9h:
4410 pop af
4411 jr l17cfh
4412 l17cch:
4413 rlca
4414 rlca
4415 rlca
4416 l17cfh:
4417 add a,b
4418 jp l13ech
4419
4420 arg.bit:
4421 call arg.imm_8bit
4422 ld a,l
4423 cp 008h
4424 jr nc,error8
4425 ret
4426
4427 arg.j_displ:
4428 call test_expr
4429 push bc
4430 push iy
4431 pop bc
4432 and a
4433 sbc hl,bc
4434 dec hl
4435 dec hl
4436 pop bc
4437 call sub_1802h
4438 ld a,h
4439 xor l
4440 bit 7,a
4441 jr nz,error8
4442 ret
4443
4444 arg.addr_8bit:
4445 call get_char_upper
4446 cp '('
4447 jr nz,arg.imm_8bit
4448 inc de
4449 call arg.imm_8bit
4450 jp test_paren_close
4451
4452 arg.imm_8bit:
4453 call test_expr
4454 sub_1802h:
4455 ld a,h
4456 and a
4457 ret z
4458 inc a
4459 ret z
4460 jr error8
4461
4462 test_expr:
4463 push bc
4464 call expr
4465 pop bc
4466 ret nc
4467 error8:
4468 jp ERROR
4469
4470 arg.zz:
4471 push hl
4472 ld hl,t_BC.DE.HL.AF
4473 jr l181fh
4474
4475 arg.reg_16bit:
4476 push hl
4477 jr l181fh
4478
4479 arg.ww:
4480 push hl
4481 ld hl,t_BC.DE.HL.SP
4482 l181fh:
4483 push bc
4484 call sub_030ah
4485 jr nc,l182bh
4486 ld a,b
4487 rlca
4488 rlca
4489 rlca
4490 rlca
4491 scf
4492 l182bh:
4493 pop bc
4494 pop hl
4495 ret
4496
4497 arg.r_HL_A:
4498 call skipbl
4499 push bc
4500 push hl
4501 ld hl,t_BCDEHL_HL_A
4502 call sub_030ah
4503 ld a,b
4504 pop hl
4505 pop bc
4506 ret
4507
4508 arg.IX_IY:
4509 push hl
4510 push bc
4511 ld hl,t_IX.IY
4512 call sub_030ah
4513 jr nc,l1852h
4514 ld a,0ddh
4515 dec b
4516 jr nz,l184eh
4517 ld a,0fdh
4518 l184eh:
4519 ld (prefix_ixiy),a
4520 scf
4521 l1852h:
4522 pop bc
4523 pop hl
4524 ret
4525
4526 arg.IDX_displcmnt:
4527 push hl
4528 push bc
4529 call get_char_upper
4530 cp '('
4531 jr nz,l18a1h
4532 push de
4533 inc de
4534 ld hl,t_IX.IY
4535 call sub_030ah
4536 jr nc,l18a0h
4537 pop af
4538 ld a,0ddh
4539 dec b
4540 jr nz,l186eh
4541 ld a,0fdh
4542 l186eh:
4543 ld (prefix_ixiy),a
4544 call get_char_upper
4545 cp '+'
4546 jr z,l1882h
4547 cp ')'
4548 ld hl,0
4549 jr z,l189ah
4550 cp '-'
4551 jr nz,error9
4552 l1882h:
4553 push af
4554 inc de
4555 call arg.imm_8bit
4556 pop af
4557 cp '+'
4558 jr z,l1894h
4559 ld b,h
4560 ld c,l
4561 ld hl,0
4562 and a
4563 sbc hl,bc
4564 l1894h:
4565 call get_char_upper
4566 cp ')'
4567 jr nz,error9
4568 l189ah:
4569 inc de
4570 pop bc
4571 ld c,l
4572 pop hl
4573 scf
4574 ret
4575 l18a0h:
4576 pop de
4577 l18a1h:
4578 pop bc
4579 pop hl
4580 and a
4581 ret
4582
4583 arg.cc_ZCPS:
4584 ld hl,t_tstfl_ZCPS
4585 ld c,007h
4586 jr l18b1h
4587
4588 arg.cc_ZC:
4589 ld hl,t_tstfl_ZC
4590 ld c,003h
4591 l18b1h:
4592 push bc
4593 call sub_030ah
4594 ld a,b
4595 pop bc
4596 ret nc
4597 and c
4598 rlca
4599 rlca
4600 rlca
4601 scf
4602 ret
4603
4604 assert_comma:
4605 call next_arg
4606 ret z
4607 error9:
4608 jp ERROR
4609
4610 test_paren_close:
4611 call get_char_upper
4612 cp ')'
4613 jr nz,error9
4614 inc de
4615 ret
4616
4617 ;-------------------------------------------------------------------------------
4618 ; >>L [startaddr] [endaddr]
4619 ; List disassembled code
4620
4621 cmd_L:
4622 ld hl,cmd_L
4623 ld (cmd_rpt),hl
4624 call expr
4625 jr nc,l18dbh
4626 ld hl,(last_L)
4627 l18dbh:
4628 call next_arg
4629 call get_range
4630 jr nc,l1905h
4631 call assert_eol
4632 ld b,16
4633 l18ebh:
4634 push bc
4635 call cmdl_p_line
4636 pop bc
4637 djnz l18ebh
4638 ret
4639
4640 l1905h:
4641 call assert_eol
4642 ld d,h
4643 ld e,l
4644 add hl,bc
4645 ex de,hl
4646 l190fh:
4647 push de
4648 call cmdl_p_line
4649 pop de
4650 call cp_hl_de
4651 jr c,l190fh
4652 ret
4653
4654 ;-------------------------------------------------------------------------------
4655
4656 cmdl_p_line:
4657 push hl
4658 call p_disas_line
4659 call crlf
4660 pop hl
4661 ld c,b
4662 ld b,0
4663 add hl,bc
4664 ld (last_L),hl
4665 ret
4666
4667 p_disas_line:
4668 call p_label
4669 call outbl2
4670 call out.hl.@
4671 call z,outbl
4672 call outbl
4673 sub a
4674 ld (con_col),a
4675 push hl
4676 pop iy
4677 call p_disas_instr
4678 ret z
4679
4680 ld c,15
4681 call p_goto_col
4682 call p_offset
4683 call outbl
4684 jp p_symbol
4685
4686 ;-------------------------------------------------------------------------------
4687
4688 p_offset:
4689 ld de,(var.@)
4690 ld a,d
4691 or e
4692 ret z
4693 call pstr_inl
4694 dc '(@'
4695 and a
4696 sbc hl,de
4697 call out_hl
4698 add hl,de
4699 jp out_rparen
4700
4701 ;-------------------------------------------------------------------------------
4702
4703 p_disas_instr:
4704 sub a
4705 ld (disas_argtype),a
4706 call disas_get_instrlen
4707 jr nc,l197fh
4708 push bc
4709 ld a,(con_col)
4710 add a,5
4711 ld c,a
4712 call pstr
4713 call p_goto_col
4714 ex de,hl
4715 call call_hl
4716 pop bc
4717 ld a,(disas_argtype)
4718 ld hl,(disas_arg_16)
4719 or a
4720 scf
4721 ret
4722
4723 l197fh:
4724 call pstr_inl
4725 DC '???'
4726 ld b,1
4727 sub a
4728 ret
4729
4730 disas_get_instrlen:
4731 sub a
4732 ld (isprefix_ixiy),a
4733 ld a,(iy+000h)
4734 cp 0edh
4735 jp z,disas_pfx.ED
4736 cp 0ddh
4737 jr z,l19abh
4738 cp 0fdh
4739 jr z,l19afh
4740 sub_19a0h:
4741 ld a,(iy+000h)
4742 cp 0cbh
4743 jp z,disas_pfx.CB
4744 jp disas_nopfx
4745 l19abh:
4746 ld a,1
4747 jr l19b1h
4748 l19afh:
4749 ld a,2
4750 l19b1h:
4751 ld (isprefix_ixiy),a
4752 call disas_pfx.DDFD
4753 ret nc
4754 push bc
4755 call sub_19a0h
4756 pop af
4757 add a,b
4758 ld b,a
4759 scf
4760 ret
4761
4762 ;-------------------------------------------------------------------------------
4763
4764 disas_pfx.DDFD:
4765 inc iy
4766 ld hl,b_19ef_start
4767 call test_DDFD
4768 ld b,002h
4769 ret c
4770 ld hl,l1a0ah
4771 call test_DDFD
4772 ld b,001h
4773 ret c
4774 ld a,(iy+000h)
4775 cp 0cbh
4776 jr nz,l19edh
4777 ld a,(iy+002h)
4778 cp 036h
4779 ret z
4780 and 007h
4781 cp 006h
4782 jr nz,l19edh
4783 ld b,002h
4784 scf
4785 ret
4786 l19edh:
4787 and a
4788 ret
4789
4790 ;-------------------------------------------------------------------------------
4791 ; DD/FD 3 byte (ix+d)/(iy+d)
4792 b_19ef_start:
4793 db 034h
4794 db 035h
4795 db 036h
4796 db 046h
4797 db 04eh
4798 db 056h
4799 db 05eh
4800 db 066h
4801 db 06eh
4802 db 070h
4803 db 071h
4804 db 072h
4805 db 073h
4806 db 074h
4807 db 075h
4808 db 077h
4809 db 07eh
4810 db 086h
4811 db 08eh
4812 db 096h
4813 db 09eh
4814 db 0a6h
4815 db 0aeh
4816 db 0b6h
4817 db 0beh
4818 db 0
4819
4820 ; DD/FD 2 byte
4821 l1a0ah:
4822 db 009h
4823 db 019h
4824 db 021h
4825 db 022h
4826 db 023h
4827 db 029h
4828 db 02ah
4829 db 02bh
4830 db 039h
4831 db 0e1h
4832 db 0e3h
4833 db 0e5h
4834 db 0e9h
4835 db 0f9h
4836 db 0
4837
4838 ;-------------------------------------------------------------------------------
4839
4840 disas_pfx.ED:
4841 inc iy
4842 ld hl,b_1bc9_start
4843 call sub_1a72h
4844 ld b,2
4845 ret c
4846 ld hl,b_1bf4_start
4847 call lookup_opc
4848 ld b,2
4849 ret c
4850
4851 ld hl,l228bh
4852 call lookup_opc
4853 ld b,3
4854 ret c
4855 ld hl,b_1c40_start
4856 call lookup_opc
4857 ld b,4
4858 ret
4859
4860 ;-------------------------------------------------------------------------------
4861
4862 disas_pfx.CB:
4863 push iy
4864 inc iy
4865 ld a,(isprefix_ixiy)
4866 and a
4867 jr z,l1a42h
4868 inc iy
4869 l1a42h:
4870 ld hl,b_1c55_start
4871 call lookup_opc
4872 pop iy
4873 ld b,2
4874 ret
4875
4876 ;-------------------------------------------------------------------------------
4877
4878 disas_nopfx:
4879 ld hl,b_1b54_start
4880 call lookup_opc
4881 ld b,2
4882 ret c
4883 ld hl,b_1ab6_start
4884 call sub_1a72h
4885 ld b,1
4886 ret c
4887 ld hl,b_1ad1_start
4888 call lookup_opc
4889 ld b,1
4890 ret c
4891 ld hl,b_1b9b_start
4892 call lookup_opc
4893 ret nc
4894 ld b,3
4895 ret
4896
4897 ;-------------------------------------------------------------------------------
4898
4899 sub_1a72h:
4900 ld a,(hl)
4901 cp 0ffh
4902 ret z
4903 cp (iy+000h)
4904 jr z,l1a7fh
4905 inc hl
4906 inc hl
4907 jr sub_1a72h
4908 l1a7fh:
4909 ld de,l1c97h
4910 inc hl
4911 ld c,(hl)
4912 jr get_mnemonic
4913
4914
4915 test_DDFD:
4916 ld a,(hl)
4917 and a
4918 ret z
4919 inc hl
4920 cp (iy+000h)
4921 jr nz,test_DDFD
4922 scf
4923 ret
4924
4925 lookup_opc:
4926 ld a,(iy+000h)
4927 and (hl)
4928 inc hl
4929 cp (hl)
4930 jr z,l1aa8h
4931 inc hl
4932 inc hl
4933 inc hl
4934 inc hl
4935 ld a,(hl)
4936 and a
4937 jr nz,lookup_opc
4938 ret
4939
4940 l1aa8h:
4941 inc hl
4942 ld c,(hl)
4943 inc hl
4944 ld e,(hl)
4945 inc hl
4946 ld d,(hl)
4947 get_mnemonic:
4948 ld hl,t_MNEMONICS
4949 ld b,0
4950 add hl,bc
4951 scf
4952 ret
4953
4954 ;-------------------------------------------------------------------------------
4955 ; 1 byte opcodes (no parameters)
4956 ; Format: db opcode, t_MNEMONICS-index
4957 b_1ab6_start:
4958 db 076h,039h ;halt
4959 db 0d9h,036h ;exx
4960 db 0f3h,02ch ;di
4961 db 0fbh,032h ;ei
4962 db 000h,069h ;nop
4963 db 007h,09eh ;rlca
4964 db 00fh,0adh ;rrca
4965 db 017h,098h ;rla
4966 db 01fh,0a7h ;rra
4967 db 027h,026h ;daa
4968 db 02fh,023h ;cpl
4969 db 037h,0bah ;scf
4970 db 03fh,010h ;ccf
4971 db 0ffh
4972
4973
4974 ; 1 byte opcodes
4975 ; Format: db mask, match, t_MNEMONICS-index
4976 ; dw argument formating fuction
4977 b_1ad1_start:
4978 db 0c0h,040h,056h ;ld r,r
4979 dw p_arg_r_r
4980 db 0f8h,080h,003h ;add a,r
4981 dw p_arg_a_r
4982 db 0f8h,088h,000h ;adc a,r
4983 dw p_arg_a_r
4984 db 0f8h,090h,0c9h ;sub r
4985 dw p_arg_rs
4986 db 0f8h,098h,0b7h ;sbc a,r
4987 dw p_arg_a_r
4988 db 0f8h,0a0h,006h ;and r
4989 dw p_arg_rs
4990 db 0f8h,0a8h,0cch ;xor r
4991 dw p_arg_rs
4992 db 0f8h,0b0h,06ch ;or r
4993 dw p_arg_rs
4994 db 0f8h,0b8h,013h ;cp r
4995 dw p_arg_rs
4996 db 0c7h,0c0h,08bh ;ret cc
4997 dw p_arg_cc
4998 db 0c7h,0c7h,0b4h ;rst
4999 dw l1c98h
5000 db 0ffh,0c9h,08bh ;ret
5001 dw l1c97h
5002 db 0cfh,0c1h,081h ;pop rr
5003 dw p_arg_zz
5004 db 0cfh,0c5h,084h ;push rr
5005 dw p_arg_zz
5006 db 0ffh,0e3h,034h ;ex (sp),hl
5007 dw l1ca0h
5008 db 0ffh,0e9h,052h ;jp (hl)
5009 dw l1caeh
5010 db 0ffh,0ebh,034h ;ex de,hl
5011 dw p_arg_ex_dehl
5012 db 0ffh,0f9h,056h ;ld sp,hl
5013 dw l1cc1h
5014 db 0cfh,003h,041h ;inc rr
5015 dw p_arg_ww
5016 db 0cfh,00bh,029h ;dec rr
5017 dw p_arg_ww
5018 db 0c7h,004h,041h ;inc r
5019 dw p_arg_r
5020 db 0c7h,005h,029h ;dec r
5021 dw p_arg_r
5022 db 0ffh,008h,034h ;ex af,af'
5023 dw p_arg_ex_afaf
5024 db 0cfh,009h,003h ;add hl,rr
5025 dw l1cd3h
5026 db 0efh,002h,056h ;ld (rr),a ;rr=bc,de
5027 dw l1cdch
5028 db 0efh,00ah,056h ;ld a,(rr) ;rr=bc,de
5029 dw l1ce5h
5030 db 0
5031
5032 ; 2 byte opdodes
5033 b_1b54_start:
5034 db 0c7h,006h,056h ;ld r,nn
5035 dw l1cfah
5036 db 0ffh,0c6h,003h ;add a,nn
5037 dw l1cf5h
5038 db 0ffh,0ceh,000h ;adc a,nn
5039 dw l1cf5h
5040 db 0ffh,0d6h,0c9h ;sub a,nn
5041 dw l1d09h
5042 db 0ffh,0deh,0b7h ;sbc a,nn
5043 dw l1cf5h
5044 db 0ffh,0e6h,006h ;and a,nn
5045 dw l1d09h
5046 db 0ffh,0eeh,0cch ;xor nn
5047 dw l1d09h
5048 db 0ffh,0f6h,06ch ;or nn
5049 dw l1d09h
5050 db 0ffh,0feh,013h ;cp a,nn
5051 dw l1d09h
5052 db 0ffh,010h,02eh ;djnz
5053 dw p_arg_jrel
5054 db 0ffh,018h,054h ;jr
5055 dw p_arg_jrel
5056 db 0e7h,020h,054h ;jr cc,
5057 dw p_arg_cc_jrel
5058 db 0ffh,0d3h,076h ;out (nn),a
5059 dw l1d37h
5060 db 0ffh,0dbh,03fh ;in a,(nn)
5061 dw l1d29h
5062 db 0
5063
5064 ; 3 byte opcodes
5065 b_1b9b_start:
5066 db 0c7h,0c2h,052h ;jp cc,mn
5067 dw p_arg_cc_mn
5068 db 0c7h,0c4h,00ch ;call cc,mn
5069 dw p_arg_cc_mn
5070 db 0cfh,001h,056h ;ld ww,mn
5071 dw p_arg_ww_mn
5072 db 0ffh,0c3h,052h ;jp mn
5073 dw p_arg_mn
5074 db 0ffh,0cdh,00ch ;call mn
5075 dw p_arg_mn
5076 db 0ffh,022h,056h ;ld (mn),hl
5077 dw p_arg_addr_hl
5078 db 0ffh,02ah,056h ;ld hl,(mn)
5079 dw p_arg_hl_addr
5080 db 0ffh,032h,056h ;ld (mn),a
5081 dw p_arg_addr_a
5082 db 0ffh,03ah,056h ;ld a,(mn)
5083 dw p_arg_a_addr
5084 db 0
5085
5086 ; Prefix ED + 1 byte opcode, no arguments
5087 ; Format: opcode, t_MNEMONICS index
5088 b_1bc9_start:
5089 db 044h,066h ;neg
5090 db 045h,092h ;retn
5091 db 04dh,08eh ;reti
5092 db 067h,0b1h ;rrd
5093 db 06fh,0a2h ;rld
5094 db 0a0h,05fh ;ldi
5095 db 0a1h,01ch ;cpi
5096 db 0a2h,04bh ;ini
5097 db 0a3h,07dh ;outi
5098 db 0a8h,058h ;ldd
5099 db 0a9h,015h ;cpd
5100 db 0aah,044h ;ind
5101 db 0abh,079h ;outd
5102 db 0b0h,062h ;ldir
5103 db 0b1h,01fh ;cpir
5104 db 0b2h,04eh ;inir
5105 db 0b3h,072h ;otir
5106 db 0b8h,05bh ;lddr
5107 db 0b9h,018h ;cpdr
5108 db 0bah,047h ;indr
5109 db 0bbh,06eh ;otdr
5110 db 08bh,0d5h ;otdm
5111 db 09bh,0d9h ;otdmr
5112 db 083h,0deh ;otim
5113 db 093h,0e2h ;otimr
5114 db 076h,0ebh ;slp
5115 db 0ffh ;<end mark>
5116
5117 b_1bf4_start:
5118 db 0e7h,040h,03fh ;in r,(c) ;r=b,c,d,e
5119 dw p_arg_in_c ;
5120 db 0f7h,060h,03fh ;in r,(c) ;r=h,l
5121 dw p_arg_in_c ;
5122 db 0ffh,078h,03fh ;in r,(c) ;r=a
5123 dw p_arg_in_c ;
5124 db 0e7h,041h,076h ;out (c),r ;r=b,c,d,e
5125 dw p_arg_out_c ;
5126 db 0f7h,061h,076h ;out (c),r ;r=h,l
5127 dw p_arg_out_c ;
5128 db 0ffh,079h,076h ;out (c),r ;r=a
5129 dw p_arg_out_c ;
5130 db 0cfh,042h,0b7h ;sbc hl,rr
5131 dw l1dcah ;
5132 db 0cfh,04ah,000h ;adc hl,rr
5133 dw l1dcah ;
5134 db 0ffh,046h,03dh ;im 0
5135 dw l1d85h ;
5136 db 0ffh,056h,03dh ;im 1
5137 dw l1d89h ;
5138 db 0ffh,05eh,03dh ;im 2
5139 dw l1d8dh ;
5140 db 0ffh,047h,056h ;ld i,a
5141 dw l1d92h ;
5142 db 0ffh,057h,056h ;ld a,i
5143 dw l1d97h ;
5144 db 0ffh,04fh,056h ;ld r,a
5145 dw l1d9ch ;
5146 db 0ffh,05fh,056h ;ld a,r
5147 dw l1da1h
5148 db 0cfh,04ch,0d2h ;mlt rr
5149 dw p_arg_ww
5150 db 0c7h,004h,0eeh ;tst r
5151 dw p_arg_r
5152 db 0
5153
5154 l228bh:
5155 db 0e7h,000h,0cfh ;in0 r,(m) ;r=b,c,d,e
5156 dw p_arg_r_m
5157 db 0f7h,020h,0cfh ;in0 r,(m) ;r=h,l
5158 dw p_arg_r_m
5159 db 0ffh,038h,0cfh ;in0 a,(m)
5160 dw p_arg_r_m
5161 db 0e7h,001h,0e7h ;out0 (m),r ;r=b,c,d,e
5162 dw p_arg_m_r
5163 db 0f7h,021h,0e7h ;out0 (m),r ;r=h,l
5164 dw p_arg_m_r
5165 db 0ffh,039h,0e7h ;out0 (m),a
5166 dw p_arg_m_r
5167 db 0ffh,064h,0eeh ;tst m
5168 dw l1d09h
5169 db 0ffh,074h,0f1h ;tstio m
5170 dw l1d09h
5171 db 0
5172
5173 b_1c40_start:
5174 db 0efh,043h,056h ;ld (mn),ww ;ww=bc,de
5175 dw p_arg_addr_ww
5176 db 0ffh,073h,056h ;ld (mn),sp
5177 dw p_arg_addr_ww
5178 db 0efh,04bh,056h ;ld ww,(mn) ;ww=bc,de
5179 dw p_arg_ww_addr
5180 db 0ffh,07bh,056h ;ld sp,(mn)
5181 dw p_arg_ww_addr
5182 db 0
5183
5184 ; CB
5185 b_1c55_start:
5186 db 0f8h,000h,09bh ;rlc g
5187 dw l1e03h
5188 db 0f8h,008h,0aah ;rrc g
5189 dw l1e03h
5190 db 0f8h,010h,096h ;rl g
5191 dw l1e03h
5192 db 0f8h,018h,0a5h ;rr g
5193 dw l1e03h
5194 db 0f8h,020h,0c0h ;sla g
5195 dw l1e03h
5196 db 0f8h,028h,0c3h ;sra g
5197 dw l1e03h
5198 db 0f8h,038h,0c6h ;srl g
5199 dw l1e03h
5200 db 0c0h,040h,009h ;bit b,g
5201 dw p_arg_bitop
5202 db 0c0h,080h,088h ;res b,g
5203 dw p_arg_bitop
5204 db 0c0h,0c0h,0bdh ;set b,g
5205 dw p_arg_bitop
5206 db 0
5207
5208 ;-------------------------------------------------------------------------------
5209
5210 p_arg_r_r:
5211 call p_arg_r
5212 call p_char_comma
5213 jp p_arg_rs
5214 p_arg_a_r:
5215 call p_A_comma
5216 jp p_arg_rs
5217 l1c97h:
5218 ret
5219
5220 p_arg_r_m:
5221 call p_arg_r
5222 call p_char_comma
5223 jp sub_1d2ch
5224
5225 p_arg_m_r:
5226 call sub_1d2ch
5227 call p_char_comma
5228 jp p_arg_r
5229
5230 l1c98h:
5231 ld a,(iy+000h)
5232 and 038h
5233 jp out_hex
5234
5235 l1ca0h:
5236 call pstr_inl
5237 DC '(SP),'
5238 jp p_arg_hlixiy
5239
5240 l1caeh:
5241 call p_char_lparen
5242 call p_arg_hlixiy
5243 jr out_rparen
5244
5245 p_arg_ex_dehl:
5246 ld hl,l1773h
5247 jp pstr
5248
5249 l1cc1h:
5250 call pstr_inl
5251 DC 'SP,'
5252 jp p_arg_hlixiy
5253
5254 p_arg_ex_afaf:
5255 ld hl,b_176d_start
5256 jp pstr
5257
5258 l1cd3h:
5259 call p_arg_hlixiy
5260 call p_char_comma
5261 jp p_arg_ww
5262 l1cdch:
5263 call sub_1ce8h
5264 call p_char_comma
5265 jp p_char_A
5266
5267 l1ce5h:
5268 call p_A_comma
5269 sub_1ce8h:
5270 call p_char_lparen
5271 call p_arg_ww
5272 jr out_rparen
5273
5274 l1cf5h:
5275 call p_A_comma
5276 jr l1d09h
5277 l1cfah:
5278 call p_arg_r
5279 call p_char_comma
5280 ld a,(isprefix_ixiy)
5281 and a
5282 ld a,(iy+002h)
5283 jr nz,l1d0ch
5284 l1d09h:
5285 ld a,(iy+001h)
5286 l1d0ch:
5287 jp out_hex
5288
5289 p_arg_cc_jrel:
5290 ld a,(iy+000h)
5291 and 018h
5292 call p_arg_cc0
5293 call p_char_comma
5294 p_arg_jrel:
5295 ld c,(iy+001h)
5296 ld a,c
5297 rla
5298 sbc a,a
5299 ld b,a
5300 push iy
5301 pop hl
5302 add hl,bc
5303 inc hl
5304 inc hl
5305 jr l1d4eh
5306
5307 l1d29h:
5308 call p_A_comma
5309 sub_1d2ch:
5310 call p_char_lparen
5311 ld a,(iy+001h)
5312 p_arg_nn_rp:
5313 call out_hex
5314 out_rparen:
5315 jr p_char_rparen
5316
5317 l1d37h:
5318 call sub_1d2ch
5319 jr p_char_comma_A
5320
5321 p_arg_cc_mn:
5322 call p_arg_cc
5323 call p_char_comma
5324 p_arg_mn:
5325 ld l,(iy+001h)
5326 ld h,(iy+002h)
5327 l1d4eh:
5328 ld a,002h
5329 sub_1d50h:
5330 ld (disas_argtype),a
5331 ld (disas_arg_16),hl
5332 jp out_hl
5333
5334 p_arg_ww_mn:
5335 call p_arg_ww
5336 call p_char_comma
5337 jr p_arg_mn
5338
5339 p_arg_addr_hl:
5340 call p_arg_addr
5341 call p_char_comma
5342 jp p_arg_hlixiy
5343
5344 p_arg_hl_addr:
5345 call p_arg_hlixiy
5346 call p_char_comma
5347 jp p_arg_addr
5348
5349 p_arg_addr_a:
5350 call p_arg_addr
5351 p_char_comma_A:
5352 call p_char_comma
5353 jr p_char_A
5354
5355 p_A_comma:
5356 call p_char_A
5357 p_char_comma:
5358 ld a,','
5359 db 021h
5360 p_char_A:
5361 ld a,'A'
5362 db 021h
5363 l1d85h:
5364 ld a,'0'
5365 db 021h
5366 l1d89h:
5367 ld a,'1'
5368 db 021h
5369 l1d8dh:
5370 ld a,'2'
5371 db 021h
5372 p_char_rparen:
5373 ld a,')'
5374 db 021h
5375 p_char_lparen:
5376 ld a,'('
5377 jp outchar
5378
5379 l1d92h:
5380 ld hl,b_1da7_start
5381 jr l1da4h
5382 l1d97h:
5383 ld hl,l1daah
5384 jr l1da4h
5385 l1d9ch:
5386 ld hl,l1dadh
5387 jr l1da4h
5388 l1da1h:
5389 ld hl,l1db0h
5390 l1da4h:
5391 jp pstr
5392
5393 b_1da7_start:
5394 DC 'I,A'
5395 l1daah:
5396 DC 'A,I'
5397 l1dadh:
5398 DC 'R,A'
5399 l1db0h:
5400 DC 'A,R'
5401
5402 p_arg_in_c:
5403 call p_arg_r
5404 call p_char_comma
5405 ld hl,t__C_
5406 jp pstr
5407
5408 p_arg_out_c:
5409 ld hl,t__C_
5410 call pstr
5411 call p_char_comma
5412 jr p_arg_r
5413
5414 l1dcah:
5415 call p_arg_hlixiy
5416 call p_char_comma
5417 jp p_arg_ww
5418
5419 p_arg_addr_ww:
5420 call p_arg_addr
5421 call p_char_comma
5422 jp p_arg_ww
5423
5424 p_arg_ww_addr:
5425 call p_arg_ww
5426 call p_char_comma
5427 jr p_arg_addr
5428
5429 p_arg_a_addr:
5430 call p_A_comma
5431 p_arg_addr:
5432 call p_char_lparen
5433 ld l,(iy+001h)
5434 ld h,(iy+002h)
5435 ld a,001h
5436 call sub_1d50h
5437 jr p_char_rparen
5438
5439 p_arg_bitop:
5440 ld a,(isprefix_ixiy)
5441 and a
5442 jr nz,l1defh
5443 ld a,(iy+001h)
5444 jr l1df2h
5445 l1defh:
5446 ld a,(iy+002h)
5447 l1df2h:
5448 push af
5449 rra
5450 rra
5451 rra
5452 and 007h
5453 add a,'0'
5454 call outchar
5455 call p_char_comma
5456 pop af
5457 jr p_arg_r0
5458
5459 l1e03h:
5460 ld a,(isprefix_ixiy)
5461 and a
5462 jr nz,l1e0eh
5463 ld a,(iy+001h)
5464 jr l1e11h
5465 l1e0eh:
5466 ld a,(iy+002h)
5467 l1e11h:
5468 jr p_arg_r0
5469
5470 p_arg_r:
5471 ld a,(iy+000h)
5472 rra
5473 rra
5474 rra
5475 jr p_arg_r0
5476 p_arg_rs:
5477 ld a,(iy+000h)
5478 p_arg_r0:
5479 and 007h
5480 cp 006h
5481 jr nz,p_arg_r1
5482 ld a,(isprefix_ixiy)
5483 and a
5484 ld a,006h
5485 jr z,p_arg_r1
5486 ld hl,b_1e78_start
5487 ld a,(isprefix_ixiy)
5488 dec a
5489 jr z,l1e4dh
5490 ld hl,l1e7bh
5491 l1e4dh:
5492 call pstr
5493 ld a,(iy+001h)
5494 push af
5495 rlca
5496 ld a,'+'
5497 jr nc,l1e61h
5498 pop af
5499 neg
5500 push af
5501 ld a,'-'
5502 l1e61h:
5503 call outchar
5504 pop af
5505 jp p_arg_nn_rp
5506
5507 p_arg_r1:
5508 ld hl,t_BCDEHL_HL_A
5509 jr p_arg
5510
5511 b_1e78_start:
5512 DC '(IX'
5513 l1e7bh:
5514 DC '(IY'
5515
5516 p_arg_hlixiy:
5517 ld a,(isprefix_ixiy)
5518 ld hl,t_HL.IX.IY
5519 jr p_arg
5520 p_arg_zz:
5521 ld hl,t_BC.DE.HL.AF
5522 jr l1e8eh
5523 p_arg_ww:
5524 ld hl,t_BC.DE.HL.SP
5525 l1e8eh:
5526 ld a,(iy+000h)
5527 rra
5528 rra
5529 rra
5530 rra
5531 and 003h
5532 cp 002h
5533 jr z,p_arg_hlixiy
5534 jr p_arg
5535
5536 p_arg_cc:
5537 ld a,(iy+000h)
5538 p_arg_cc0:
5539 rra
5540 rra
5541 rra
5542 and 007h
5543 ld hl,t_tstfl_ZCPS
5544 p_arg:
5545 ld b,a
5546 call sel_dc_string
5547 jp pstr
5548
5549 ;-------------------------------------------------------------------------------
5550
5551 t_MNEMONICS:
5552 DC 'ADC'
5553 DC 'ADD'
5554 DC 'AND'
5555 DC 'BIT'
5556 DC 'CALL'
5557 DC 'CCF'
5558 DC 'CP'
5559 DC 'CPD'
5560 DC 'CPDR'
5561 DC 'CPI'
5562 DC 'CPIR'
5563 DC 'CPL'
5564 DC 'DAA'
5565 DC 'DEC'
5566 DC 'DI'
5567 DC 'DJNZ'
5568 DC 'EI'
5569 DC 'EX'
5570 DC 'EXX'
5571 DC 'HALT'
5572 DC 'IM'
5573 DC 'IN'
5574 DC 'INC'
5575 DC 'IND'
5576 DC 'INDR'
5577 DC 'INI'
5578 DC 'INIR'
5579 DC 'JP'
5580 DC 'JR'
5581 DC 'LD'
5582 DC 'LDD'
5583 DC 'LDDR'
5584 DC 'LDI'
5585 DC 'LDIR'
5586 DC 'NEG'
5587 DC 'NOP'
5588 DC 'OR'
5589 DC 'OTDR'
5590 DC 'OTIR'
5591 DC 'OUT'
5592 DC 'OUTD'
5593 DC 'OUTI'
5594 DC 'POP'
5595 DC 'PUSH'
5596 DC 'RES'
5597 DC 'RET'
5598 DC 'RETI'
5599 DC 'RETN'
5600 DC 'RL'
5601 DC 'RLA'
5602 DC 'RLC'
5603 DC 'RLCA'
5604 DC 'RLD'
5605 DC 'RR'
5606 DC 'RRA'
5607 DC 'RRC'
5608 DC 'RRCA'
5609 DC 'RRD'
5610 DC 'RST'
5611 DC 'SBC'
5612 DC 'SCF'
5613 DC 'SET'
5614 DC 'SLA'
5615 DC 'SRA'
5616 DC 'SRL'
5617 DC 'SUB'
5618 DC 'XOR'
5619 DC 'IN0'
5620 DC 'MLT'
5621 DC 'OTDM'
5622 DC 'OTDMR'
5623 DC 'OTIM'
5624 DC 'OTIMR'
5625 DC 'OUT0'
5626 DC 'SLP'
5627 DC 'TST'
5628 DC 'TSTIO'
5629 DB 0
5630
5631 t_BCDEHL_HL_A:
5632 DC 'B'
5633 DC 'C'
5634 DC 'D'
5635 DC 'E'
5636 DC 'H'
5637 DC 'L'
5638 DC '(HL)'
5639 DC 'A'
5640 DB 0
5641 t_BC.DE.HL.SP:
5642 DC 'BC'
5643 DC 'DE'
5644 DC 'HL'
5645 DC 'SP'
5646 DB 0
5647 t_BC.DE.HL.AF:
5648 DC 'BC'
5649 DC 'DE'
5650 t_HL.AF:
5651 DC 'HL'
5652 DC 'AF'
5653 DB 0
5654 t_BC.DE.IY.SP:
5655 DC 'BC'
5656 DC 'DE'
5657 DC 'IY'
5658 DC 'SP'
5659 DB 0
5660 t_BC.DE.IX.SP:
5661 DC 'BC'
5662 DC 'DE'
5663 DC 'IX'
5664 DC 'SP'
5665 DB 0
5666 t_HL.IX.IY:
5667 DC 'HL'
5668 t_IX.IY:
5669 DC 'IX'
5670 DC 'IY'
5671 DB 0
5672 t_tstfl_ZC:
5673 DC 'NZ'
5674 DC 'Z'
5675 DC 'NC'
5676 DC 'C'
5677 DC 'NE'
5678 DC 'EQ'
5679 DC 'GE'
5680 DC 'LT'
5681 DB 0
5682 t_tstfl_ZCPS:
5683 DC 'NZ'
5684 DC 'Z'
5685 DC 'NC'
5686 DC 'C'
5687 DC 'PO'
5688 DC 'PE'
5689 DC 'P'
5690 DC 'M'
5691 DC 'NE'
5692 DC 'EQ'
5693 DC 'GE'
5694 DC 'LT'
5695 DC 'NV'
5696 DC 'V'
5697 DB 0
5698 t__C_:
5699 DC '(C)'
5700 DB 0
5701
5702 ;-------------------------------------------------------------------------------
5703
5704 tc_set_bp:
5705 ld hl,(reg.pc)
5706 ld a,h
5707 or l
5708 jr z,l2037h
5709 ld de,BDOS
5710 and a
5711 sbc hl,de
5712 ld hl,l20edh
5713 jr z,l2031h
5714 ld iy,(reg.pc)
5715 call disas_get_instrlen
5716 jp nc,ERROR
5717 ld c,b
5718 ld b,0
5719 ld hl,(reg.pc)
5720 add hl,bc
5721 call bp_trace_enter
5722 ld iy,(reg.pc)
5723 ld hl,b_2039_start
5724 call lookup_opc
5725 ccf
5726 ret c
5727 ex de,hl
5728 l2031h:
5729 call CALL_HL
5730 call c,bp_trace_enter
5731 l2037h:
5732 scf
5733 ret
5734
5735 ;-------------------------------------------------------------------------------
5736
5737 b_2039_start:
5738 db 0ffh,0ddh,000h ;Prefix DD
5739 dw l20a7h
5740 db 0ffh,0fdh,000h ;Prefix FD
5741 dw l20ach
5742 db 0ffh,0edh,000h ;Prefix ED
5743 dw l20b8h
5744
5745 b_2048_start:
5746 db 0ffh,0cdh,000h ;call mn
5747 dw l2080h
5748 db 0ffh,0c3h,000h ;jp mn
5749 dw l208bh
5750 db 0ffh,0e9h,000h ;jp ()
5751 dw l20a2h
5752 db 0ffh,0c9h,000h ;ret
5753 dw l20dch
5754 db 0ffh,0cfh,000h ;rst 8
5755 dw l2115h
5756 db 0c7h,0c7h,000h ;rst n
5757 dw l20f9h
5758 db 0c7h,0c4h,000h ;call cc,mn
5759 dw l2080h
5760 db 0f7h,010h,000h ;djnz d; jr d
5761 dw l2093h
5762 db 0e7h,020h,000h ;jr cc,d
5763 dw l2093h
5764 db 0c7h,0c2h,000h ;jp cc,mn
5765 dw l208bh
5766 db 0c7h,0c0h,000h ;ret cc
5767 dw l20c5h
5768 db 0
5769
5770 ;-------------------------------------------------------------------------------
5771 ; call mn call cc,mn
5772 l2080h:
5773 ld a,(b_21e2_start)
5774 and a
5775 jr nz,l208bh
5776 ld a,(trace_call_flag)
5777 and a
5778 ret nz
5779
5780 ; jp mn jp cc,mn
5781 l208bh:
5782 ld l,(iy+001h)
5783 ld h,(iy+002h)
5784 scf
5785 ret
5786
5787 l2093h:
5788 ld c,(iy+001h)
5789 ld a,c
5790 rla
5791 sbc a,a
5792 ld b,a
5793 ld hl,(reg.pc)
5794 add hl,bc
5795 inc hl
5796 inc hl
5797 scf
5798 ret
5799
5800 ; jp (hl)
5801 l20a2h:
5802 ld hl,(reg.l)
5803 scf
5804 ret
5805
5806 ; Prefix DD
5807 l20a7h:
5808 ld hl,(reg.ix)
5809 jr l20afh
5810 ; Prefix FD
5811 l20ach:
5812 ld hl,(reg.iy)
5813 l20afh:
5814 ld a,(iy+001h)
5815 cp 0e9h ; jp (ix); jp (iy)
5816 scf
5817 ret z
5818 and a
5819 ret
5820
5821 ; Prefix ED
5822 l20b8h:
5823 ld a,(iy+001h)
5824 cp 04dh ; reti
5825 jr z,l20dch
5826 cp 045h ; retn
5827 jr z,l20dch
5828 and a
5829 ret
5830 l20c5h:
5831 ld a,(iy+000h)
5832 ld (l20d7h),a
5833 ld hl,(reg.f)
5834 push hl
5835 pop af
5836 call l20d7h
5837 scf
5838 jr c,l20dch
5839 ret
5840 l20d7h:
5841 nop
5842 and a
5843 pop hl
5844 inc hl
5845 jp (hl)
5846
5847 l20dch:
5848 ld a,(b_21e2_start)
5849 and a
5850 jr nz,l20edh
5851 ld a,(trace_call_flag)
5852 and a
5853 jr z,l20edh
5854 call l20edh
5855 pop hl
5856 ret
5857 l20edh:
5858 ld hl,(reg_sp)
5859 ld e,(hl)
5860 inc hl
5861 ld d,(hl)
5862 ex de,hl
5863 call bp_trace_enter
5864 l2115h:
5865 and a
5866 ret
5867
5868 l20f9h:
5869 ld a,(l0003h)
5870 cp (iy+000h)
5871 ret z
5872 ld a,(iy+000h)
5873 and 038h
5874 ld l,a
5875 ld h,000h
5876 ld a,(b_21e2_start)
5877 and a
5878 jr nz,l2113h
5879 ld a,(trace_call_flag)
5880 and a
5881 ret nz
5882 l2113h:
5883 scf
5884 ret
5885
5886 ;-------------------------------------------------------------------------------
5887 ; >>C[N][J] [steps]
5888 ; >>C[N][J] W expression
5889 ; >>C[N][J] U expression
5890 ; trace over Calls [No list] [Jumps only] /.While./.Until.
5891
5892 cmd_C:
5893 ld hl,cmd_C
5894 ld a,1
5895 jr cmd_tc
5896
5897 ;-------------------------------------------------------------------------------
5898 ; >>T[N][J] [steps]
5899 ; >>T[N][J] W expression
5900 ; >>T[N][J] U expression
5901 ; Trace [no List] [Jumps only] / .While. / .Until.
5902
5903 cmd_T:
5904 xor a
5905 ld hl,cmd_T
5906 cmd_tc:
5907 ld (cmd_rpt),hl
5908 ld (trace_call_flag),a
5909 call get_char_upper
5910 sub 'N'
5911 jr nz,tc_non
5912 inc de
5913 tc_non:
5914 ld (trace_N_flag),a
5915 call get_char_upper
5916 sub 'J'
5917 jr nz,tc_noj
5918 inc de
5919 tc_noj:
5920 ld (trace_J_flag),a
5921 call tc_chk_u_or_w
5922 jr z,tc_save_uw_expr_ptr
5923 ld hl,1 ;default: 1 step
5924 call get_lastarg_def
5925 tc_save_uw_expr_ptr:
5926 ld (trace_cnt_or_ptr),hl
5927 sub a
5928 ld (bp_p_cpu_flag),a
5929 l214ch:
5930 call tc_set_bp
5931 jr user_go1
5932
5933 l2151h:
5934 call bp_clr_temporary
5935 ld a,(trace_J_flag)
5936 and a
5937 jr nz,l216bh
5938 ld iy,(reg.pc)
5939 call sub_21c8h
5940 jr z,l216bh
5941 ld hl,b_2048_start
5942 call lookup_opc
5943 jr nc,l214ch
5944 l216bh:
5945 ld a,(trace_UW_flag) ;0 or 'U' or 'W'
5946 and a
5947 jr z,tc_cnt ;flag is 0, check for step count.
5948 ld de,(trace_cnt_or_ptr)
5949 call expr
5950 ld a,h
5951 or l
5952 add a,0ffh
5953 sbc a,a
5954 ld hl,trace_UW_flag ;'U' or 'W'
5955 xor (hl)
5956 bit 1,a ;'U' = 55H, 'W' = 57H
5957 jr z,l2193h
5958 do_break0: ;print registers and go to main loop
5959 jp do_break
5960
5961 tc_cnt:
5962 ld hl,(trace_cnt_or_ptr)
5963 dec hl
5964 ld (trace_cnt_or_ptr),hl
5965 ld a,h
5966 or l
5967 jr z,do_break0
5968 l2193h:
5969 call tc_set_bp
5970 jr nc,do_break0
5971 ld a,(trace_N_flag)
5972 ld b,a
5973 ld a,(bp_p_cpu_flag)
5974 or b
5975 ld (bp_p_cpu_flag),a
5976 user_go1:
5977 jp user_go
5978
5979 tc_chk_u_or_w:
5980 call skipbl
5981 xor a
5982 ld (trace_UW_flag),a
5983 call get_char_upper
5984 cp 'U'
5985 jr z,l21b5h
5986 cp 'W'
5987 ret nz
5988 l21b5h:
5989 inc de
5990 push af
5991 push de
5992 call expr
5993 jp c,ERROR
5994 call assert_eol
5995 pop hl
5996 pop af
5997 ld (trace_UW_flag),a
5998 sub a
5999 ret
6000
6001 sub_21c8h:
6002 ld a,(iy+000h)
6003 cp 0edh
6004 jr z,l21dah
6005 and 0dfh
6006 cp 0ddh
6007 ret nz
6008 ld a,(iy+001h)
6009 cp 0e9h
6010 ret
6011 l21dah:
6012 ld a,(iy+001h)
6013 and 0f7h
6014 cp 045h
6015 ret
6016
6017 ;-------------------------------------------------------------------------------
6018
6019 con_col:
6020 db 0
6021
6022 ;-------------------------------------------------------------------------------
6023
6024 b_21e2_start:
6025 db 0
6026 trace_call_flag:
6027 db 0 ;1=call, 0=trace
6028 trace_UW_flag:
6029 db 0 ;0 or 'U' or 'W'
6030 trace_cnt_or_ptr:
6031 dw 0
6032 trace_N_flag:
6033 db 0 ;0 if 'N'
6034 trace_J_flag:
6035 db 0 ;0 if 'J'
6036
6037 bp_p_cpu_flag:
6038 db 0
6039
6040 bp_tab:
6041 rept BP_CNT
6042 rept BP_SIZE
6043 db 0
6044 endm
6045 endm
6046
6047 expr_p1:
6048 dw expr_buf
6049
6050 expr_buf:
6051 current_cseg defl $ - current_cseg
6052 .phase current_phase + current_cseg
6053
6054 start:
6055 LD SP,ldr_end+(stack-ddtz_base)
6056 LD DE,signon ;ldr_end+(expr_buf-ddtz_base)
6057 LD C,BDOS_PSTR
6058 CALL BDOS
6059
6060 xor a
6061 dec a
6062 jp po,reloc
6063 ld de,msgz80
6064 LD C,BDOS_PSTR
6065 CALL BDOS
6066 jp 0
6067
6068 reloc:
6069 LD HL,ldr_end+ddtz_size ;start of reloc bitmap
6070 ld bc,0108h ;init bit counter
6071
6072 EXX
6073 LD HL,(BDOS+1)
6074 LD (ldr_end+(ddtz_bdos+1-ddtz_base)),HL
6075 LD BC,ddtz_size-1
6076 LD D,B
6077 LD E,0FFH
6078 INC DE ;size rounded up to next page boundary
6079 INC BC ;ddtz_size
6080 OR A
6081 SBC HL,DE ;BDOS - size
6082 LD (BDOS+1),HL ;-> new BDOS entry
6083
6084 push hl
6085 PUSH BC
6086 ld de,ldr_end
6087 sbc hl,de
6088 EX DE,HL ;-> DE
6089 LD HL,ldr_size
6090 add hl,bc
6091 ld b,h
6092 ld c,l
6093 LD HL,TPA
6094 reloc_lp:
6095 EXX
6096 djnz reloc_nl
6097 ld b,c ;reload bit counter
6098 LD e,(HL) ;get next 8 relocation bits
6099 INC HL
6100 reloc_nl:
6101 sla e
6102 EXX
6103 JR NC,reloc_next
6104 DEC HL
6105 LD A,(HL)
6106 ADD A,E
6107 LD (HL),A
6108 INC HL
6109 LD A,(HL)
6110 ADC A,D
6111 LD (HL),A
6112 reloc_next:
6113 cpi
6114 jp pe,reloc_lp
6115 dec hl
6116
6117 POP BC
6118 pop de
6119 EX DE,HL
6120 ADD HL,BC
6121 EX DE,HL
6122 DEC DE
6123 LDDR
6124 LD HL,conbuf+2-ddtz_base
6125 ADD HL,DE
6126 JP (HL)
6127
6128 current_phase defl $
6129 .dephase
6130 current_cseg defl $
6131
6132 ds EXPR_BUF_SIZE - ($ - expr_buf)
6133 expr_bufe:
6134
6135 ;-------------------------------------------------------------------------------
6136
6137 msg_Y:
6138 dc 'Yn'
6139 reg_Y:
6140 rept YREG_CNT
6141 dw 0
6142 endm
6143
6144 last_S:
6145 dw TPA
6146
6147 last_I:
6148 dw 0
6149
6150 last_O_addr:
6151 dw 0
6152 last_O_val:
6153 db 0
6154
6155 cmd_Q_jopt:
6156 db -1
6157
6158 last_D:
6159 dw TPA
6160
6161 cmdR_rindex:
6162 db 0
6163
6164 high_load:
6165 dw TPA
6166 max_load:
6167 dw TPA
6168
6169 l1262h:
6170 dw 0
6171 last_A:
6172 dw TPA
6173 cmd_A_prev:
6174 dw TPA
6175
6176 prefix_ixiy:
6177 db 0
6178
6179 isprefix_ixiy:
6180 db 0
6181 last_L:
6182 dw TPA
6183 disas_arg_16:
6184 dw 0
6185 disas_argtype:
6186 db 0
6187
6188 pbl_loop_adr:
6189 dw 0
6190
6191 symlen_cur: ;max length of symbols read so far
6192 db 0
6193 cur_fcb:
6194 dw 0
6195 fcbsym:
6196 ds 33
6197
6198 ddtz_size equ $-ddtz_base
6199 ddtz_end:
6200
6201 ;-------------------------------------------------------------------------------
6202
6203 end