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