Add "DUMP" word
This commit is contained in:
parent
7df7416e9e
commit
7b34268a9a
@ -199,6 +199,9 @@ core.
|
|||||||
." xxx" -- *I* Compiles string literal xxx followed by a call
|
." xxx" -- *I* Compiles string literal xxx followed by a call
|
||||||
to (print)
|
to (print)
|
||||||
C< -- c Read one char from buffered input.
|
C< -- c Read one char from buffered input.
|
||||||
|
DUMP n a -- Prints n bytes at addr a in a hexdump format.
|
||||||
|
Prints in chunks of 8 bytes. Doesn't do partial
|
||||||
|
lines. Output is designed to fit in 32 columns.
|
||||||
EMIT c -- Spit char c to output stream
|
EMIT c -- Spit char c to output stream
|
||||||
IN> -- a Address of variable containing current pos in input
|
IN> -- a Address of variable containing current pos in input
|
||||||
buffer.
|
buffer.
|
||||||
|
31
forth/fmt.fs
31
forth/fmt.fs
@ -42,3 +42,34 @@
|
|||||||
256 /MOD ( l h )
|
256 /MOD ( l h )
|
||||||
.x .x
|
.x .x
|
||||||
;
|
;
|
||||||
|
|
||||||
|
( a -- a+8 )
|
||||||
|
: _
|
||||||
|
DUP ( save for 2nd loop )
|
||||||
|
':' EMIT DUP .x SPC
|
||||||
|
4 0 DO
|
||||||
|
DUP @
|
||||||
|
256 /MOD SWAP
|
||||||
|
.x .x
|
||||||
|
SPC
|
||||||
|
2 +
|
||||||
|
LOOP
|
||||||
|
DROP
|
||||||
|
8 0 DO
|
||||||
|
DUP C@
|
||||||
|
DUP 0x20 < IF DROP '.' THEN
|
||||||
|
DUP 0x7e > IF DROP '.' THEN
|
||||||
|
EMIT
|
||||||
|
1 +
|
||||||
|
LOOP
|
||||||
|
LF
|
||||||
|
;
|
||||||
|
( n a -- )
|
||||||
|
: DUMP
|
||||||
|
LF
|
||||||
|
BEGIN
|
||||||
|
OVER 1 < IF DROP EXIT THEN
|
||||||
|
_
|
||||||
|
SWAP 8 - SWAP
|
||||||
|
AGAIN
|
||||||
|
;
|
||||||
|
Loading…
Reference in New Issue
Block a user