Florent
Florent

Reputation: 137

Arm 7 How can I calculate x * 64 mod 2^64?

I have a requirement that I have to multiply a 64 bit number which is stored in 2 seperate registers with 64 mod 2^64. In this case the two 32bit values are stored in R4(low) and R5(high) So far I have written this code:

LDR         R1,=Value
LDR         R2, [R1]
MOV         R3, #64
UMULL       R4, R5, R2, R3
MUL         R6, R4, R3
MUL         R7, R5, R3
MOV         R1, R6, LSR #32
MOV         R2, R7, LSR #32

Value       DCD         67108864

For the mod 2^64 part I do the last two MOV commands with 32 bit shifts. Is this correct? When I do this I always get the value 0 in R1 and R2. What can I do so that I dont get mod 2^64 = 0?

Upvotes: 0

Views: 102

Answers (0)

Related Questions