kevinpt / opbasm

Open PicoBlaze Assembler
http://kevinpt.github.io/opbasm/
MIT License
60 stars 13 forks source link

local labels do not work when using C-style ifs #17

Open nrother opened 7 years ago

nrother commented 7 years ago

The following code does not work:

proc:
jump .test
if (sA == 1) {
  nop()
}
.test:
nop()

This is because the if will create a label that will destroy the locality of .local. It would be nice if automatic generated labels could be ignored while parsing local label. This would make this features much more useful.

kevinpt commented 7 years ago

I have fixed this. Now all macro generated labels will start with "__". Any label with a double-underscore prefix will not affect the context for local labels.

nrother commented 7 years ago

Oh, looks like this introduces a subtle bug. The following code now fails:

loadaddr(tmp16, .jump_tab)
fetch sC, spm_state
add16(tmp16, zero, sC)
call@ (tmp16)
jump rxtx_Run ;endless loop

.jump_tab:
    jump doStateBusyDelimiterScanning
    jump doStateIdleDelimiterScanning

Message

ERROR: Unknown label: .jump_tab'upper
kevinpt commented 7 years ago

This should be fixed now.

nrother commented 3 years ago

Looks like this was broken again by 6b41b29745bebd52d787af57b771310810abb3a1 :cry: The version before seems to work.

Even simpler testcase:

a:
    jump .test
uniqlabel(debug):
    .test:
    load sA, 1