Advertisement
Guest User

Untitled

a guest
Jul 14th, 2011
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. static inline long long rtai_llimd(long long ll, int mult, int div) {
  2.  
  3. /* Returns (long long)ll = (int)ll*(int)(mult)/(int)div. */
  4.  
  5. __asm__ __volatile ( \
  6. "movl %%edx,%%ecx\t\n" \
  7. "mull %%esi\t\n" \
  8. "movl %%eax,%%ebx\n\t" \
  9. "movl %%ecx,%%eax\t\n" \
  10. "movl %%edx,%%ecx\t\n" \
  11. "mull %%esi\n\t" \
  12. "addl %%ecx,%%eax\t\n" \
  13. "adcl $0,%%edx\t\n" \
  14. "divl %%edi\n\t" \
  15. "movl %%eax,%%ecx\t\n" \
  16. "movl %%ebx,%%eax\t\n" \
  17. "divl %%edi\n\t" \
  18. "sal $1,%%edx\t\n" \
  19. "cmpl %%edx,%%edi\t\n" \
  20. "movl %%ecx,%%edx\n\t" \
  21. "jge 1f\t\n" \
  22. "addl $1,%%eax\t\n" \
  23. "adcl $0,%%edx\t\n" \
  24. "1:\t\n" \
  25. : "=A" (ll) \
  26. : "A" (ll), "S" (mult), "D" (div) \
  27. : "%ebx", "%ecx");
  28.  
  29. return ll;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement