1
0
mirror of https://github.com/hsoft/collapseos.git synced 2025-04-05 06:38:40 +11:00

introduce command to print the memory pointer

This commit is contained in:
Valentin Lenhart 2019-10-10 13:05:53 +02:00
parent 23be234762
commit cf0d7eb6e9
2 changed files with 22 additions and 13 deletions

View File

@ -79,7 +79,8 @@ parseHexPair:
; you still need to have a specifier for the second part of ; you still need to have a specifier for the second part of
; the multibyte. ; the multibyte.
; Bit 2 - optional: If set and not present during parsing, we don't error out ; Bit 2 - optional: If set and not present during parsing, we don't error out
; and write zero ; and write zero. Unfortunately there is currently no way to distinguish
; a value that a not present and a value that is zero.
; ;
; Bit 3 - String argument: If set, this argument is a string. A pointer to the ; Bit 3 - String argument: If set, this argument is a string. A pointer to the
; read string, null terminated (max 0x20 chars) will ; read string, null terminated (max 0x20 chars) will

View File

@ -33,7 +33,8 @@
; *** CONSTS *** ; *** CONSTS ***
; number of entries in shellCmdTbl ; number of entries in shellCmdTbl
.equ SHELL_CMD_COUNT 6+SHELL_EXTRA_CMD_COUNT .equ SHELL_INTERNAL_CMD_COUNT 7
.equ SHELL_CMD_COUNT SHELL_INTERNAL_CMD_COUNT+SHELL_EXTRA_CMD_COUNT
; *** VARIABLES *** ; *** VARIABLES ***
; Memory address that the shell is currently "pointing at" for peek, load, call ; Memory address that the shell is currently "pointing at" for peek, load, call
@ -220,19 +221,13 @@ shellPrintErr:
; directive *just* after your '.inc "shell.asm"'. Voila! ; directive *just* after your '.inc "shell.asm"'. Voila!
; ;
; Set memory pointer to the specified address (word) ors print the current value. ; Set memory pointer to the specified address (word).
; Example: mptr 01fe ; Example: mptr 01fe
shellMptrCmd: shellMptrCmd:
.db "mptr", 0b111, 0b001, 0 .db "mptr", 0b011, 0b001, 0
shellMptr: shellMptr:
push hl push hl
ld a, (hl)
inc hl
and (hl)
dec hl
jr z, .print
; reminder: z80 is little-endian ; reminder: z80 is little-endian
ld a, (hl) ld a, (hl)
ld (SHELL_MEM_PTR+1), a ld (SHELL_MEM_PTR+1), a
@ -240,7 +235,20 @@ shellMptr:
ld a, (hl) ld a, (hl)
ld (SHELL_MEM_PTR), a ld (SHELL_MEM_PTR), a
.print: call shellMptrPrint
pop hl
xor a
ret
; Print the current value of the memory pointer.
; Example: pptr
shellMptrPrintCmd:
.db "pptr", 0, 0, 0
shellMptrPrint:
push hl
ld hl, (SHELL_MEM_PTR) ld hl, (SHELL_MEM_PTR)
ld a, h ld a, h
call printHex call printHex
@ -362,6 +370,6 @@ shellIOWRCmd:
; This table is at the very end of the file on purpose. The idea is to be able ; This table is at the very end of the file on purpose. The idea is to be able
; to graft extra commands easily after an include in the glue file. ; to graft extra commands easily after an include in the glue file.
shellCmdTbl: shellCmdTbl:
.dw shellMptrCmd, shellPeekCmd, shellPokeCmd, shellCallCmd .dw shellMptrCmd, shellMptrPrintCmd, shellPeekCmd, shellPokeCmd
.dw shellIORDCmd, shellIOWRCmd .dw shellCallCmd, shellIORDCmd, shellIOWRCmd