opbasm icon indicating copy to clipboard operation
opbasm copied to clipboard

local labels do not work when using C-style ifs

Open nrother opened this issue 8 years ago • 4 comments

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.

nrother avatar Aug 08 '17 12:08 nrother

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.

kevinpt avatar Aug 11 '17 03:08 kevinpt

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

nrother avatar Aug 11 '17 10:08 nrother

This should be fixed now.

kevinpt avatar Aug 11 '17 13:08 kevinpt

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

nrother avatar Jul 21 '21 09:07 nrother