summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeo C2018-12-07 22:04:14 +0100
committerLeo C2018-12-07 22:09:08 +0100
commit25e453a7775c64b58487179ef909839d030d179f (patch)
tree24b45682616e27c56d68279bd8a30aaae3becee9
parent12eea40b2a19262bffbb570149ef9a6c68c3d8b5 (diff)
downloadddt180-25e453a7775c64b58487179ef909839d030d179f.zip
Remove BDOS file i/o (cmd_F, cmd_W). Read Hex files from console (cmd_R).
-rw-r--r--ddt180.z80443
1 files changed, 71 insertions, 372 deletions
diff --git a/ddt180.z80 b/ddt180.z80
index 3ab5b88..1d8f4ae 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
@@ -156,10 +146,6 @@ l0093h:
ld hl,ddtz_base
ld l,000h
ld (reg_sp),hl
- ld a,(dfcb1+1)
- cp ' '
- ld hl,0
- call nz,read_file
jr mainloop
ds CONBUF_SIZE + 3 - ($ - conbuf)
@@ -178,7 +164,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 +181,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
@@ -2462,201 +2448,89 @@ 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
+;cmd_F:
;-------------------------------------------------------------------------------
+; > R [displacement]
+; Read Intel Hex File from console [add displacement]
-setup_fcb:
+cmd_R:
+ ld hl,0
+ call get_lastarg_def ;get offset from command line
+ push hl
+ 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
+ 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
- ld hl,12
+ push hl
add hl,de
- xor a
- ld b,21
-l1052h:
- ld (hl),a
+ call i.storebyte
+ pop hl
inc hl
- djnz l1052h
- ld de,DMA_BUF
- ld c,BDOS_SETDMA
- call ddtz_bdos
- pop de
- ret
-
-;-------------------------------------------------------------------------------
+ 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
-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
+i.gethexbyte:
+ call sub_16f6h
+ rlca
+ rlca
+ rlca
+ rlca
+ ld d,a
+ call sub_16f6h
+ add a,d
+ ld d,a
+ add a,c
+ ld c,a
+ ld a,d
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
- push hl
- add a,07fh
- ld l,a
- ld h,000h
- ld a,(hl)
- pop hl
- cp 01ah
- ret
+sub_16f6h:
+ call i.getchar
+ jr z,error2
+ call hex_digit
+ ret nc
+error2:
+ jp ERROR
-read_sector:
- push hl
- 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
- pop hl
+i.getchar:
+ call $ci
+ cp 01ah
ret
-cmdR_storebyte:
+i.storebyte:
push af
push de
- ld de,TPA
+ ld de,TPA ;lowest allowed load address
call cp_hl_de
jr c,error2
- ld de,(BDOS+1)
+ ld de,(BDOS+1) ;highest allowed load address
call cp_hl_de
jr nc,error2
ld de,(high_load)
@@ -2671,120 +2545,10 @@ l1157h:
l1163h:
pop de
pop af
- ld (hl),a
+ ld (hl),a ;store byte
ret
-strncmp:
- ld a,(de)
- cp (hl)
- inc de
- inc hl
- ret nz
- djnz strncmp
- ret
-
-str_hex:
- db 'HEX'
-
-read_hexchar:
- call read_hexdigit
- rlca
- rlca
- rlca
- rlca
- ld d,a
- call read_hexdigit
- add a,d
- ld d,a
- add a,c
- ld c,a
- ld a,d
- ret
-
-read_hexdigit:
- call read_byte
- jr z,error2
-hex_digit_v:
- call hex_digit
- ret nc
-error2:
- jp ERROR
-
;-------------------------------------------------------------------------------
-; > R [displacement]
-; Read a binary or hex file [add displacement]
-
-cmd_R:
- ld hl,0
- call get_lastarg_def
-read_file:
- ld de,dfcb1
- push hl
- ld hl,0
- 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
- 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 ' '
@@ -2815,66 +2579,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]
@@ -4277,9 +3982,6 @@ cmd_Q_jopt:
last_D:
dw TPA
-cmdR_rindex:
- db 0
-
high_load:
dw TPA
max_load:
@@ -4297,9 +3999,6 @@ disas_argtype:
pbl_loop_adr:
dw 0
-cur_fcb:
- dw 0
-
ddtz_size equ $-ddtz_base
ddtz_end: