Next: 386 Assembler, Previous: Common Assembler, Up: Assembler and Code Words
You can disassemble a code
word with see
(see Debugging). You can disassemble a section of memory with
discode
addr u – gforth “discode”
hook for the disassembler: disassemble code at addr of length u
There are two kinds of disassembler for Gforth: The Forth disassembler (available on some CPUs) and the gdb disassembler (available on platforms with gdb and mktemp). If both are available, the Forth disassembler is used by default. If you prefer the gdb disassembler, say
' disasm-gdb is discode
If neither is available, discode
performs dump
.
The Forth disassembler generally produces output that can be fed into the assembler (i.e., same syntax, etc.). It also includes additional information in comments. In particular, the address of the instruction is given in a comment before the instruction.
The gdb disassembler produces output in the same format as the gdb
disassemble
command (see Source and machine code), in the default flavour (AT&T syntax for
the 386 and AMD64 architectures).
See
may display more or less than the actual code of the word,
because the recognition of the end of the code is unreliable. You can
use discode
if it did not display enough. It may display more, if
the code word is not immediately followed by a named word. If you have
something else there, you can follow the word with align latest ,
to ensure that the end is recognized.