#8 Condition check with multiple ports at once causes error.

closed-fixed
5
2008-09-13
2008-08-22
Jonny!!!
No

When doing this particular condition check:

If PORTA.5 on OR PORTA.0 on then
'mycode
end if

Once compiled by GCBASIC, MPASM shoots out this error:

ASM: Error[113] C:\PROGRA~1\GCBASIC\COMPILED.ASM 1072 : Symbol not previously defined (PORTA.51)

ASM: Error[113] C:\PROGRA~1\GCBASIC\COMPILED.ASM 1073 : Symbol not previously defined (PORTA.01)

It does this with the AND condition check as well. I don't understand why it's adding the "1" to the end of the port bit.

Thank you!

Discussion

  • Hugh Considine
    Hugh Considine
    2008-09-13

    Had a similar problem a while back, the solution is to add an equals sign like this:

    If PORTA.5 = on OR PORTA.0 = on then
    'mycode
    end if

    The reason for the 1 is that "On" is a constant in GCBASIC with a value of 1. When GCBASIC reads the line, it translates it into "If PORTA.5 1 OR PORTA.0 1 then". The condition checking code then removes any spaces ("If PORTA.51|PORTA.01 Then"), resulting in the mess that you saw in the asm file.

    I did consider making GCBASIC add the = automatically, but it was going to be difficult and the code already worked with the = sign in there.

     
  • Hugh Considine
    Hugh Considine
    2008-09-13

    • status: open --> closed-fixed