SamCoVT / TaliForth2

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

How should disasm handle words with CFA (HC flag)? #120

Closed patricksurry closed 1 week ago

patricksurry commented 1 month ago

Some of the CFA words use adjust_z to include the PFA payload within the word size (e.g. variable, defer). But other words don't (like 2constant, marker). These words are never-native so the word content never gets copied and presumably it would be wrong to copy the data anyway.

Adjusting the word size means that disasm dumps the bytes for both CFA and PFA but then tries to disassemble through the PFA which (usually?) doesn't make sense. For example:

3 constant foo  ok
see foo 
nt: 800  xt: 80B 
flags: CO 0 IM 0 AN 0 NN 1 HC 1 | UF 0 ST 0 
size (decimal): 5 

080B  20 F1 D6 03 00   ....

80B   D6F1 jsr     
80E        ?
80F     20 brk

It's useful to see the PFA, but it's a little opaque what's going on right now. What's your ideal presentation for a HC word? Perhaps something like this?

080B  20 F1 D6 03 00   .....

80B   D6F1 jsr     (CFA)

Maybe simpler: we could skip CFA adjustment for word sizes altogether so that disasm wouldn't be confused. Then see could check HC flag and add a second dump for the PFA. I guess it wouldn't know how big it was without a lookup table for the various CFA handlers tho.

080B  20 F1 D6   ...

80B   D6F1 jsr     ; CFA

80E   03 00   ..   ; PFA
patricksurry commented 1 month ago

side note: since all opcodes are defined on 65c02, shouldn't it show 80E nop instead of ?

SamCoVT commented 1 month ago

We could have Tali print nop instead of ?, but Tali usually only encounters these when trying to disassemble data (in which case the ? is a better indication of confusion).

It probably makes sense to stop assembling before the data on these HCF words, bit it would be nice if DUMP still displayed the extra so the data is visible. I like your suggestion of: `` 080B 20 F1 D6 03 00 .....

80B D6F1 jsr (CFA)