string.find is not working
Target cx16, Version:Prog8 compiler v10.3
string.find not working correct, here the compiled asm source for:
flag, pos = string.find(consts.DELIMETERCHAR, @(prgptr))
is compiled to:
ldy #>p8b_consts.p8v_DELIMETERCHAR
lda #<p8b_consts.p8v_DELIMETERCHAR
lda (p8b_main.p8v_prgptr)
tax
jsr string.find
But it should be
lda (p8b_main.p8v_prgptr)
tax
ldy #>p8b_consts.p8v_DELIMETERCHAR
lda #<p8b_consts.p8v_DELIMETERCHAR
jsr string.find
interesting, a register order problem. I'll have a look when I get back from my coding pause. You may be able to work around it by assigning one or both of the arguments of the function call to an intermedate variable or maybe cx16.Rx register.
However, in the meantime, I also have a question: is the code you posted supposed to be actual code? If so, what should it do? It suggests a problem in the meaning of the arguments.
Thanks for the response.
The code is parsing a command /program line and is looking for delimiter char;
str DELIMITERCHAR = " =,;#()]*/-+%&><"
where: @(prgptr) is the actual value of the position of the prg/line pointer
As workaround I'm using:
flag = string.contains(consts.DELIMITERCHAR, @(prgptr))
You could also just write if character in stringvar .
For my own reference: problem is inside argumentsViaRegisters() routine
Note that a fix for this will probably take me a while as I need a summer break ^_^
A workaround that avoids the problem was quite easy to make and is now implemented, but it could be improved a lot especially on 6502 CPU targets (it can cause a lot of stack juggling now). This is an optimization that has to wait till later.