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