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