Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- __divrem_u64_t wrap_divrem_u64(uint64_t dividend, uint64_t divisor) {
- __divrem_u64_t out;
- asm(".extern ___divrem_u64;"
- "r0 = %2L;"
- "r1 = %2H;"
- "r2 = %3L;"
- "r3 = %3H;"
- "[--sp] = r3;"
- "[--sp] = r2;"
- "[--sp] = r1;"
- "[--sp] = r0;" // Wants a minimal stack frame for scratch space
- "call ___divrem_u64;"
- "sp += 16;"
- "%0L = r0;"
- "%0H = r1;"
- "%1L = r2;"
- "%1H = r3;"
- : "=I"(out.quo),"=I"(out.rem) // Outputs
- : "I"(dividend),"I"(divisor) // Inputs
- // Clobbers (includes those clobbered by ___divrem_u64)
- : "r0","r1","r2","r3","p0","p1","p2","lc0","lt0","lb0","cc"
- );
- return out;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement