Hello,
I am trying to compile some asm code with operand unable to be used as immediate, but compiler does not generate error but produce strange binary code, hard to detect erroneous code.
The source code
int main(void){
asm volatile ( "mov r0, #0x1234 \n" "orr r0, #0x4321 \n");}
The binary code generated
0000802c <main>: 802c: f241 2034 movw r0, #4660 ; 0x1234 8030: f244 3021 movw r0, #17185 ; 0x4321 8034: 2000 movs r0, #0 8036: 4770 bx lr
Why does not the compiler throw warn or error but silently produce the strange code?
Thanks
Gene
Quick question: which compiler and version are you using?
I use gcc-arm-none-eabi-7-2017-q4-major version, but I also meet the issue using gcc-arm-none-eabi-6_2-2016q4 .
Hi Gene, thanks for the report. We're investigating this and will get back to you soon.
Thank you
Our preliminary investigations suggest its a bug. We're working on fixing it and will include the fix in a new release shortly.
More specifically, the assembler should print an error in this case because that immediate is invalid for ORR. We'll include a fix for the assembler to print a warning.
Thanks a lot