I was trying divide a result by 9 in ARM quite similarly to ARM DIVISION HOW TO DO IT? except for a couple of things,
- I'm trying to divide a 16 bit number (halfword)
- It is signed
I have the following implementation at the moment to divide [r8] and place it into [r1] but the result differs from the C++ implementation when the 16th bit is set and works otherwise
LDR r7, =0x1C72 ; 2**16 *(1/9) +1
MUL r9, r8, r7
LSR r9, #16
STRH r9, [r1], #2
Please let me know if you understand why. (ps I also tried with SMULBB but it wasn't any better