X-Git-Url: http://cloudbase.mooo.com/gitweb/ddt180.git/blobdiff_plain/12eea40b2a19262bffbb570149ef9a6c68c3d8b5..c18ba81991314d10f95b00051fd1e3fbcebc8e48:/ddt180.z80 diff --git a/ddt180.z80 b/ddt180.z80 index 3ab5b88..3a445c3 100644 --- a/ddt180.z80 +++ b/ddt180.z80 @@ -39,21 +39,11 @@ CNTRX equ 'X'-'@' ; CP/M memory layout BDOS equ 5 -dfcb1 equ 05ch -dfcb2 equ 06ch -DMA_BUF equ 080h TPA equ 0100h ; BDOS function calls BDOS_PSTR equ 9 ;Print String -BDOS_OPEN equ 15 ;Open File -BDOS_CLOSE equ 16 ;Close File -BDOS_DELETE equ 19 ;Delete File -BDOS_READ equ 20 ;Read Sequential -BDOS_WRITE equ 21 ;Write Sequential -BDOS_CREATE equ 22 ;Make File -BDOS_SETDMA equ 26 ;Set DMA Address ; ddtz specific definitions @@ -61,7 +51,7 @@ STACK_SIZE equ 80 ;ddtz internal stack CONBUF_SIZE equ 80 ;Size of console input buffer EXPR_BUF_SIZE equ 128 ;expressen buffer for conditional breakpoints BP_CNT equ 12 ;Number of breakpoints -BP_SIZE equ 6 ;Size of a breakpoint record +BP_SIZE equ 4 ;Size of a breakpoint record ;------------------------------------------------------------------------------- @@ -156,20 +146,35 @@ l0093h: ld hl,ddtz_base ld l,000h ld (reg_sp),hl - ld a,(dfcb1+1) - cp ' ' - ld hl,0 - call nz,read_file + + ld hl,(1) ;wboot addr + ld de,?const + ld b,6 +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 + jr mainloop ds CONBUF_SIZE + 3 - ($ - conbuf) ;------------------------------------------------------------------------------- -?const: -?conin: -?cono: - ret +?const: jp 0 ; return console input status +?conin: jp 0 ; return console input character +?cono: jp 0 ; send console output character +?list: jp 0 ; send list output character +?auxo: jp 0 ; send auxiliary output character +?auxi: jp 0 ; return auxiliary input character CMDTAB: dw ERROR ;cmd_@ ;examine/substitute the displacement register @ @@ -178,7 +183,7 @@ CMDTAB: dw ERROR ;cmd_C ;trace over Calls dw cmd_D ;Display memory in hex and ascii dw ERROR ; - dw cmd_F ;specify Filename and command line + dw ERROR ;cmd_F ;specify Filename and command line dw cmd_G ;Go dw cmd_H ;compute Hex and other expressions dw cmd_I ;Input a byte from port @@ -195,7 +200,7 @@ CMDTAB: dw cmd_T ;Trace dw ERROR ; dw cmd_V ;Verify (compare) two memory areas - dw cmd_W ;Write a file to disk + dw ERROR ;cmd_W ;Write a file to disk dw cmd_X ;eXamine [and substitute] registers dw ERROR ;cmd_Y ;examine [and substitute] Y variables dw cmd_Z ;Zap (fill) memory with a byte string @@ -244,9 +249,9 @@ exe_hl: crlf: call pstr_inl dc CR,LF - call inchar - ld a,0 + xor a ld (con_col),a + call inchar jr c,mainloop ret @@ -393,7 +398,6 @@ pstr: and a ret z call outchar - and a ret m jr pstr @@ -413,25 +417,9 @@ p_goto_col: ;------------------------------------------------------------------------------- -$ci: - push hl - push de - push bc - call ?conin - pop bc - pop de - pop hl - ret - -$co: - push hl - push de - push bc - ld c,a - call ?cono - pop bc - pop de - pop hl +incharw: + call inchar + jr nc,incharw ret ;------------------------------------------------------------------------------- @@ -467,18 +455,8 @@ DELC: cp ' ' ret nc DELC1: - push de - push hl - push bc - ld c,BS - call ?cono - ld c,' ' - call ?cono - ld c,BS - call ?cono - pop bc - pop hl - pop de + call pstr_inl + dc BS,' ',BS ret DELL: @@ -501,18 +479,17 @@ inlnxtch: ld a,c ; or a ; jr z,inl_e ; - call $ci ; + call incharw ; cp CR ; jr z,inl_e ;Accept line cp LF ; jr z,inl_e ;Accept line + cp BS ; - jr nz,gl_1 ; - call DELC ;Delete Char - jr inlnxtch ; -gl_1: + jr z,gl_1 ; cp DEL ; jr nz,gl_2 ; +gl_1: call DELC ;Delete Char jr inlnxtch ; gl_2: @@ -529,11 +506,11 @@ gl_4: cp ' ' ; jr nc,gl_5 ; ld a,'^' ;Controll characters - call $co ; + call outchar ; ld a,(hl) ; add a,'@' ; gl_5: - call $co ; + call outchar ; inc hl ; inc b ; dec c ; @@ -544,7 +521,6 @@ inl_e: ld hl,conbuf+1 ; ld (hl),b ; call CRLF ; - inc hl ex de,hl pop hl ; @@ -569,17 +545,20 @@ skipbl0: inc de skipbl: call get_char_upper - call test_whitespace + cp ' ' + jr z,skipbl0 + cp TAB jr z,skipbl0 or a ret +;------------------------------------------------------------------------------- + next_arg: call skipbl cp ',' ret nz - inc de - call skipbl + call skipbl0 cp a ret @@ -1483,11 +1462,10 @@ bp_clr_temporary: ; set breakpoints ; > BX ; clear all breakpoints -; > BX address [address..] +; > BX breakp [breakp..] ; clear breakpoints ; -; where breakp is: -; expression +; breakp can be any valid expression cmd_B: call skipbl @@ -1571,9 +1549,6 @@ bp_enter: pop de ld (ix+002h),l ld (ix+003h),h - call bp_get_count - ld (ix+004h),l - ld (ix+005h),h call next_arg pop af ld (ix+000h),a @@ -1591,15 +1566,6 @@ bp_get_freeslot: error12 jp ERROR -bp_get_count: - call skipbl - ld hl,1 - cp ':' - ret nz - inc de - call expr - jr c,error12 - ret ;------------------------------------------------------------------------------- ; Breakpoint handling routine. @@ -1667,32 +1633,14 @@ sub_0913h: ld d,(ix+003h) ld hl,(reg.pc) call cp_hl_de - push bc - call z,sub_0942h - pop bc -l0938h: - - call bpl_next - ex af,af' - ret - -sub_0942h: + jr nz,l0938h ex af,af' res 7,a - ex af,af' - ld e,(ix+004h) - ld d,(ix+005h) - dec de - ld a,d - or e - jr z,l0974h - ld (ix+004h),e - ld (ix+005h),d - ret -l0974h: - ex af,af' or (ix+000h) ex af,af' +l0938h: + call bpl_next + ex af,af' ret bp_restore_mem: @@ -1733,8 +1681,6 @@ bp_tst_e: bp_trace_enter: call bp_get_freeslot - ld (ix+004h),001h - ld (ix+005h),000h ld (ix+002h),l ld (ix+003h),h ld a,(b_21e2_start) @@ -2160,29 +2106,17 @@ 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 ;------------------------------------------------------------------------------- -; > M[V] startaddr endaddr destaddr -; Move memory [and verify] +; > M startaddr endaddr destaddr +; Move memory cmd_M: - call get_char_upper - cp 'V' - jr nz,l0e1fh - inc de -l0e1fh: - push af call sub_034eh - push hl - push de - push bc call cp_hl_de jr nc,cmdm_up add hl,bc @@ -2195,11 +2129,6 @@ l0e1fh: db 01h ;swallow ldir instruction (ld bc,...) cmdm_up: ldir - pop bc - pop de - pop hl - pop af - jr z,l0dedh ret ;------------------------------------------------------------------------------- @@ -2232,32 +2161,31 @@ cmd_H: ; Query memory for a byte string [Justified] cmd_Q: - call get_char_upper - sub 'J' - ld (cmd_Q_jopt),a - jr nz,l0e8dh - inc de -l0e8dh: call get_arg_range push bc push hl call sub_0ee6h pop hl l0e96h: - call sub_0ed7h + push hl + push de + push bc +l0edah: + ld a,(de) + cp (hl) + jr nz,l0ee2h + inc de + inc hl + djnz l0edah +l0ee2h: + pop bc + pop de + pop hl jr nz,l0eb0h push bc - push hl - ld a,(cmd_Q_jopt) - or a - jr nz,l0ea7h - ld bc,-8 - add hl,bc -l0ea7h: ld bc,16 - and a + and a ;clear carry call sub_0f58h - pop hl pop bc l0eb0h: inc hl @@ -2296,23 +2224,6 @@ l0ed3h: pop hl ret -sub_0ed7h: - push hl - push de - push bc -l0edah: - ld a,(de) - cp (hl) - jr nz,l0ee2h - inc de - inc hl - djnz l0edah -l0ee2h: - pop bc - pop de - pop hl - ret - sub_0ee6h: ld hl,conbuf+1 call sub_0ef7h @@ -2323,26 +2234,13 @@ sub_0ee6h: ret nz jp ERROR -sub_0ef7h: - db 0e6h ; and 037h (clear carry) -sub_0ef8h: +sub_0ef7h: ;from cmd_Q, cmd_Z + db 0e6h ;and 037h (clear carry) +sub_0ef8h: ;from cmd_S scf l0ef9h: push af call next_arg - cp 'W' - jr nz,l0f0eh - inc de - push hl - call sub_035dh - ex de,hl - ex (sp),hl - ld (hl),e - inc hl - ld a,d - pop de - jr l0f1ah -l0f0eh: cp '''' jr z,l0f1eh push hl @@ -2404,8 +2302,7 @@ sub_0f58h: push af l0f5ch: call out_hl - call z,outbl2 - call outbl + call outbl2 ld de,0 l0f68h: ld a,(hl) @@ -2462,238 +2359,62 @@ l0fach: ; > Fcommandline ; specifiy filenames and command line -cmd_F: - push de - ld hl,DMA_BUF+1 - ld (hl),' ' - inc hl -l0fb6h: - call get_char_upper - ld (hl),a - inc hl - inc de - and a - jr nz,l0fb6h - ld a,l - sub DMA_BUF+2 - ld (DMA_BUF),a - pop hl - ld de,dfcb1 - call parse_filename - ld de,dfcb2 - ;fall thru - -parse_filename: - call sub_102ch - push de - push bc - ld b,(hl) - inc hl - ld a,(hl) - cp ':' - jr nz,l0fe1h - inc hl - ld a,b - sub 040h - and 01fh - jr l0fe3h -l0fe1h: - dec hl - xor a -l0fe3h: - ld (de),a - inc de - ld b,8 - call sub_0ff2h - ld b,3 - call sub_0ff2h - pop bc - pop de - ret - -sub_0ff2h: - call sub_1012h - jr z,l0ffeh - inc hl - ld (de),a - inc de - djnz sub_0ff2h - jr l1003h -l0ffeh: - ld a,c -l0fffh: - ld (de),a - inc de - djnz l0fffh -l1003h: - call sub_1012h - inc hl - jr nz,l1003h - cp '*' - jr z,l1003h - cp '.' - ret z - dec hl - ret - -sub_1012h: - ld a,(hl) - ld c,' ' - and 01fh - ret z - ld a,(hl) - cp ' ' - ret z - call sub_1043h - ret z - cp '/' - ret z - cp '.' - ret z - ld c,'?' - call toupper - cp '*' - ret - -l102bh: - inc hl -sub_102ch: - ld a,(hl) - cp '/' - jr z,l103bh - call sub_1043h - jr z,l102bh -l1036h: - cp ' ' - jr z,l102bh - ret - -l103bh: - ld a,(hl) - cp ' '+1 - jr c,l1036h - inc hl - jr l103bh - -sub_1043h: - cp '=' - ret z - cp '_' - ret z - cp ',' - ret - -;------------------------------------------------------------------------------- - -setup_fcb: - push de - ld hl,12 - add hl,de - xor a - ld b,21 -l1052h: - ld (hl),a - inc hl - djnz l1052h - ld de,DMA_BUF - ld c,BDOS_SETDMA - call ddtz_bdos - pop de - ret +;cmd_F: ;------------------------------------------------------------------------------- +; > R [displacement] +; Read Intel Hex File from console [add displacement] -file_open: - ld (cur_fcb),de - call setup_fcb - ld c,BDOS_OPEN - call ddtz_bdos - inc a - jp z,ERROR - ld a,080h - ld (cmdR_rindex),a - ret - -read_byte: - ld a,(cmdR_rindex) - cp 080h - jr nz,l1111h - call read_sector - ld a,01ah - ret z - sub a -l1111h: - inc a - ld (cmdR_rindex),a +cmd_R: + ld hl,0 + call get_lastarg_def ;get offset from command line push hl - add a,07fh + ld hl,0 + ld (high_load),hl +w_recstart: + call i.getchar + jr z,rdhex_done + cp ':' + jr nz,w_recstart + ld c,0 ;init checksum + call i.gethexbyte ;record len + ld b,a + call i.gethexbyte ;address high + ld h,a + call i.gethexbyte ;address low ld l,a - ld h,000h - ld a,(hl) - pop hl - cp 01ah - ret - -read_sector: - push hl + call i.gethexbyte ;record type (ignored) + ld a,b + and a ;record len == 0? + jr z,rdhex_done +l16c6h: + call i.gethexbyte + pop de ;offset push de - push bc - ld de,(cur_fcb) - ld c,BDOS_READ - call ddtz_bdos - sub a,1 - jr z,l1132h - jr nc,error2 -l1132h: - pop bc - pop de + push hl + add hl,de + call i.storebyte pop hl - ret - -cmdR_storebyte: - push af - push de - ld de,TPA - call cp_hl_de - jr c,error2 - ld de,(BDOS+1) - call cp_hl_de - jr nc,error2 - ld de,(high_load) - call cp_hl_de - jr c,l1157h - ld (high_load),hl -l1157h: - ld de,(max_load) - call cp_hl_de - jr c,l1163h - ld (max_load),hl -l1163h: - pop de - pop af - ld (hl),a - ret - -strncmp: - ld a,(de) - cp (hl) - inc de inc hl - ret nz - djnz strncmp - ret - -str_hex: - db 'HEX' + djnz l16c6h ;repeat for record len + call i.gethexbyte ;checksum + ld a,c + and a + jp nz,ERROR ;exit if checksum error + jr w_recstart ;next record +rdhex_done: + pop hl + call i.gethexbyte + jp p_max_high -read_hexchar: - call read_hexdigit +i.gethexbyte: + call sub_16f6h rlca rlca rlca rlca ld d,a - call read_hexdigit + call sub_16f6h add a,d ld d,a add a,c @@ -2701,95 +2422,41 @@ read_hexchar: ld a,d ret -read_hexdigit: - call read_byte +sub_16f6h: + call i.getchar jr z,error2 -hex_digit_v: call hex_digit ret nc error2: jp ERROR -;------------------------------------------------------------------------------- -; > R [displacement] -; Read a binary or hex file [add displacement] +i.getchar: + call incharw + cp 01ah + ret -cmd_R: - ld hl,0 - call get_lastarg_def -read_file: - ld de,dfcb1 - push hl - ld hl,0 +i.storebyte: + push af + push de + ld de,TPA ;lowest allowed load address + call cp_hl_de + jr c,error2 + ld de,(BDOS+1) ;highest allowed load address + call cp_hl_de + jr nc,error2 + ld de,(high_load) + call cp_hl_de + jr c,l1157h ld (high_load),hl - call file_open - ld hl,dfcb1+9 - ld de,str_hex - ld b,3 - call strncmp - pop hl - jr z,read_hexfile - ld de,TPA - push hl - add hl,de -l108eh: - call read_sector - jr nz,read_file_nxt - pop hl - jp p_max_high - -read_file_nxt: - ld de,DMA_BUF - ld b,080h -l109ah: - ld a,(de) - call cmdR_storebyte - inc de - inc hl - djnz l109ah - jr l108eh - -read_hexfile: - push hl -l10aeh: - call read_byte ; RECORD MARK - jr z,rdhex_done - cp ':' - jr nz,l10aeh - ld c,0 - call read_hexchar ; RECLEN - ld b,a - call read_hexchar ; LOAD ADDR H - ld h,a - call read_hexchar ; LOAD ADDR L - ld l,a - ld a,b - and a - jr z,rdhex_done - call read_hexchar ; RECTYP -l10cch: - call read_hexchar ; DATA +l1157h: + ld de,(max_load) + call cp_hl_de + jr c,l1163h + ld (max_load),hl +l1163h: pop de - push de - push hl - add hl,de - call cmdR_storebyte - pop hl - inc hl - djnz l10cch - call read_hexchar ; CHKSUM - ld a,c - and a - jp nz,ERROR - jr l10aeh -rdhex_done: - pop hl - jp p_max_high - -test_whitespace: - cp ' ' - ret z - cp TAB + pop af + ld (hl),a ;store byte ret ;------------------------------------------------------------------------------- @@ -2815,66 +2482,7 @@ p_max_high: ; > Wstartaddr endaddr ; Write a file to disk -cmd_W: - call get_arg_range - call assert_eol - push hl - ld a,c - add a,07fh - jr nc,l11adh - inc b -l11adh: - and 080h - ld c,a - push bc - ld a,(dfcb1+1) - cp ' ' - jr z,error4 - ld de,dfcb1 - call setup_fcb - push de - ld c,BDOS_DELETE - call ddtz_bdos - pop de - ld c,BDOS_CREATE - call ddtz_bdos - inc a - jr z,error4 - pop bc - pop hl -l11cch: - ld a,b - or c - jr z,close_file - push bc - ld de,080h ; DMA_BUF - ld b,d - ld c,e - ldir - call write_sector - ex (sp),hl - ld bc,0ff80h - add hl,bc - ex (sp),hl - pop bc - jr l11cch - -write_sector: - push hl - ld de,dfcb1 - ld c,BDOS_WRITE - call ddtz_bdos - pop hl - and a - ret z - call close_file -error4: - jp ERROR - -close_file: - ld de,dfcb1 - ld c,BDOS_CLOSE - jp ddtz_bdos +;cmd_W: ;------------------------------------------------------------------------------- ; > A [startaddr] @@ -3956,7 +3564,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 @@ -4087,7 +3695,7 @@ l20d7h: l20dch: l20edh: - ld hl,(reg_sp) + ld hl,(reg_sp) ;break on return address ld e,(hl) inc hl ld d,(hl) @@ -4271,15 +3879,9 @@ last_O_addr: last_O_val: db 0 -cmd_Q_jopt: - db -1 - last_D: dw TPA -cmdR_rindex: - db 0 - high_load: dw TPA max_load: @@ -4297,9 +3899,6 @@ disas_argtype: pbl_loop_adr: dw 0 -cur_fcb: - dw 0 - ddtz_size equ $-ddtz_base ddtz_end: