mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-27 12:08:07 +11:00
shell: add count arg to peek
Also, fix seek reversed endianness.
This commit is contained in:
parent
e4e7db8e23
commit
902c6a5dd3
@ -101,8 +101,8 @@ parseHexPair:
|
|||||||
ld b, a
|
ld b, a
|
||||||
inc hl
|
inc hl
|
||||||
ld a, (hl)
|
ld a, (hl)
|
||||||
;cp 0x21
|
cp 0x21
|
||||||
;jr c, .single ; special char? single digit
|
jr c, .single ; special char? single digit
|
||||||
call parseHex
|
call parseHex
|
||||||
jr c, .end ; error?
|
jr c, .end ; error?
|
||||||
or b ; join left-shifted + new. we're done!
|
or b ; join left-shifted + new. we're done!
|
||||||
|
@ -166,22 +166,25 @@ shellPrintErr:
|
|||||||
; When these commands are called, DE points to the first character of the
|
; When these commands are called, DE points to the first character of the
|
||||||
; command args.
|
; command args.
|
||||||
|
|
||||||
; Set memory pointer to the specified address.
|
; Set memory pointer to the specified address (word).
|
||||||
; Example: seek 01fe
|
; Example: seek 01fe
|
||||||
|
|
||||||
shellSeek:
|
shellSeek:
|
||||||
|
push af
|
||||||
push de
|
push de
|
||||||
push hl
|
push hl
|
||||||
|
|
||||||
ex de, hl
|
ex de, hl
|
||||||
call parseHexPair
|
call parseHexPair
|
||||||
jr c, .error
|
jr c, .error
|
||||||
ld (SHELL_MEM_PTR), a
|
; z80 is little endian. in a "ld hl, (nn)" op, L is loaded from the
|
||||||
|
; first byte, H is loaded from the second
|
||||||
|
ld (SHELL_MEM_PTR+1), a
|
||||||
inc hl
|
inc hl
|
||||||
inc hl
|
inc hl
|
||||||
call parseHexPair
|
call parseHexPair
|
||||||
jr c, .error
|
jr c, .error
|
||||||
ld (SHELL_MEM_PTR+1), a
|
ld (SHELL_MEM_PTR), a
|
||||||
jr .success
|
jr .success
|
||||||
|
|
||||||
.error:
|
.error:
|
||||||
@ -190,12 +193,12 @@ shellSeek:
|
|||||||
jr .end
|
jr .end
|
||||||
|
|
||||||
.success:
|
.success:
|
||||||
ld a, (SHELL_MEM_PTR)
|
ld a, (SHELL_MEM_PTR+1)
|
||||||
ld hl, SHELL_HEX_FMT
|
ld hl, SHELL_HEX_FMT
|
||||||
call fmtHexPair
|
call fmtHexPair
|
||||||
ld a, 2
|
ld a, 2
|
||||||
call printnstr
|
call printnstr
|
||||||
ld a, (SHELL_MEM_PTR+1)
|
ld a, (SHELL_MEM_PTR)
|
||||||
call fmtHexPair
|
call fmtHexPair
|
||||||
ld a, 2
|
ld a, 2
|
||||||
call printnstr
|
call printnstr
|
||||||
@ -204,23 +207,55 @@ shellSeek:
|
|||||||
.end:
|
.end:
|
||||||
pop hl
|
pop hl
|
||||||
pop de
|
pop de
|
||||||
|
pop af
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
; peek byte where memory pointer points to aby display its value
|
; peek byte where memory pointer points to any display its value. If the
|
||||||
|
; optional numerical byte arg is supplied, this number of bytes will be printed
|
||||||
|
;
|
||||||
|
; Example: peek 2 (will print 2 bytes)
|
||||||
shellPeek:
|
shellPeek:
|
||||||
push af
|
push af
|
||||||
|
push bc
|
||||||
|
push de
|
||||||
push hl
|
push hl
|
||||||
|
|
||||||
|
ld b, 1 ; by default, we run the loop once
|
||||||
|
ld a, (de)
|
||||||
|
cp 0
|
||||||
|
jr z, .success ; no arg? don't try to parse
|
||||||
|
|
||||||
|
ex de, hl
|
||||||
|
call parseHexPair
|
||||||
|
jr c, .error
|
||||||
|
cp 0
|
||||||
|
jr z, .error ; zero isn't a good arg, error
|
||||||
|
ld b, a ; loop the number of times specified in arg
|
||||||
|
jr .success
|
||||||
|
|
||||||
|
.error:
|
||||||
|
ld a, SHELL_ERR_BAD_ARGS
|
||||||
|
call shellPrintErr
|
||||||
|
jr .end
|
||||||
|
|
||||||
|
.success:
|
||||||
ld hl, (SHELL_MEM_PTR)
|
ld hl, (SHELL_MEM_PTR)
|
||||||
ld a, (hl)
|
.loop: ld a, (hl)
|
||||||
|
ex hl, de
|
||||||
ld hl, SHELL_HEX_FMT
|
ld hl, SHELL_HEX_FMT
|
||||||
call fmtHexPair
|
call fmtHexPair
|
||||||
ld a, 2
|
ld a, 2
|
||||||
call printnstr
|
call printnstr
|
||||||
|
ex hl, de
|
||||||
|
inc hl
|
||||||
|
djnz .loop
|
||||||
call printcrlf
|
call printcrlf
|
||||||
|
|
||||||
|
.end:
|
||||||
pop hl
|
pop hl
|
||||||
|
pop de
|
||||||
|
pop bc
|
||||||
pop af
|
pop af
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user