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