ARM/aeabi uidivmod

From aldeid
Jump to navigation Jump to search
You are here


Perform a division of R0/R1 and save quotient in R0 and remainder in R1.


BL __aeabi_uidivmod


.text:00000EEE MOVS    R0, R4                                ; R0 = 0x7365
.text:00000EF0 LDR     R1, [SP,#0x1BB8+current_prime_number] ; R1 = 0x2
.text:00000EF2 BL      __aeabi_uidivmod                      ; division R0/R1. R0 = quotient = 0x39b2, R1 = remainder = 0x1
.text:00000EF6 LSLS    R1, R1, #0x10
.text:00000EF8 LSRS    R1, R1, #0x10
.text:00000EFA BNE     loc_F5C

The above example could be illustrated as follows in python

>>> r0 = 0x7365
>>> r1 = 0x2
>>> (quotient, remainder) = (r0/r1, r0%r1)
>>> hex(quotient)
>>> hex(remainder)