7. Example 17
# EXAMPLE 17: using the new print iterator
# This example expects a memory address on top of the stack and prints 256
# bytes of memory in hex, as 16 rows of eight 16-bit values.
__ FD ( addr -- ) print 256 bytes of memory in hex,
__ as 16 rows of 8 16-bit vals
__ usage example: 0x400 FD
#BUFFER
{D
1~& __ force address to be halfword-aligned
255 over + swap __ convert addr to end-addr start-addr
loop 2dup swap <= while __ while start-addr is <= end-addr
dup __ copy the row start-addr
"!A @a: @h @h @h @h @h @h @h @h\n" __ print a row
16+ __ advance to next row start
endloop
2drop __ drop start-addr end-addr from stack
}
#EXECUTE