PeterTillema / ICE

ICE Compiler for the TI-84 Plus CE
22 stars 1 forks source link

Nested While in If/Else jumps to wrong address #125

Open PeterTillema opened 5 years ago

PeterTillema commented 5 years ago
If <condition>
    <small code: < 128 bytes>
Else
    While <condition>
        <large code: > 127 bytes>
    End
End

Result: the While <condition> injects a JP to its End, but the If <condition> uses a JR to its Else part, causing to move the entire While code 2 bytes up, which clearly makes the JP invalid.

Thanks @TheLastMillennial for finding the bug!

TheLastMillennial commented 5 years ago

I'd like to add that this did not apply just to While loops but to anything that was within the Else. The only solution is to remove the Else.