4. Byte-by-Byte Memory Dump
__ BYTE-BY-BYTE VERSION, using the new print iterator.
__ FD ( addr -- nxtaddr ) Print 256 bytes of memory in hex, as 16 rows of 16
__ bytes with ASCII equivalents. The value left on the
__ stack, nxtaddr, is the address of the next location
__ following the last dumped location. This helps with
__ repeated FD commands.
__ usage example: 8K FD FD .
#BUFFER
{D
__ fe ( addr -- ) print the ascii equivalent of the 16 bytes
`e
" !A" __ output two blanks and set iterator start
15 0 loop 2dup swap <= while
"@C" __ display the ascii equivalent of the byte
1+ __ count it
endloop 2drop __ remove loop indices
`
__ fd ( addr -- ) dump the 16 bytes in hex
`d
dup __ preserve a copy of addr for mfe to use later on
"!A @A:" __ set iterator start and print the row address
15 0 loop 2dup swap <= while
" @B" __ display a non-notated hex byte
1+ __ count it
endloop 2drop mfe __ remove loop indices, display ascii equiv.
"\n" __ print newline
`
255 over + swap __ convert addr to end-addr start-addr
loop 2dup swap <= while __ while start-addr <= end-addr
dup mfd 16+ __ display a row and advance start-addr to next row
endloop
2drop 38K __ remove loop indices, leave next address on stack
}
#EXECUTE
#define dump=FD