-
-
Notifications
You must be signed in to change notification settings - Fork 724
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
delayMicroseconds in complicated code causes compilation to fail #614
Comments
With the unsigned wait it is possible to wait for about 72 minutes. But I don't think it 's used for such long times. So a possible fix would be to use a signed value (still able to delay for 36 minutes), negate it in the function and use add instead of sub. Ok, as I am not an ARM assembly expert, I just assume that add also sets the zero flag |
@EmbeddedG: You could try it? Could you also check whether the cortex-m0 flag is given to the compiler (command line)? If yes, it's a compiler issue. |
Why do you think it is a better idea to change the function signature in the core library than changing a little detail in the function implementation? I can be convinced, if you have a good reason :) I don't think it's a good idea to change the function signature, that could break code using it. As far as I know, I checked the ARM architecture reference, the Cortex M0 manuals and several forums about GCC, unified/Thumb2 assembly and it is still not clear for me whether I could get this to work any other way. I like ARM assembly and sometimes I even write assembly routines, but I got a little lost here. Some other people also stated that the proper handling of sub with Cortex-M0 and unified assembly is not clear from GCC and ARM documentation. But forcing the compiler to use a Lo register always gets this working. |
excuse me, didn't check this completely. Why don't you make a pull request for this? I think it's a good idea to just use general purpose registers in case of 'sub'. |
No, it's not a compiler bug. ARMv6-M is restricted to a subset of Thumb-2 opcodes, and in particular SUB-immediate only takes low registers. See ARMv6-M Architecture Reference Manual section A6.7.65 "SUB (immediate)". As of writing, rev C is on the web but rev E is only available as a PDF (DDI0419E). So @EmbeddedG's solution is correct: the Related: adafruit/Adafruit_BusIO#102 I'm not sure if anyone will be hitting this issue again since 0a55883 no longer inlines |
Hello!
Compilation fails with the error message:
In this code:
%0 gets assigned to a high register (r8-r15) in my case. I suspect the reason is that gcc embeds this assembly in a complicated code using many registers (which is caused by LTO combining large parts of the code into single "functions"). Cortex-M0 doesn't support the sub/subs instruction with every register/immediate combination.
Modifying the register constraints so that only a lower register is suitable for %0 solves the problem for me:
SAMD core version: 1.8.9
GCC version: 9.3.1 (I need some C++17 features)
The text was updated successfully, but these errors were encountered: