Browse Source

shell: make arg in peek/poke mandatory

Also, make `0` mean `0x100`.
pull/10/head
Virgil Dupras 5 years ago
parent
commit
bd2877e012
1 changed files with 6 additions and 18 deletions
  1. +6
    -18
      kernel/shell.asm

+ 6
- 18
kernel/shell.asm View File

@@ -295,22 +295,17 @@ shellMptr:
ret ret




; 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
; peek the number of bytes specified by argument where memory pointer points to
; and display their value. If 0 is specified, 0x100 bytes are peeked.
; ;
; Example: peek 2 (will print 2 bytes) ; Example: peek 2 (will print 2 bytes)
shellPeekCmd: shellPeekCmd:
.db "peek", 0b101, 0, 0
.db "peek", 0b001, 0, 0
shellPeek: shellPeek:
push bc push bc
push de
push hl push hl


ld a, (hl) ld a, (hl)
cp 0
jr nz, .arg1isset ; if arg1 is set, no need for a default
ld a, 1 ; default for arg1
.arg1isset:
ld b, a ld b, a
ld hl, (SHELL_MEM_PTR) ld hl, (SHELL_MEM_PTR)
.loop: ld a, (hl) .loop: ld a, (hl)
@@ -321,26 +316,19 @@ shellPeek:


.end: .end:
pop hl pop hl
pop de
pop bc pop bc
xor a xor a
ret ret


; poke byte where memory pointer points and set them to bytes types through
; stdioGetC. If the optional numerical byte arg is supplied, this number of
; bytes will be expected from stdioGetC. Blocks until all bytes have been
; fetched.
; poke specified number of bytes where memory pointer points and set them to
; bytes typed through stdioGetC. Blocks until all bytes have been fetched.
shellPokeCmd: shellPokeCmd:
.db "poke", 0b101, 0, 0
.db "poke", 0b001, 0, 0
shellPoke: shellPoke:
push bc push bc
push hl push hl


ld a, (hl) ld a, (hl)
or a ; cp 0
jr nz, .arg1isset ; if arg1 is set, no need for a default
ld a, 1 ; default for arg1
.arg1isset:
ld b, a ld b, a
ld hl, (SHELL_MEM_PTR) ld hl, (SHELL_MEM_PTR)
.loop: call stdioGetC .loop: call stdioGetC


Loading…
Cancel
Save