modsi3.S 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. ! Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
  2. ! Imagination Technologies Ltd
  3. !
  4. ! Integer modulus routines.
  5. !
  6. !!
  7. !! 32-bit modulus unsigned i/p - passed unsigned 32-bit numbers
  8. !!
  9. .text
  10. .global ___umodsi3
  11. .type ___umodsi3,function
  12. .align 2
  13. ___umodsi3:
  14. MOV D0FrT,D1RtP ! Save original return address
  15. CALLR D1RtP,___udivsi3
  16. MOV D1RtP,D0FrT ! Recover return address
  17. MOV D0Re0,D1Ar1 ! Return remainder
  18. MOV PC,D1RtP
  19. .size ___umodsi3,.-___umodsi3
  20. !!
  21. !! 32-bit modulus signed i/p - passed signed 32-bit numbers
  22. !!
  23. .global ___modsi3
  24. .type ___modsi3,function
  25. .align 2
  26. ___modsi3:
  27. MOV D0FrT,D1RtP ! Save original return address
  28. MOV A0.2,D1Ar1 ! Save A in A0.2
  29. CALLR D1RtP,___divsi3
  30. MOV D1RtP,D0FrT ! Recover return address
  31. MOV D1Re0,A0.2 ! Recover A
  32. MOV D0Re0,D1Ar1 ! Return remainder
  33. ORS D1Re0,D1Re0,D1Re0 ! Was A negative?
  34. NEG D1Ar1,D1Ar1 ! Negate remainder
  35. MOVMI D0Re0,D1Ar1 ! Return neg remainder
  36. MOV PC, D1RtP
  37. .size ___modsi3,.-___modsi3