PDA

View Full Version : analize pleas - arm 32 byte code



OrbiTel gSm
12-08-2003, 05:52 PM
LDRMIB R0, [R8,-R0]!
SUB R1, R0, #0xA
SUB R0, R0, R0,LSR#2
ADD R0, R0, R0,LSR#4
ADD R0, R0, R0,LSR#8
ADD R0, R0, R0,LSR#16
MOV R0, R0,LSR#3
ADD R2, R0, R0,LSL#2
SUBS R1, R1, R2,LSL#1
ADDPL R0, R0, #1
ADDMI R1, R1, #0xA
BX LR


thanx for the analizing

wumpus
12-08-2003, 09:52 PM
It's the udiv10 function.. (unsigned divide by 10)
Return quotient in R0, remainder in R1

StiNKy
13-08-2003, 06:41 AM
now how the hell did you work that out wumpus?... teach me almighty! :P

OrbiTel gSm
13-08-2003, 07:22 AM
Originally posted by wumpus
It's the udiv10 function.. (unsigned divide by 10)
Return quotient in R0, remainder in R1

Thanx mate )

wumpus
13-08-2003, 12:07 PM
Well, I worked out the floating point/double routines in the firmware disassembly, so recognized the 'divide' pattern.

But I didn't know a certain instruction, so searched for that in the Arm7TDMI data sheet.. and guess what was the stereotypical ARM32 code example there.. yeah, the udiv10 function, exactly this one :-) that was easy