Advertisement
tari

Untitled

Jul 6th, 2012
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.63 KB | None | 0 0
  1. __divrem_u64_t wrap_divrem_u64(uint64_t dividend, uint64_t divisor) {
  2.      __divrem_u64_t out;
  3.     asm(".extern ___divrem_u64;"
  4.       "r0 = %2L;"
  5.         "r1 = %2H;"
  6.         "r2 = %3L;"
  7.         "r3 = %3H;"
  8.         "[--sp] = r3;"
  9.         "[--sp] = r2;"
  10.         "[--sp] = r1;"
  11.         "[--sp] = r0;"      // Wants a minimal stack frame for scratch space
  12.         "call ___divrem_u64;"
  13.         "sp += 16;"
  14.         "%0L = r0;"
  15.         "%0H = r1;"
  16.         "%1L = r2;"
  17.         "%1H = r3;"
  18.         : "=I"(out.quo),"=I"(out.rem)   // Outputs
  19.         : "I"(dividend),"I"(divisor)                // Inputs
  20.         // Clobbers (includes those clobbered by ___divrem_u64)
  21.         : "r0","r1","r2","r3","p0","p1","p2","lc0","lt0","lb0","cc"
  22.         );
  23.     return out;
  24. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement