Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static inline long long rtai_llimd(long long ll, int mult, int div) {
- /* Returns (long long)ll = (int)ll*(int)(mult)/(int)div. */
- __asm__ __volatile ( \
- "movl %%edx,%%ecx\t\n" \
- "mull %%esi\t\n" \
- "movl %%eax,%%ebx\n\t" \
- "movl %%ecx,%%eax\t\n" \
- "movl %%edx,%%ecx\t\n" \
- "mull %%esi\n\t" \
- "addl %%ecx,%%eax\t\n" \
- "adcl $0,%%edx\t\n" \
- "divl %%edi\n\t" \
- "movl %%eax,%%ecx\t\n" \
- "movl %%ebx,%%eax\t\n" \
- "divl %%edi\n\t" \
- "sal $1,%%edx\t\n" \
- "cmpl %%edx,%%edi\t\n" \
- "movl %%ecx,%%edx\n\t" \
- "jge 1f\t\n" \
- "addl $1,%%eax\t\n" \
- "adcl $0,%%edx\t\n" \
- "1:\t\n" \
- : "=A" (ll) \
- : "A" (ll), "S" (mult), "D" (div) \
- : "%ebx", "%ecx");
- return ll;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement