Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

On RPi 4 GCC and CLANG use 16-bit loads

This is simplified from a larger example.

In the C source, I have:

uint32_t xx = oxdeadbeef ;

I compiled with gcc -O or clang -O

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Looking at ‘objdump -d a.out’ on the RPi 4, I see

9ac:    5297dde8    mov w8, #0xbeef // #48879
9b0:    72bbd5a8    movk w8, #0xdead, lsl #16

This produces the correct result, but, these are 16-bit values.
How do I force gcc or clang to use 32-bits in this case?

mov w8, #0xdeadbeef

Or, do I want to?

>Solution :

This micro does not have move immediate 32 value into the register, only 16 bits. 2 instructions are faster and shorter than storing the value in memory and load it into the register from memory.

That’s the reason why you have 2 instructions.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading