mirror of
https://github.com/hsoft/collapseos.git
synced 2024-12-25 15:58:05 +11:00
apps/ed: add support for addr ranges
This commit is contained in:
parent
2d9f74c2af
commit
c811d5330c
@ -26,9 +26,41 @@ cmdParse:
|
|||||||
ld a, (hl)
|
ld a, (hl)
|
||||||
cp 'q'
|
cp 'q'
|
||||||
jr z, .quit
|
jr z, .quit
|
||||||
ld (CMD_TYPE), a
|
|
||||||
ld ix, CMD_ADDR1
|
ld ix, CMD_ADDR1
|
||||||
jp .readAddr
|
call .readAddr
|
||||||
|
ret nz
|
||||||
|
; Before we check for the existence of a second addr, let's set that
|
||||||
|
; second addr to the same value as the first. That's going to be its
|
||||||
|
; value if we have to ",".
|
||||||
|
ld a, (ix)
|
||||||
|
ld (CMD_ADDR2), a
|
||||||
|
ld a, (ix+1)
|
||||||
|
ld (CMD_ADDR2+1), a
|
||||||
|
ld a, (ix+2)
|
||||||
|
ld (CMD_ADDR2+2), a
|
||||||
|
ld a, (hl)
|
||||||
|
cp ','
|
||||||
|
jr nz, .noaddr2
|
||||||
|
inc hl
|
||||||
|
ld ix, CMD_ADDR2
|
||||||
|
call .readAddr
|
||||||
|
ret nz
|
||||||
|
.noaddr2:
|
||||||
|
; We expect HL (rest of the cmdline) to be a null char or an accepted
|
||||||
|
; cmd, otherwise it's garbage
|
||||||
|
ld a, (hl)
|
||||||
|
or a
|
||||||
|
jr z, .nullCmd
|
||||||
|
cp 'p'
|
||||||
|
jr z, .okCmd
|
||||||
|
; unsupported cmd
|
||||||
|
ret ; Z unset
|
||||||
|
.nullCmd:
|
||||||
|
ld a, 'p'
|
||||||
|
.okCmd:
|
||||||
|
ld (CMD_TYPE), a
|
||||||
|
ret ; Z already set
|
||||||
|
|
||||||
.quit:
|
.quit:
|
||||||
; Z already set
|
; Z already set
|
||||||
ld (CMD_TYPE), a
|
ld (CMD_TYPE), a
|
||||||
@ -84,14 +116,10 @@ cmdParse:
|
|||||||
ex de, hl
|
ex de, hl
|
||||||
pop hl
|
pop hl
|
||||||
.end:
|
.end:
|
||||||
; We expect HL (rest of the cmdline) to be a null char, otherwise it's
|
|
||||||
; garbage
|
|
||||||
ld a, (hl)
|
|
||||||
or a
|
|
||||||
ret nz
|
|
||||||
; we still have to save DE in memory
|
; we still have to save DE in memory
|
||||||
ld (ix+1), e
|
ld (ix+1), e
|
||||||
ld (ix+2), d
|
ld (ix+2), d
|
||||||
|
cp a ; ensure Z
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; call parseDecimal and set HL to the character following the last digit
|
; call parseDecimal and set HL to the character following the last digit
|
||||||
@ -106,7 +134,8 @@ cmdParse:
|
|||||||
jr nc, .loop
|
jr nc, .loop
|
||||||
; We're at the first non-digit char. Let's save it because we're going
|
; We're at the first non-digit char. Let's save it because we're going
|
||||||
; to temporarily replace it with a null.
|
; to temporarily replace it with a null.
|
||||||
ld b, a
|
ld b, (hl) ; refetch (HL), A has been mucked with in
|
||||||
|
; parseDecimalDigit
|
||||||
xor a
|
xor a
|
||||||
ld (hl), a
|
ld (hl), a
|
||||||
; Now, let's go back to the beginning of the string and parse it.
|
; Now, let's go back to the beginning of the string and parse it.
|
||||||
@ -129,6 +158,11 @@ cmdAddr1:
|
|||||||
ld ix, CMD_ADDR1
|
ld ix, CMD_ADDR1
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
; Make (IX) point to addr 2
|
||||||
|
cmdAddr2:
|
||||||
|
ld ix, CMD_ADDR2
|
||||||
|
ret
|
||||||
|
|
||||||
; Set A to CMD_TYPE
|
; Set A to CMD_TYPE
|
||||||
cmdType:
|
cmdType:
|
||||||
ld a, (CMD_TYPE)
|
ld a, (CMD_TYPE)
|
||||||
|
@ -96,12 +96,25 @@ edMain:
|
|||||||
.doPrint:
|
.doPrint:
|
||||||
call cmdAddr1
|
call cmdAddr1
|
||||||
call edResolveAddr
|
call edResolveAddr
|
||||||
|
ex de, hl ; DE: addr1
|
||||||
|
call cmdAddr2
|
||||||
|
call edResolveAddr
|
||||||
ld (ED_CURLINE), hl
|
ld (ED_CURLINE), hl
|
||||||
|
ex de, hl ; HL: addr1, DE: addr2
|
||||||
|
call cpHLDE
|
||||||
|
jr z, .doPrintLoop ; DE == HL, ok
|
||||||
|
jr nc, .error ; DE < HL, not good
|
||||||
|
.doPrintLoop:
|
||||||
|
push hl
|
||||||
call bufGetLine
|
call bufGetLine
|
||||||
jr nz, .error
|
jr nz, .error
|
||||||
call printstr
|
call printstr
|
||||||
call printcrlf
|
call printcrlf
|
||||||
jr .mainLoop
|
pop hl
|
||||||
|
call cpHLDE
|
||||||
|
jr nc, .mainLoop
|
||||||
|
inc hl
|
||||||
|
jr .doPrintLoop
|
||||||
.error:
|
.error:
|
||||||
ld a, '?'
|
ld a, '?'
|
||||||
call stdioPutC
|
call stdioPutC
|
||||||
@ -116,13 +129,14 @@ edResolveAddr:
|
|||||||
jr z, .relative
|
jr z, .relative
|
||||||
; absolute
|
; absolute
|
||||||
ld l, (ix+1)
|
ld l, (ix+1)
|
||||||
ld a, l
|
|
||||||
ld h, (ix+2)
|
ld h, (ix+2)
|
||||||
ret
|
ret
|
||||||
.relative:
|
.relative:
|
||||||
ld hl, (ED_CURLINE)
|
ld hl, (ED_CURLINE)
|
||||||
|
push de
|
||||||
ld e, (ix+1)
|
ld e, (ix+1)
|
||||||
ld d, (ix+2)
|
ld d, (ix+2)
|
||||||
add hl, de
|
add hl, de
|
||||||
|
pop de
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user