bcc_i386.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /************************************************************************/
  2. /* This file contains the BCC compiler helper functions */
  3. /* (C) Copyright Bruce Evans */
  4. /* Support for 386 integer arithmetic
  5. * __divsi3.o __idiv.o __idivu.o __imod.o __imodu.o __imul.o
  6. * __isl.o __isr.o __isru.o
  7. */
  8. #ifdef __AS386_32__
  9. #asm
  10. .text ! This is common to all.
  11. .align 4
  12. #endasm
  13. #ifdef L___divsi3
  14. #asm
  15. ! divsi3.s
  16. .globl ___divsi3
  17. ___divsi3:
  18. push edx
  19. mov eax,[esp+4+4]
  20. cdq
  21. idiv [esp+4+4+4]
  22. pop edx
  23. ret
  24. .globl ___udivsi3
  25. .text
  26. .align 4
  27. ___udivsi3:
  28. push edx
  29. mov eax,[esp+4+4]
  30. sub edx,edx
  31. div [esp+4+4+4]
  32. pop edx
  33. ret
  34. #endasm
  35. #endif
  36. #ifdef L___idiv
  37. #asm
  38. ! idiv.s
  39. ! idiv_ doesn`t preserve edx (returns remainder in it)
  40. .globl idiv_
  41. idiv_:
  42. cdq
  43. idiv ebx
  44. ret
  45. #endasm
  46. #endif
  47. #ifdef L___idivu
  48. #asm
  49. ! idivu.s
  50. ! idiv_u doesn`t preserve edx (returns remainder in it)
  51. .globl idiv_u
  52. idiv_u:
  53. xor edx,edx
  54. div ebx
  55. ret
  56. #endasm
  57. #endif
  58. #ifdef L___imod
  59. #asm
  60. ! imod.s
  61. ! imod doesn`t preserve edx (returns quotient in it)
  62. .globl imod
  63. imod:
  64. cdq
  65. idiv ebx
  66. mov eax,edx ! instruction queue full so xchg slower
  67. ret
  68. #endasm
  69. #endif
  70. #ifdef L___imodu
  71. #asm
  72. ! imodu.s
  73. ! imodu doesn`t preserve edx (returns quotient in it)
  74. .globl imodu
  75. imodu:
  76. xor edx,edx
  77. div ebx
  78. mov eax,edx ! instruction queue full so xchg slower
  79. ret
  80. #endasm
  81. #endif
  82. #ifdef L___imul
  83. #asm
  84. ! imul.s
  85. ! imul_, imul_u don`t preserve edx
  86. .globl imul_
  87. .globl imul_u
  88. imul_:
  89. imul_u:
  90. imul ebx
  91. ret
  92. #endasm
  93. #endif
  94. #ifdef L___isl
  95. #asm
  96. ! isl.s
  97. ! isl, islu don`t preserve cl
  98. .globl isl
  99. .globl islu
  100. isl:
  101. islu:
  102. mov cl,bl
  103. shl eax,cl
  104. ret
  105. #endasm
  106. #endif
  107. #ifdef L___isr
  108. #asm
  109. ! isr.s
  110. ! isr doesn`t preserve cl
  111. .globl isr
  112. isr:
  113. mov cl,bl
  114. sar eax,cl
  115. ret
  116. #endasm
  117. #endif
  118. #ifdef L___isru
  119. #asm
  120. ! isru.s
  121. ! isru doesn`t preserve cl
  122. .globl isru
  123. isru:
  124. mov cl,bl
  125. shr eax,cl
  126. ret
  127. #endasm
  128. #endif
  129. #endif