Category:ARM Assembly: Difference between revisions
m
→Limitations of the ARM
Puppydrum64 (talk | contribs) |
Puppydrum64 (talk | contribs) |
||
Line 162:
===Limitations of the ARM===
While the ARM has a rich amount of features that other processors only dream of having, there are a few limitations.
The biggest one
Looking at the following in C and its ARM assembly equivalent (I've cut the stack twiddling and the return statement for clarity) we can see just what exactly happens:
<lang
return 0xFFFF;
}</lang>
<lang ARM Assembly>
mov r0, #255 ;MOV R0,#0xFF
orr r0, r0, #65280 ;ORR R0,#0xFF00 (0xFF00|0x00FF = 0xFFFF)</lang>
It's very common to store "complicated" numbers into a nearby data block and just load from that data block with PC-relative addressing. These data blocks are usually placed after the nearest return statement so that they don't get executed as instructions.
<lang ARM Assembly>ldr r0,testData ;load 0xABCD1234 into R0
bx lr ;return
testData:
.long 0xABCD1234</lang>
Thankfully, there's an even easier solution than this. The GNU Assembler saves the day with the following special notation.
|