Op Mon, 07 May 2012 00:36:22 +0200 schreef Bernard Talbert
<
bernard...@gmail.com>:
> Need some help decipher some ARM assembly code that doesn't have
> comments.
>
> Some of the instructions use conditional execution and I'm trying to
> figure out higher level
> "if condition" they are checking for. For example in the following
> snippet
> the ANDS is setting condition codes. What "if equal" condition is the
> BEQ instruction checking for here?
If you had read the section in the Architecture Reference Manual about
Conditional Execution, you would have found out that EQ means "if Z==1".
Predictably, ANDS sets Z when the result is zero.
> Equal to what?
The term "equal" only makes sense when you perform a compare operation.
> If the instruction setting conditions codes were CMP
> I know its (x == y) where x and y are the operands. But what is for
> ANDS here?
>
> rsb r3, r0, #0 /* r3 = -r0 */
> ands r3, r3, #0x1C /* r3 = (r3 & 0x1c), setCPSR.flags(r3) */
> beq 3f /* if (equal?) goto 3f */
>
> I'm having trouble decipher the following also. The MOVS sets
> condition codes.
> What condition are the store byte instructions checking for? CS = HS
> right?
As the pseudocode definition says, LSL sets C equal to the last bit
shifted out and N to the MSB of the result.
> So greater-than or equal to what?
Also this term only makes sense when you perform a compare operation.
> movs r12, r3, lsl #31 /* r12 = (r3 << 31), set
> CPSR.flags(r12) */
> strcsb r1, [r0], #1 /* if ?(C==1) *(r0) = r1, r0 += 1 */
> strcsb r1, [r0], #1 /* if ?(C==1) *(r0) = r1, r0 += 1 */
> strmib r1, [r0], #1 /* if ?(N==1) *(r0) = r1, r0 += 1 */
--
Gemaakt met Opera's revolutionaire e-mailprogramma:
http://www.opera.com/mail/
(Remove the obvious prefix to reply privately.)