Closed sai2791 closed 6 months ago
I'm not saying this isn't worth adding directly to beebasm, but I think you can implement it via a macro:
$ cat /tmp/tbs.asm
macro equtbs s
if len(s) > 0
equs left$(s, len(s) - 1)
equb $80 or asc(right$(s, 1))
endif
endmacro
org $900
.start
equs "hello"
equtbs "hello"
equtbs ""
equb '*'
equtbs "goodbye"
.end
save "tbs", start, end
$ ./beebasm -i /tmp/tbs.asm -o x -v
.start
0900 68 65 6C ...
Macro equtbs:
0905 68 65 6C ...
0909 EF
End macro equtbs
Macro equtbs:
End macro equtbs
090A 2A
Macro equtbs:
090B 67 6F 6F ...
0911 E5
End macro equtbs
.end
Saving file 'tbs'
Processed file '/tmp/tbs.asm' ok
$ xxd tbs
00000000: 6865 6c6c 6f68 656c 6cef 2a67 6f6f 6462 hellohell.*goodb
00000010: 79e5 y.
I don't particularly like the name "equtbs", but you can obviously pick whatever you like.
equs (and presumably a native C++-implemented equtbs too) can accept multiple arguments, which this macro-based version of equtbs can't. So while I'm not sure this is a killer, there is an argument for a native implementation. Or allowing macros to take variable numbers of arguments. :-)
the macro is good enough for what I'm doing. thanks
I've found a number of strings with the last character of the string with the top bit set. I'm using beebdis which has the directive stringhi for this to decode the string correctly, but there does not seem to be equivalent corresponding directive in beebasm to recompile the source. Is this worthy of being added? I know that I can use a combination of EQUS and EQUB but it feels bad.