Browse Source

Add "DUMP" word

pull/102/head
Virgil Dupras 4 years ago
parent
commit
7b34268a9a
2 changed files with 34 additions and 0 deletions
  1. +3
    -0
      forth/dictionary.txt
  2. +31
    -0
      forth/fmt.fs

+ 3
- 0
forth/dictionary.txt View File

@@ -199,6 +199,9 @@ core.
." xxx" -- *I* Compiles string literal xxx followed by a call
to (print)
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
IN> -- a Address of variable containing current pos in input
buffer.


+ 31
- 0
forth/fmt.fs View File

@@ -42,3 +42,34 @@
256 /MOD ( l h )
.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…
Cancel
Save