目的是在字典中创建一个 Forth 单词,然后打印出该单词的记忆内容。第一步很容易。这个: main
词的创建方式如教程中所述。创建单词后,字典指针移动到下一个位置,所以我必须从中减去一些项目,现在可以转储创建单词的内存区域:
\ create a dummy routine
: main 1 dup + . ;
\ put dictionary pointer to the stack
\ and subtract 50 indizies
dp 50 -
\ print out 20 cells to the screen from dp-50 until dp+50
\ but where is my newly created routine ": main"?
100 dump
bye
------
gforth "a.fs"
7F81DF443FC6: 00 00 20 17 12 AF 60 55 - 00 00 04 00 00 00 00 00 .. ...`U........
7F81DF443FD6: 00 00 A0 58 14 AF 60 55 - 00 00 10 00 00 00 00 00 ...X..`U........
7F81DF443FE6: 00 00 FF FF FF FF FF FF - FF FF 00 00 00 00 00 00 ................
7F81DF443FF6: 00 00 50 82 49 DF 81 7F - 00 00 F8 3F 44 DF 81 7F ..P.I......?D...
7F81DF444006: 00 00 08 82 49 DF 81 7F - 00 00 F0 81 49 DF 81 7F ....I.......I...
7F81DF444016: 00 00 32 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ..2.............
7F81DF444026: 00 00 00 00
不幸的是,dump 命令显示的内存区域没有以开头的部分,: main
并且单词1 dup ...
中的语句也丢失了。那么这个新创造的词到底在哪里呢?如何查看内存中的原始字节?