TLDR Version: I've updated the assembler further with string literal support so it doesn't try to disassemble the string data anymore.
VILR (Very Interesting... Let's Read!) Version: Tali inlines string data by compiling a jump over the string data, then a call to the string literal runtime handler, and then two cells that contain the address and length of the string:
Code:
Strings are compiled into the dictionary like so:
jmp a
<string data bytes>
a --> jsr sliteral_runtime
<string address>
<string length>
Tali used to try to disassemble the string data after the jump and would sometimes gack on it. To fix this, I needed to recognize the
JMP/JSR sliteral_runtime pattern. When the assembler encounters a JMP instruction, it peeks ahead at the jump destination to see if the 3 bytes there are the
JSR sliteral_runtime instruction. If it matches, it adjusts the current disassembly location to skip over the string data and continue at the jsr. There is then a special handler for
JSR sliteral_runtime that prints the following string address and length and skips over those as well.
I thought about printing the string data, but Tali supports very long strings and they are shown in the memory dump when using
SEE, so the address and length should be good enough in the disassembly. Here is an example of the new behavior, including typing in the address and length and
TYPEing one of the strings.
Code:
: teststrings s" This is a string literal" 2drop ." This is a printed string" ; ok
see teststrings
nt: 800 xt: 813
flags (CO AN IM NN UF HC): 0 0 0 1 0 1
size (decimal): 78
0813 4C 2E 08 54 68 69 73 20 69 73 20 61 20 73 74 72 L..This is a str
0823 69 6E 67 20 6C 69 74 65 72 61 6C 20 8A A0 16 08 ing lite ral ....
0833 18 00 20 D5 D7 E8 E8 E8 E8 4C 57 08 54 68 69 73 .. ..... .LW.This
0843 20 69 73 20 61 20 70 72 69 6E 74 65 64 20 73 74 is a pr inted st
0853 72 69 6E 67 20 8A A0 3F 08 18 00 20 DE A4 ring ..? ... ..
813 82E jmp
82E A08A jsr SLITERAL 816 18
835 D7D5 jsr STACK DEPTH CHECK
838 inx
839 inx
83A inx
83B inx
83C 857 jmp
857 A08A jsr SLITERAL 83F 18
85E A4DE jsr type
ok
$816 $18 type This is a string literal ok
The
2DROP got inlined as the stack depth check and the
INX instructions.