TG9541/stm8ef

Strange behaviour of LITERAL

Closed this issue · 7 comments

When used within a "if then" block LITERAL behaves strange.

HEX ABCD DUP
: test1 LITERAL ;
: test2 IF LITERAL THEN ;
test1 . ABCD ok ( this is expected)
-1 test2 . B4 ok ( ???)

Hoi @Eelkhoorn!

I'm not sure if that's what you intend to do... but the following code will show a more consistent behavior:

HEX ABCD
: test2 IF [ SWAP ] LITERAL THEN ; 

The result is now consistent with the input: -1 test2 . ABCD ok.

Without the SWAP you'd be using the address of the dummy IF jump target (patched by THEN).

@Eelkhoorn maybe the FC-table implementation in STM8-Modbus MBPROTO matches your use case: it allows patching a table at runtime and it's well tested. FC>XT is the access word and @?EXEC the execution word. You'll also find an extension mechanism with a default word.

Wow, that sounds interesting! If you get it working please share!

TG9541 commented

I'm looking forward to testing https://github.com/Eelkhoorn/stm8ef-mu !