Closed patricksurry closed 6 months ago
i haven't been using wordlists, so this simple helper seems to work for decoding the return stack. As Sam notes the return stack might also contain user data for loop control and explicit r>
etc. But usually the first pair of bytes on the return stack is the return address for an underflow check jsr
in a native word, so writing above example as a low-endian address we do $8d30 trace>name
.
This doesn't work for addresses in tali internals (tho symbol table is your friend there). Similarly if you have inlined native words you'll find the containing word rather than the actual native word triggering the error but that is often enough. The disasm
and dump
words are also useful to see what's happening and locate a dictionary header.
: trace>name ( addr -- nt )
\ find largest nt prior to addr
>r 0 latestnt begin
?dup while
2dup u< over r@ u< and if
nip dup
then
2 + @
repeat
r> drop
dup if
dup u. dup wordsize u. dup name>string type space cr
then
;
lmk if this looks better
Resolves #34
Dumps the return stack prior to an underflow message, which changes to 'Data stack underflow' instead of just 'Stack underflow'. All tests still pass.
Also corrects a couple of minor typos I noticed and adds a python environment.yml suitable for conda or micromamba to create an env for running tests.