diff --git a/recipes/rc2014/selfhost/README.md b/recipes/rc2014/selfhost/README.md index 314124f..b8ee0db 100644 --- a/recipes/rc2014/selfhost/README.md +++ b/recipes/rc2014/selfhost/README.md @@ -77,3 +77,14 @@ You're looking at the offset of the last wordref of the *previous* LOAD operation. That offset is going in `XCURRENT`. Then, you're looking at the end of that word. That offset goes in `HERE`. Once you've done that, relaunch your LOAD. + +### Verifying + +You can use `/tools/memdump` to dump the memory between your start/stop offsets +so that you can compare against your reference stage 1. Before you do, you have +to take yourself out of xcomp mode. First, run `XCOFF` to go back to your +regular dict. Then, run `FORGET CODE` to undo the xcomp overrides you've added +before. That will rewind `HERE`. You don't want that. Put `HERE` back to after +your ending offset so that you don't overwrite your binary. + +Then, you can run `/tools/memdump`. diff --git a/tools/memdump.c b/tools/memdump.c index 8702bf4..158eb88 100644 --- a/tools/memdump.c +++ b/tools/memdump.c @@ -5,7 +5,7 @@ #include "common.h" -/* Read specified number of bytes at specified memory address through a BASIC +/* Read specified number of bytes at specified memory address through a Forth * remote shell and dump it to stdout. */ @@ -29,9 +29,7 @@ int main(int argc, char **argv) int fd = open(argv[1], O_RDWR|O_NOCTTY); char s[0x30]; - sprintf(s, "m=0x%04x", memptr); - sendcmdp(fd, s); - sprintf(s, "while m<0x%04x peek m:puth a:m=m+1", memptr+bytecount); + sprintf(s, ": _ 0x%04x 0x%04x DO I @ .x LOOP ; _", memptr+bytecount, memptr); sendcmd(fd, s); for (int i=0; i