User Tools

Site Tools


how_20to_20display_20a_20hex_20dump_20of_20memory_20contents

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

how_20to_20display_20a_20hex_20dump_20of_20memory_20contents [2018/03/31 13:19]
127.0.0.1 external edit
how_20to_20display_20a_20hex_20dump_20of_20memory_20contents [2018/04/17 16:37] (current)
tbest3112 Added syntax highlighting
Line 2: Line 2:
  
 //by Jon Ripley, May 2011//\\ \\  It is useful sometimes to be able to list the contents of a block of memory to examine it. This may be to help debug a problem, examine binary data in memory or one of many other uses.\\ \\  The easiest way to achieve that is probably to use the supplied **Memory Monitor** [[/​Tools%20and%20Utilities|add-in utility]], which optionally displays the contents of a block of memory in hexadecimal and ANSI (commonly known as a //hex dump//).\\ \\  However if you want to achieve a similar effect in your own program you can use **PROCm_Dump** below; it accepts four parameters:​\\ ​ //by Jon Ripley, May 2011//\\ \\  It is useful sometimes to be able to list the contents of a block of memory to examine it. This may be to help debug a problem, examine binary data in memory or one of many other uses.\\ \\  The easiest way to achieve that is probably to use the supplied **Memory Monitor** [[/​Tools%20and%20Utilities|add-in utility]], which optionally displays the contents of a block of memory in hexadecimal and ANSI (commonly known as a //hex dump//).\\ \\  However if you want to achieve a similar effect in your own program you can use **PROCm_Dump** below; it accepts four parameters:​\\ ​
 +<code bb4w>
         PROCm_dump(block%,​ size%, items%, verbose%)         PROCm_dump(block%,​ size%, items%, verbose%)
 +</​code>​
 Here //block%// should point to the memory to list, //size%// is the size in bytes, //items%// is the number of bytes to display on each line -- typically 16 -- and verbose controls whether a header is printed.\\ \\  In the example below we reserve 16 bytes of memory, write a message into the memory and call **PROCm_dump** to display a hex dump of the memory:​\\ ​ Here //block%// should point to the memory to list, //size%// is the size in bytes, //items%// is the number of bytes to display on each line -- typically 16 -- and verbose controls whether a header is printed.\\ \\  In the example below we reserve 16 bytes of memory, write a message into the memory and call **PROCm_dump** to display a hex dump of the memory:​\\ ​
 +<code bb4w>
         DIM a 15         DIM a 15
         $$a="​Hello world!"​         $$a="​Hello world!"​
         PROCm_dump(a,​ 16, 8, TRUE)         PROCm_dump(a,​ 16, 8, TRUE)
 +</​code>​
 The ouput of the code is as follows:​\\ ​ The ouput of the code is as follows:​\\ ​
   Address ​ : 00 01 02 03 04 05 06 07 :   Address ​ : 00 01 02 03 04 05 06 07 :
Line 13: Line 17:
   04421AA9 : 72 6C 64 21 00 00 00 00 : rld!....   04421AA9 : 72 6C 64 21 00 00 00 00 : rld!....
 Here is the code for **PROCm_dump**:​\\ ​ Here is the code for **PROCm_dump**:​\\ ​
 +<code bb4w>
         DEF PROCm_dump(P%,​L%,​S%,​F%)         DEF PROCm_dump(P%,​L%,​S%,​F%)
         LOCAL I%,J%,K%         LOCAL I%,J%,K%
Line 45: Line 50:
         DEF FNh0(N%,L%)         DEF FNh0(N%,L%)
         =RIGHT$(STRING$(L%,"​0"​)+STR$~N%,​L%)         =RIGHT$(STRING$(L%,"​0"​)+STR$~N%,​L%)
 +</​code>​
how_20to_20display_20a_20hex_20dump_20of_20memory_20contents.txt ยท Last modified: 2018/04/17 16:37 by tbest3112