From 798417c1f1b4b1c5614e213f42ae2275ea4075c1 Mon Sep 17 00:00:00 2001 From: Leo C Date: Thu, 6 Feb 2020 11:41:27 +0100 Subject: [PATCH] Renaming/minor opt (from tiny) --- Makefile | 8 +- ddt180.z80 | 322 ++++++++++++++++++++++++++--------------------------- 2 files changed, 162 insertions(+), 168 deletions(-) diff --git a/Makefile b/Makefile index 44b6c27..6ac3191 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,7 @@ ZIP := zip AS_OPT := MFS -.phony: all +.PHONY: all all: $(PROG).com @@ -57,7 +57,7 @@ version.inc: autorevision.cache db '$(VERS)'\r\n\ endm\r\n\032" > $@ -.phony: dist +.PHONY: dist dist: $(PROG).com version.inc $(GIT) archive --format=zip --prefix=$(PREFIX)/ -9 -o $(DIST_NAME) HEAD^{tree} @mkdir -p $(PREFIX) @@ -65,7 +65,7 @@ dist: $(PROG).com version.inc $(ZIP) -r -9 $(DIST_NAME) $(PREFIX) $(PROG).com @$(RM) -r $(PREFIX) -.phony: clean +.PHONY: clean clean: rm -f $(PROG).com *.rel *.lst *.prl @@ -76,7 +76,7 @@ clean: define cpm-asm = COMMAND="$(ASM) -$(basename $<)/$(AS_OPT)"; \ OUTPUT=$$(mktemp); echo $${COMMAND}; \ -$${COMMAND} > $${OUTPUT}; \ +$${COMMAND} > $${OUTPUT} < $<; \ grep -q '^ 0 Error(s) Detected' $${OUTPUT}; ERROR=$$? ; \ if [ "$${ERROR}" != "0" ]; then cat $${OUTPUT}; rm -f $@; fi ; \ exit $${ERROR} diff --git a/ddt180.z80 b/ddt180.z80 index 60c588a..a4da4cb 100644 --- a/ddt180.z80 +++ b/ddt180.z80 @@ -240,9 +240,8 @@ mainloop: jr c,ERROR cp 'Z'+1-'@' jr nc,ERROR - add a,a ld hl,CMDTAB - call add_hl_a + call add_hl_a2 ld a,(hl) inc hl ld h,(hl) @@ -258,9 +257,9 @@ p_msg_error: crlf: call pstr_inl dc CR,LF - call inchar - ld a,0 + xor a ld (con_col),a + call inchar jr c,mainloop ret @@ -286,8 +285,7 @@ l01bfh: sub_01d9h: call pstr_inl dc '-' - dec hl - jp cpl.hl + jp neg.hl out_hl_dec_neg: push hl @@ -354,9 +352,8 @@ out.bin.b: l01c9h: rlca push af - ld a,'0'/2 - adc a,a - call outchar + and 1 + call out_dgt pop af djnz l01c9h ld a,'"' @@ -369,7 +366,8 @@ out.ascii: cp ' ' push af call nc,outbl - call outquote + call pstr_inl + dc '''' pop af jr nc,l0242h sub 0c0h @@ -381,7 +379,8 @@ l0242h: call outchar cp '''' call z,outchar - call outquote + call pstr_inl + dc '''' sla c pop bc ret nc @@ -396,10 +395,6 @@ outbl2: call outbl outbl: ld a,' ' - jr outchar - -outquote: - ld a,'''' outchar: push ix push iy @@ -421,21 +416,6 @@ outchar: pop ix ret -pstr: - ld a,(hl) - inc hl - and a - ret z - call outchar - ret m - jr pstr - -pstr_inl: - ex (sp),hl - call pstr - ex (sp),hl - ret - p_align_@_sym: push de ld de,(var.@) @@ -558,6 +538,8 @@ chk_stack: ;------------------------------------------------------------------------------- +add_hl_a2: + add a,a add_hl_a: add a,l ld l,a @@ -711,22 +693,23 @@ l031eh: pop bc ret l0336h: - call sub_0345h + call str_sel_next l0339h: pop de and a pop bc ret -sel_dc_string: +str_sel: inc b -l033eh: - dec b - ret z - call sub_0345h - jr l033eh + jr str_sel2 +str_sel1: + call str_sel_next +str_sel2: + djnz str_sel1 + ret -sub_0345h: +str_sel_next: ld a,(hl) and a ret z @@ -737,12 +720,12 @@ l0348h: ret m jr l0348h -sub_034eh: +get_arg_range_target: call get_arg_range push hl push bc call next_arg - call sub_0363h + call get_arg_final ex de,hl pop bc pop hl @@ -753,7 +736,7 @@ sub_035dh: jr c,error0 ret -sub_0363h: +get_arg_final: call sub_035dh l0366h: jp assert_eol @@ -902,8 +885,7 @@ l0406h: l0411h: ld hl,tab_func_eqlege ld a,b - add a,a - call add_hl_a + call add_hl_a2 ld c,(hl) inc hl ld b,(hl) @@ -1057,8 +1039,7 @@ do_binary_op: call lookupch ld a,b ld hl,tblf_opa - add a,a - call add_hl_a + call add_hl_a2 ld c,(hl) inc hl ld b,(hl) @@ -1142,9 +1123,8 @@ fact_reg.Y: jr c,error1 inc de get_y_val: - add a,a ld hl,reg_Y - call add_hl_a + call add_hl_a2 ld a,(hl) inc hl ld h,(hl) @@ -1184,14 +1164,19 @@ fact_reg.CPU: inc hl ld h,(hl) ld l,a - and a + xor a ;clr cy, a=0 bit 0,c ret nz - ld h,000h + ld h,a ret +fact_factinv: + call fact_factor + jr cpl.hl + fact_factneg: call fact_factor +neg.hl: dec hl cpl.hl: ld a,h @@ -1202,10 +1187,6 @@ cpl.hl: ld l,a ret -fact_factinv: - call fact_factor - jr cpl.hl - fact_mem: call expr1 jr c,error1 @@ -1435,13 +1416,13 @@ p_f: call p_flags ld a,(reg.iff) cp 0f3h - jp z,outbl + jr z,outbl_1 ld a,'E' jp outchar p_f2: ld a,(reg.f2) call p_flags - jp outbl + jr outbl_1 p_flags: push hl @@ -1496,10 +1477,10 @@ l06deh: ld a,(de) call out_hex l06e2h: - call outbl pop de pop hl - ret +outbl_1: + jp outbl b_06e9_start: DC 'A ' @@ -2118,7 +2099,7 @@ sub_0bdch: add hl,bc ex de,hl ld c,003h - jp l0c33h + jr l0c33h ;------------------------------------------------------------------------------- ; > X @@ -2142,7 +2123,7 @@ cmd_X: jp z,ERROR ex de,hl ld hl,t_reg_names - call sel_dc_string + call str_sel l0c12h: call l0c33h l0c15h: @@ -2152,7 +2133,7 @@ l0c15h: call get_line call skipbl jr z,l0c30h - call sub_0363h + call get_arg_final ex de,hl pop bc pop hl @@ -2454,7 +2435,7 @@ cmd_O: ; Verify (compare) two memory areas cmd_V: - call sub_034eh + call get_arg_range_target l0dedh: push bc ld a,(de) @@ -2476,12 +2457,9 @@ l0dedh: call crlf l0e10h: pop bc - inc hl inc de - dec bc - ld a,b - or c - jr nz,l0dedh + cpi + jp pe,l0dedh ret ;------------------------------------------------------------------------------- @@ -2495,7 +2473,7 @@ cmd_M: inc de l0e1fh: push af - call sub_034eh + call get_arg_range_target push hl push de push bc @@ -2709,9 +2687,9 @@ sub_0ee6h: ret nz jp ERROR -sub_0ef7h: +sub_0ef7h: ;from cmd_Q, cmd_Z db 0e6h ; and 037h (clear carry) -sub_0ef8h: +sub_0ef8h: ;from cmd_S scf l0ef9h: push af @@ -3766,7 +3744,7 @@ as.LD: l1395h: call assert_eol ld a,(prefix_ixiy) -l139bh: +as_store_4: ld (iy+000h),a ld (iy+001h),b ld (iy+002h),l @@ -3781,7 +3759,7 @@ l13aah: inc de ld b,032h -as.store_3: +as_store_3: call assert_eol ld (iy+000h),b ld (iy+001h),l @@ -3797,10 +3775,10 @@ l13c2h: l13c9h: call assert_eol ld a,0edh - jr l139bh + jr as_store_4 l13d0h: ld b,022h - jr as.store_3 + jr as_store_3 l13d4h: ld b,a @@ -3874,7 +3852,7 @@ l1432h: add a,006h l143fh: ld b,a -as.store_2: +as_store_2: call assert_eol ld (iy+000h),b ld (iy+001h),l @@ -3901,7 +3879,7 @@ l1466h: call test_expr call test_paren_close ld b,03ah - jp as.store_3 + jp as_store_3 l1471h: call assert_comma @@ -3965,7 +3943,7 @@ l14cch: l14e3h: ld b,02ah - jp as.store_3 + jp as_store_3 l14e8h: call test_expr @@ -3973,7 +3951,7 @@ l14e8h: ld a,001h add a,b ld b,a - jp as.store_3 + jp as_store_3 l14f5h: call assert_comma call get_char_upper @@ -4175,7 +4153,7 @@ l163ch: l163eh: pop af call test_expr - jp as.store_3 + jp as_store_3 as.RET: call arg.cc_ZCPS @@ -4208,7 +4186,7 @@ l1666h: pop af l166eh: call test_expr - jp as.store_3 + jp as_store_3 l1674h: call assert_eol ld a,b @@ -4223,7 +4201,7 @@ l1680h: ld b,0fdh l1687h: ld l,0e9h - jp as.store_2 + jp as_store_2 l168ch: DC '(HL)' @@ -4246,7 +4224,7 @@ l16a9h: call assert_comma l16aeh: call arg.j_displ - jp as.store_2 + jp as_store_2 as.IM: call arg.imm_8bit @@ -4302,7 +4280,7 @@ as.IN: jr c,l1715h call arg.addr_8bit ld b,0dbh - jp as.store_2 + jp as_store_2 l170fh: call assert_comma call sub_171bh @@ -4336,7 +4314,7 @@ l1739h: jr nz,error7 inc de ld b,0d3h - jp as.store_2 + jp as_store_2 as.EX: ld hl,b_176d_start @@ -4464,7 +4442,7 @@ error8: arg.zz: push hl - ld hl,t_BC.DE.HL.AF + ld hl,t_arg_rp2 jr l181fh arg.reg_16bit: @@ -4473,7 +4451,7 @@ arg.reg_16bit: arg.ww: push hl - ld hl,t_BC.DE.HL.SP + ld hl,t_arg_rp l181fh: push bc call sub_030ah @@ -4493,7 +4471,7 @@ arg.r_HL_A: call skipbl push bc push hl - ld hl,t_BCDEHL_HL_A + ld hl,t_arg_r call sub_030ah ld a,b pop hl @@ -4581,7 +4559,7 @@ arg.cc_ZCPS: jr l18b1h arg.cc_ZC: - ld hl,t_tstfl_ZC + ld hl,t_arg_cc ld c,003h l18b1h: push bc @@ -4703,10 +4681,10 @@ p_disas_instr: ld a,(con_col) add a,5 ld c,a - call pstr + call pstr ;print mnemonic call p_goto_col ex de,hl - call call_hl + call call_hl ;print arguments pop bc ld a,(disas_argtype) ld hl,(disas_arg_16) @@ -4755,6 +4733,65 @@ l19b1h: ;------------------------------------------------------------------------------- +disas_nopfx: + ld hl,b_1b54_start ;2 byte opcodes + call lookup_op + ld b,2 + ret c + ld hl,b_1ab6_start ;1 byte opcodes (no parameters) + call sub_1a72h + ld b,1 + ret c + ld hl,b_1ad1_start ;1 byte opcodes + call lookup_op + ld b,1 + ret c + ld hl,b_1b9b_start ;3 byte opcodes + call lookup_op + ret nc + ld b,3 + ret + +;------------------------------------------------------------------------------- + +disas_pfx.ED: + inc iy + ld hl,b_1bc9_start ;1 byte opcode, no arguments + call sub_1a72h + ld b,2 + ret c + ld hl,b_1bf4_start + call lookup_op + ld b,2 + ret c + + ld hl,l228bh + call lookup_op + ld b,3 + ret c + ld hl,b_1c40_start + call lookup_op + ld b,4 + ret + +;------------------------------------------------------------------------------- + +disas_pfx.CB: + push iy + inc iy + ld a,(isprefix_ixiy) + and a + jr z,l1a42h + inc iy +l1a42h: + ld hl,b_1c55_start + call lookup_op + pop iy + ld b,2 + ret + +;------------------------------------------------------------------------------- + disas_pfx.DDFD: inc iy ld hl,b_19ef_start @@ -4831,65 +4868,6 @@ l1a0ah: ;------------------------------------------------------------------------------- -disas_pfx.ED: - inc iy - ld hl,b_1bc9_start - call sub_1a72h - ld b,2 - ret c - ld hl,b_1bf4_start - call lookup_opc - ld b,2 - ret c - - ld hl,l228bh - call lookup_opc - ld b,3 - ret c - ld hl,b_1c40_start - call lookup_opc - ld b,4 - ret - -;------------------------------------------------------------------------------- - -disas_pfx.CB: - push iy - inc iy - ld a,(isprefix_ixiy) - and a - jr z,l1a42h - inc iy -l1a42h: - ld hl,b_1c55_start - call lookup_opc - pop iy - ld b,2 - ret - -;------------------------------------------------------------------------------- - -disas_nopfx: - ld hl,b_1b54_start - call lookup_opc - ld b,2 - ret c - ld hl,b_1ab6_start - call sub_1a72h - ld b,1 - ret c - ld hl,b_1ad1_start - call lookup_opc - ld b,1 - ret c - ld hl,b_1b9b_start - call lookup_opc - ret nc - ld b,3 - ret - -;------------------------------------------------------------------------------- - sub_1a72h: ld a,(hl) cp 0ffh @@ -4916,7 +4894,7 @@ test_DDFD: scf ret -lookup_opc: +lookup_op: ld a,(iy+000h) and (hl) inc hl @@ -4928,7 +4906,7 @@ lookup_opc: inc hl ld a,(hl) and a - jr nz,lookup_opc + jr nz,lookup_op ret l1aa8h: @@ -5023,7 +5001,7 @@ b_1ad1_start: dw l1ce5h db 0 -; 2 byte opdodes +; 2 byte opcodes b_1b54_start: db 0c7h,006h,056h ;ld r,nn dw l1cfah @@ -5499,7 +5477,7 @@ l1e61h: jp p_arg_nn_rp p_arg_r1: - ld hl,t_BCDEHL_HL_A + ld hl,t_arg_r jr p_arg b_1e78_start: @@ -5512,10 +5490,10 @@ p_arg_hlixiy: ld hl,t_HL.IX.IY jr p_arg p_arg_zz: - ld hl,t_BC.DE.HL.AF + ld hl,t_arg_rp2 jr l1e8eh p_arg_ww: - ld hl,t_BC.DE.HL.SP + ld hl,t_arg_rp l1e8eh: ld a,(iy+000h) rra @@ -5537,8 +5515,24 @@ p_arg_cc0: ld hl,t_tstfl_ZCPS p_arg: ld b,a - call sel_dc_string - jp pstr + ;fall thru +pstr_sel: + call str_sel + ;fall thru +pstr: + ld a,(hl) + inc hl + and a + ret z + call outchar + ret m + jr pstr + +pstr_inl: + ex (sp),hl + call pstr + ex (sp),hl + ret ;------------------------------------------------------------------------------- @@ -5622,7 +5616,7 @@ t_MNEMONICS: DC 'TSTIO' DB 0 -t_BCDEHL_HL_A: +t_arg_r: DC 'B' DC 'C' DC 'D' @@ -5632,13 +5626,13 @@ t_BCDEHL_HL_A: DC '(HL)' DC 'A' DB 0 -t_BC.DE.HL.SP: +t_arg_rp: DC 'BC' DC 'DE' DC 'HL' DC 'SP' DB 0 -t_BC.DE.HL.AF: +t_arg_rp2: DC 'BC' DC 'DE' t_HL.AF: @@ -5663,7 +5657,7 @@ t_IX.IY: DC 'IX' DC 'IY' DB 0 -t_tstfl_ZC: +t_arg_cc: DC 'NZ' DC 'Z' DC 'NC' @@ -5703,7 +5697,7 @@ tc_set_bp: ld de,BDOS and a sbc hl,de - ld hl,l20edh + ld hl,l20edh ;set break after BDOS call jr z,l2031h ld iy,(reg.pc) call disas_get_instrlen @@ -5715,7 +5709,7 @@ tc_set_bp: call bp_trace_enter ld iy,(reg.pc) ld hl,b_2039_start - call lookup_opc + call lookup_op ccf ret c ex de,hl @@ -5849,7 +5843,7 @@ l20dch: pop hl ret l20edh: - ld hl,(reg_sp) + ld hl,(reg_sp) ;break on return address ld e,(hl) inc hl ld d,(hl) @@ -5931,7 +5925,7 @@ l2151h: call sub_21c8h jr z,l216bh ld hl,b_2048_start - call lookup_opc + call lookup_op jr nc,l214ch l216bh: ld a,(trace_UW_flag) ;0 or 'U' or 'W' -- 2.39.2