X-Git-Url: http://cloudbase.mooo.com/gitweb/ddt180.git/blobdiff_plain/efc2486ea0340c32c372f5565a48eea068687cac..a3bccdeb0f929b999c07c180da6615da6460b1ad:/ddt180.z80 diff --git a/ddt180.z80 b/ddt180.z80 index 81b68b4..7f0ff31 100644 --- a/ddt180.z80 +++ b/ddt180.z80 @@ -6,101 +6,110 @@ ; - Use Digital Research Link-80 to generate a .PRL file (op switch). ; - Cut the .PRL header (first 256 byte) end rename the result to DDTZ.COM. -TPA equ 0100h + +; Some greneral definitions + +BS equ 08h +TAB equ 09h +CR equ 0dh +LF equ 0ah +DEL equ 7fh +CNTRX equ 'X'-'@' + +; CP/M memory layout + +BDOS equ 5 +TPA equ 0100h + +; ddtz specific definitions + +STACK_SIZE equ 80 ;ddtz internal stack +CONBUF_SIZE equ 80 ;Size of console input buffer +BP_CNT equ 12 ;Number of breakpoints +BP_SIZE equ 4 ;Size of a breakpoint record + +bitmap_size equ (prog_size+7)/8 + +;------------------------------------------------------------------------------- cseg -ldr_start: - LD SP,stack +start:: +ddtz_base:: + jr reloc + nop +l0003h: + rst 30h ;rst used by ddtz +di_or_ei: ;ints enabled/disabled while ddtz is running + nop + ret -; LD DE,signon -; LD C,BDOS_PSTR -; CALL BDOS +?const: jp 0 ; return console input status +?conin: jp 0 ; return console input character +?cono: jp 0 ; send console output character - ld hl,(1) ;wboot addr - ld de,?const - ld b,3 -vini_l: - inc hl - inc hl - inc hl - ex de,hl - inc hl - ld (hl),e - inc hl - ld (hl),d - inc hl - ex de,hl - djnz vini_l +;------------------------------------------------------------------------------- signon: - call pstr_inl db 'DDTZ/180' db ' - Version ' maclib version.inc defvers - dc CR,LF - -; 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 - - ld a,i - ld (reg.i),a - ld a,0f3h - jp po,l0093h - ld a,0fbh -l0093h: - ld (reg.iff),a - call di_or_ei - ld hl,ddtz_base - ld l,000h - ld (reg_sp),hl - - jp mainloop + dc ' (' ;------------------------------------------------------------------------------- -; Relocation loader -; - LD HL,ddtz_end ;start of reloc bitmap - ld bc,0108h ;init bit counter +; Clear old position - EXX - LD HL,(BDOS+1) - LD (ddtz_base+1),HL - LD BC,ddtz_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 +cmde_clr: + ld (hl),0 + inc hl + dec bc + ld a,b + or c + jr nz,cmde_clr + +; Determine current position + +reloc: + 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 (028h),hl + rst 028h +wearehere: + ld (028h-2),bc + ld (028h),de + ld de,-(wearehere-ddtz_base) + add hl,de ; hl: + + ld de,ddtz_base ; de: + 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 push hl - PUSH BC - ld de,ldr_end - sbc hl,de - EX DE,HL ;-> DE - LD HL,ldr_size - add hl,bc - ld b,h - ld c,l - LD HL,TPA + exx + 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 reloc_lp: EXX djnz reloc_nl @@ -125,112 +134,63 @@ reloc_next: 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 ;------------------------------------------------------------------------------- -; DDT/Z core -; -; Some greneral definitions - -BS equ 08h -TAB equ 09h -CR equ 0dh -LF equ 0ah -DEL equ 7fh -CNTRX equ 'X'-'@' -; CP/M memory layout - -BDOS equ 5 -TPA equ 0100h - -; BDOS function calls - -BDOS_PSTR equ 9 ;Print String - -; ddtz specific definitions - -STACK_SIZE equ 80 ;ddtz internal stack -CONBUF_SIZE equ 80 ;Size of console input buffer -BP_CNT equ 12 ;Number of breakpoints -BP_SIZE equ 4 ;Size of a breakpoint record - -;------------------------------------------------------------------------------- - -ddtz_base: - jp 0 -l0003h: - rst 30h -di_or_ei: - nop - ret - - ds STACK_SIZE - -stack: -reg.l2: db 000h -reg.h2: db 000h -reg.e2: db 000h -reg.d2: db 000h -reg.c2: db 000h -reg.b2: db 000h -reg.f2: db 000h -reg.a2: db 000h - db 000h -reg.i: db 000h -reg.iy: dw 0000h -reg.ix: dw 0000h -reg.f: db 000h -reg.a: db 000h -reg.c: db 000h -reg.b: db 000h -reg.e: db 000h -reg.d: db 000h -reg.l: db 000h -reg.h: db 000h -reg_sp: dw TPA -reg.iff: - db 0f3h - db 0c3h -reg.pc: dw TPA +init:: + LD SP,stack -cmd_rpt:dw mainloop + ld hl,(1) ;wboot addr + ld de,?const + ex de,hl + ld b,3 +vini_l: + inc de + inc de + inc de + inc hl + ld (hl),e + inc hl + ld (hl),d + inc hl + djnz vini_l -;------------------------------------------------------------------------------- + ld hl,signon + call pstr + ld hl,ddtz_base + call out_hl + call pstr_inl + dc ' - ' + ld de,prog_size+bitmap_size-1 + add hl,de + call out_hl + call pstr_inl + dc ')',CR,LF -conbuf: - db CONBUF_SIZE + ld a,i + ld (reg.i),a + ld a,0f3h + jp po,l0093h + ld a,0fbh +l0093h: + ld (reg.iff),a + call di_or_ei + ld hl,ddtz_base + ld l,000h + ld (reg_sp),hl - ds CONBUF_SIZE + 3 - ($ - conbuf) + jp mainloop ;------------------------------------------------------------------------------- -?const: jp 0 ; return console input status -?conin: jp 0 ; return console input character -?cono: jp 0 ; send console output character - -CMDTAB: - dw ERROR ;cmd_@ ;examine/substitute the displacement register @ - dw ERROR ;cmd_A ;Assemble +CMDTAB:: +; 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 @@ -257,7 +217,7 @@ ERROR: call pstr_inl dc '?',CR,LF ;fall thru -mainloop: +mainloop:: ld sp,stack ld hl,(reg.pc) call bp_clr_temporary @@ -276,7 +236,7 @@ mainloop: push hl ld (cmd_rpt),hl inc de - sub '@' + sub 'B' jr c,ERROR cp 'Z'+1-'@' jr nc,ERROR @@ -304,8 +264,7 @@ crlf: sub_01d9h: call pstr_inl dc '-' - dec hl - jp cpl.hl + jp neg.hl out_hl_dec_neg: push hl @@ -372,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,'"' @@ -479,7 +437,6 @@ DELC: call DELC1 dec hl dec b - inc c ld a,(hl) cp ' ' ret nc @@ -500,13 +457,10 @@ DELL: get_line: push hl ; ld hl,conbuf ; - ld c,(hl) ; - inc hl ; - ld b,000h ; - inc hl ; + ld b,0 ; inlnxtch: - ld a,c ; - or a ; + ld a,b ; + cp CONBUF_SIZE ; jr z,inl_e ; call incharw ; cp CR ; @@ -542,16 +496,12 @@ gl_5: call outchar ; inc hl ; inc b ; - dec c ; jr inlnxtch ; inl_e: ld (hl),0 - ld hl,conbuf+1 ; - ld (hl),b ; call CRLF ; - inc hl - ex de,hl + ld de,conbuf ; pop hl ; ret ; @@ -706,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 @@ -722,7 +672,7 @@ sub_035dh: jr c,error0 ret -sub_0363h: +get_arg_final: call sub_035dh l0366h: jp assert_eol @@ -986,6 +936,9 @@ do_factor: ld hl,TPA cp 'L' ret z + ld hl,(reg.pc) + cp '$' + ret z cp '-' jr z,fact_factneg cp '~' @@ -1044,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 @@ -1056,10 +1014,6 @@ cpl.hl: ld l,a ret -fact_factinv: - call fact_factor - jr cpl.hl - fact_mem: call expr1 jr c,error1 @@ -1337,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] @@ -1726,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 @@ -1998,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) @@ -2034,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 @@ -2044,7 +2041,7 @@ cmd_M: dec hl dec de lddr - db 01h ;swallow ldir instruction (ld bc,...) + ret cmdm_up: ldir ret @@ -2143,9 +2140,9 @@ l0ed3h: ret sub_0ee6h: - ld hl,conbuf+1 + ld hl,conbuf call sub_0ef7h - ld de,conbuf+1 + ld de,conbuf and a sbc hl,de ld b,l @@ -3723,8 +3720,50 @@ last_L: pbl_loop_adr: dw 0addeh +;------------------------------------------------------------------------------- + +conbuf:: + ds CONBUF_SIZE+1 + +;------------------------------------------------------------------------------- + + rept (STACK_SIZE+3)/4 + db 0deh,0adh,0beh,0efh + endm +stack:: +reg.l2: db 000h +reg.h2: db 000h +reg.e2: db 000h +reg.d2: db 000h +reg.c2: db 000h +reg.b2: db 000h +reg.f2: db 000h +reg.a2: db 000h + db 000h +reg.i: db 000h +reg.iy: dw 0000h +reg.ix: dw 0000h +reg.f: db 000h +reg.a: db 000h +reg.c: db 000h +reg.b: db 000h +reg.e: db 000h +reg.d: db 000h +reg.l: db 000h +reg.h: db 000h +reg_sp: dw TPA +reg.iff: + db 0f3h + db 0c3h +reg.pc: dw TPA + +cmd_rpt:dw mainloop + +;------------------------------------------------------------------------------- + ddtz_size equ $-ddtz_base -ddtz_end: +prog_size equ $-start +ddtz_end:: ;-------------------------------------------------------------------------------