5. Big-Endian Memory Dump

__ BIG-ENDIAN-TEXT VERSION
__ FD ( addr -- nxtaddr ) Print 256 bytes of memory in hex, as 16 rows of 4
__                        32-bit values 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

   __  fg ( c -- ) if c is printable, print it, otherwise print "."
   `g
     dup 0x20 < over 0x7E > | if drop "." else , endif
   `

   __  ff ( addr -- ) print ascii equiv. of the word, in left-to-right order
   `f __ shift off each byte of the word and print its ascii equivalent
     dup @ 24>> 0xFF& mfg
     dup @ 16>> 0xFF& mfg
     dup @ 8>>  0xFF& mfg
     @ 0xFF& mfg
   `

   __  fe ( addr -- ) print the ascii equivalent of the 4 words
   `e
     "  "              __ output two blanks
     15 over + swap    __ convert addr to end-addr start-addr
     loop 2dup swap <= while   __ while start-addr <= end-addr
       dup mff         __ display the ascii equivalent of a word
       4+              __ advance to next word
     endloop 2drop     __ remove start-addr end-addr from stack
   `

   __   fd ( addr -- ) dump the 4 words in hex
   `d
     dup                __ preserve a copy of addr for fe to use later on
     dup " #w:"         __ print the row address
     15 over + swap     __ convert addr to end-addr start-addr
     loop 2dup swap <= while  __ while start-addr <= end-addr
       dup @ " #W"      __ display a word
       4+               __ advance to next word
     endloop 2drop mfe  __ remove start-addr & end-addr, display ascii equiv.
     "\n"               __ print newline
   `

  3~&                    __ force addr to be word aligned
  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
  drop 1+                __ remove start-addr, adjust end-addr to next byte
}
#EXECUTE
#define dump=FD