| * The semantics of do_div() are: |
| * uint32_t do_div(uint64_t *n, uint32_t base) |
| * uint32_t remainder = *n % base; |
| * In other words, a 64-bit dividend with a 32-bit divisor producing |
| * a 64-bit result and a 32-bit remainder. To accomplish this optimally |
| * we call a special __do_div64 helper with completely non standard |
| * calling convention for arguments and results (beware). |
| register unsigned int __base asm("r4") = base; \ |
| register unsigned long long __n asm("r0") = n; \ |
| register unsigned long long __res asm("r2"); \ |
| register unsigned int __rem asm(__xh); \ |
| asm( __asmeq("%0", __xh) \ |
| : "=r" (__rem), "=r" (__res) \ |
| : "r" (__n), "r" (__base) \ |