In [r16234] I disabled the use of the jp lt instruction for the r4k port. It worked fine when used in regression tests (run on uCsim), but something goes wrong on real hardware.
I can reproduce the issue using SDCC from current svn trunk using the attached test program.
Some thoughts:
Edit 1: Can you write the state of all the relevant flags before the jump (preserving them, writing them, then restoring them) on the emulator and on the machine?
Can you produce the same function with the "official" tools? Would the bytes be the same, or when you can't control the address, would the byte patterns be the same, considering the different address? If the byte patterns are the same, would it behave the same?
Edit 2: The byte patterns to compare have to be those after linking not before.
Could you change the mode at the start of the function to 11 and right before exit to 10 again, and see if you can have the same behavior then?
Last edit: Janko Stamenović 1 day ago