SamCoVT / TaliForth2

A Subroutine Threaded Code (STC) ANSI-like Forth for the 65c02
Other
28 stars 4 forks source link

disasm crashes with jsr to address not in dictionary #97

Closed SamCoVT closed 2 months ago

SamCoVT commented 2 months ago

It used to print the name of the word if it was in the dictionary, but now the disassembler crashes. Here is a simple test case:

assembler-wordlist >order
hex
: test [ 1234 jsr ] ;
see test

As it turns out, the crash was detected because xt_over still had underflow checking on...

Here's the place where it breaks in words/disasm.asm:

disassembler:
                stz scratch+5   ; flag indicating whether we're arriving at sliteral (vs 2literal)
                jsr xt_cr       ; ( addr u )
_byte_loop:
                ; Print address at start of the line. Note we use whatever
                ; number base the user has
                jsr xt_over     ; ( addr u addr ) <======= BREAKS HERE ON UNDERFLOW CHECK
                jsr xt_u_dot    ; ( addr u )
                jsr xt_space

I'm going to be working on this word anyway, so I'll see if I can fix it. I suspect the JSR handler is messing up the stack when it can't find the word in the dictionary.

SamCoVT commented 2 months ago

Indeed, it was a 2drop where it should have been a drop. I'll just include that with my PR to allow JSR xt+3 in disassembler (it's right in the same routine).