From: Leo C Date: Mon, 20 May 2019 13:09:41 +0000 (+0200) Subject: Add reloc command: cmd_E X-Git-Tag: v0.5 X-Git-Url: http://cloudbase.mooo.com/gitweb/ddt180.git/commitdiff_plain/refs/tags/v0.5?ds=sidebyside Add reloc command: cmd_E ; > E addr ; relocate debugger to addr ; > ER addr ; relocate just below addr ; Move debugger to given address and restart. ; New location must not overlap with current location. --- diff --git a/ddt180.z80 b/ddt180.z80 index 437cbcc..7f0ff31 100644 --- a/ddt180.z80 +++ b/ddt180.z80 @@ -57,18 +57,31 @@ signon: dc ' (' ;------------------------------------------------------------------------------- -; Determine current execution position +; Clear old position + +cmde_clr: + ld (hl),0 + inc hl + dec bc + ld a,b + or c + jr nz,cmde_clr + +; Determine current position reloc: - ld bc,(0) - ld de,(2) - ld sp,4 + ld bc,(028h-2) + ld de,(028h) + ld a,i ;get iff2 + ex af,af' + di + ld sp,028h ;rst instr needs a minimal stack ld hl,0e9e1h ;opcpdes pop hl/jp (hl) - ld (0),hl - rst 0 + ld (028h),hl + rst 028h wearehere: - ld (0),bc - ld (2),de + ld (028h-2),bc + ld (028h),de ld de,-(wearehere-ddtz_base) add hl,de ; hl: @@ -76,17 +89,24 @@ wearehere: or a sbc hl,de ex de,hl ; de: reloc offset + ld hl,stack + add hl,de + ld sp,hl + ex af,af' + push af + pop bc + bit 2,c + jr z,$+3 + ei ld hl,ddtz_end ;start of reloc bitmap add hl,de - ld a,l - exx - ld l,a - exx - ld a,h + + push hl exx - ld h,a + pop hl ld bc,0108h ;init bit counter b (c==reload val) exx + LD HL,ddtz_base add hl,de ;--> ddtz_base ld bc,prog_size @@ -118,10 +138,6 @@ reloc_next: ;------------------------------------------------------------------------------- - -;------------------------------------------------------------------------------- - - init:: LD SP,stack @@ -168,107 +184,13 @@ l0093h: ;------------------------------------------------------------------------------- -;; Relocation loader -;; -;ldr_start:: -; LD HL,ddtz_end ;start of reloc bitmap -; ld bc,0108h ;init bit counter -; -; EXX -; LD HL,(BDOS+1) -;; LD (ddtz_base+1),HL -; LD BC,prog_size+bitmap_size-1 -; LD D,B -; LD E,0FFH -; INC DE ;size rounded up to next page boundary -; INC BC ;ddtz_size -; OR A -; SBC HL,DE ;BDOS - size -;; LD (BDOS+1),HL ;-> new BDOS entry -; -; push hl -; PUSH BC -; ld de,ddtz_base -; sbc hl,de -; EX DE,HL ;-> DE -;; LD HL,ldr_size -;; add hl,bc -;; ld b,h -;; ld c,l -; ld bc,prog_size -;; LD HL,TPA ;--> ddtz_base -;reloc_lp: -; EXX -; djnz reloc_nl -; ld b,c ;reload bit counter -; LD e,(HL) ;get next 8 relocation bits -; INC HL -;reloc_nl: -; sla e -; EXX -; JR NC,reloc_next -; DEC HL -; LD A,(HL) -; ADD A,E -; LD (HL),A -; INC HL -; LD A,(HL) -; ADC A,D -; LD (HL),A -;reloc_next: -; inc hl -; dec bc -; ld a,b -; or c -; jr nz,reloc_lp -; dec hl -; -; POP BC -; pop de -; EX DE,HL -; ADD HL,BC -; EX DE,HL -; DEC DE -; LDDR -; LD HL,conbuf+2-ddtz_base -; ADD HL,DE -; JP (HL) -; -;ldr_end:: -;ldr_size equ $ - ldr_start -; -;; Entry from relocator -;; -;; ld sp,stack -;; exx -;; ld de,ddtz_base -;; call cp_hl_de -;; jr c,l0079h -;; ex de,hl -;;l0079h: -;; ld de,TPA -;;l007ch: -;; dec hl -;; ld (hl),000h -;; ld a,h -;; sub d -;; ld b,a -;; ld a,l -;; sub e -;; or b -;; jr nz,l007ch -; -;; jp -; -;------------------------------------------------------------------------------- - CMDTAB:: - dw ERROR ;cmd_@ ;examine/substitute the displacement register @ - dw ERROR ;cmd_A ;Assemble +; dw ERROR ;cmd_@ ;examine/substitute the displacement register @ +; dw ERROR ;cmd_A ;Assemble dw cmd_B ;Breakpoints display/set/clear dw ERROR ;cmd_C ;trace over Calls dw cmd_D ;Display memory in hex and ascii - dw ERROR ; + dw cmd_E ;rElocate debugger dw ERROR ;cmd_F ;specify Filename and command line dw cmd_G ;Go dw cmd_H ;compute Hex and other expressions @@ -314,7 +236,7 @@ mainloop:: push hl ld (cmd_rpt),hl inc de - sub '@' + sub 'B' jr c,ERROR cp 'Z'+1-'@' jr nc,ERROR @@ -342,8 +264,7 @@ crlf: sub_01d9h: call pstr_inl dc '-' - dec hl - jp cpl.hl + jp neg.hl out_hl_dec_neg: push hl @@ -410,9 +331,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,'"' @@ -736,12 +656,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 @@ -752,7 +672,7 @@ sub_035dh: jr c,error0 ret -sub_0363h: +get_arg_final: call sub_035dh l0366h: jp assert_eol @@ -1077,8 +997,13 @@ fact_reg.CPU: ld h,000h ret +fact_factinv: + call fact_factor + jr cpl.hl + fact_factneg: call fact_factor +neg.hl: dec hl cpl.hl: ld a,h @@ -1089,10 +1014,6 @@ cpl.hl: ld l,a ret -fact_factinv: - call fact_factor - jr cpl.hl - fact_mem: call expr1 jr c,error1 @@ -1370,6 +1291,49 @@ b_0709_start: db 000h db 000h +;------------------------------------------------------------------------------- +; > E addr +; relocate debugger to addr +; > ER addr +; relocate just below addr +; +; Move debugger to given address and restart. +; New location must not overlap with current location. + + +cmd_E: + call skipbl + sub 'R' + jr nz,$+3 + inc de + push af + call get_arg_final + + ld bc,prog_size+bitmap_size + pop af + jr nz,cmde_bottom + sbc hl,bc +cmde_bottom: + ld ix,cmde_clr-ddtz_base + ex de,hl ;de = dst + add ix,de + ld hl,ddtz_base ;hl = src + + push hl + or a + sbc hl,de + call c,neg.hl ;abs(distance) + or a + sbc hl,bc + jp c,error + pop hl + push hl + push bc + ldir + pop bc + pop hl + jp (ix) + ;------------------------------------------------------------------------------- ; > G [startaddr] [;breakp..] ; Go [to start] [with temporary breakpoints] @@ -1759,7 +1723,7 @@ cmd_X: call get_line call skipbl jr z,l0c30h - call sub_0363h + call get_arg_final ex de,hl pop bc pop hl @@ -2031,11 +1995,11 @@ cmd_O: ret ;------------------------------------------------------------------------------- -; > Vstartaddr endaddr targetaddr +; > V startaddr endaddr targetaddr ; Verify (compare) two memory areas cmd_V: - call sub_034eh + call get_arg_range_target l0dedh: push bc ld a,(de) @@ -2067,7 +2031,7 @@ l0e10h: ; Move memory cmd_M: - call sub_034eh + call get_arg_range_target call cp_hl_de jr nc,cmdm_up add hl,bc