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