ARM is soo sweet!
Posted: Fri Jul 07, 2006 3:35 am
Hi.
I'm now more and more involved in ARM development. with my IXP2400 board, of course (starring a intel strongARM processor to schedule the 'microengines' behaviour), but also with my nintendo DS (which features two ARMs) ... And my Zaurus PDA also has an ARM stuff ... I think that means i now have more ARMs around me than x86
... well maybe not yet, i still need to buy a couple of other devices 
'til yesterday, i mainly used gcc cross-compiler to program all those stuff -- and in Linux environment most of the times, so you barely notice the fact you're running on a different beast ... just the minicom's red bar reminds me i'm not in "just-another-ssh-session"
But today, i'm going into the details of ARM instruction set, and let me tell you it's way sweeter than all i've seen in x86 world. More registers, position-relative addressing (you know, that thing that is terribly missing for relocatable code on PCs
), conditional execution of load/store (e.g. you have load-unless-Zero-flag-is-clear, store-if-Zero-flag-is-set, and probably much more).
And the most surprising is probably the absence of a RET instruction (afaik, you just copy PC into another register) and the multi-usage-memory-swiss-knife instruction, aka "LoaD Multiple, Increase After" (ldmia for friends). That one is simply magic! let's say you want to load a whole structure into a couple of registers. Easy game. You just put your structure's address into any register (say R2) and the list of registers you want to see filled (e.g. {R3, R4, R5}) and voil?.
That also means that a function's epilog can be expressed with
okay ... x86_64 also has PC-relative access and we now have cmove to mimmic the ldreq/strne instructions. Yet i see no x86_64 around (none i can hook for osdeving, at least).
So, anyone of you targetting ARM products in your projects ? or having ARM-equipped devices handing around ?
I'm now more and more involved in ARM development. with my IXP2400 board, of course (starring a intel strongARM processor to schedule the 'microengines' behaviour), but also with my nintendo DS (which features two ARMs) ... And my Zaurus PDA also has an ARM stuff ... I think that means i now have more ARMs around me than x86
'til yesterday, i mainly used gcc cross-compiler to program all those stuff -- and in Linux environment most of the times, so you barely notice the fact you're running on a different beast ... just the minicom's red bar reminds me i'm not in "just-another-ssh-session"
But today, i'm going into the details of ARM instruction set, and let me tell you it's way sweeter than all i've seen in x86 world. More registers, position-relative addressing (you know, that thing that is terribly missing for relocatable code on PCs
And the most surprising is probably the absence of a RET instruction (afaik, you just copy PC into another register) and the multi-usage-memory-swiss-knife instruction, aka "LoaD Multiple, Increase After" (ldmia for friends). That one is simply magic! let's say you want to load a whole structure into a couple of registers. Easy game. You just put your structure's address into any register (say R2) and the list of registers you want to see filled (e.g. {R3, R4, R5}) and voil?.
That also means that a function's epilog can be expressed with
Code: Select all
add sp, sp, #4 ; sp := sp + 4 as you may guess
ldmia sp!, {r4, r5, pc}
; fill r4 with [sp], r5 with [sp+4] and pc with [sp+8]
; "ia" stands for 'increment after'. there is also 'pre-increment',
; post-decrement and pre-decrement, as you may guess.
; the sp! means you want sp to be refreshed with sp+12 at
; the end of the instruction
So, anyone of you targetting ARM products in your projects ? or having ARM-equipped devices handing around ?