* added compilers lcc and bcc (linux86)
[mascara-docs.git] / compilers / linux86-0.16.17 / libc / bcc / bcc_i386.c
blobfa57513c16ee08dafbfc540f866fbece8a1e2fbf
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 */
9 #ifdef __AS386_32__
10 #asm
11 .text ! This is common to all.
12 .align 4
13 #endasm
15 #ifdef L___divsi3
16 #asm
17 ! divsi3.s
18 .globl ___divsi3
19 ___divsi3:
20 push edx
21 mov eax,[esp+4+4]
22 cdq
23 idiv [esp+4+4+4]
24 pop edx
25 ret
27 .globl ___udivsi3
28 .text
29 .align 4
31 ___udivsi3:
32 push edx
33 mov eax,[esp+4+4]
34 sub edx,edx
35 div [esp+4+4+4]
36 pop edx
37 ret
38 #endasm
39 #endif
41 #ifdef L___idiv
42 #asm
43 ! idiv.s
44 ! idiv_ doesn`t preserve edx (returns remainder in it)
46 .globl idiv_
47 idiv_:
48 cdq
49 idiv ebx
50 ret
51 #endasm
52 #endif
54 #ifdef L___idivu
55 #asm
56 ! idivu.s
57 ! idiv_u doesn`t preserve edx (returns remainder in it)
59 .globl idiv_u
60 idiv_u:
61 xor edx,edx
62 div ebx
63 ret
64 #endasm
65 #endif
67 #ifdef L___imod
68 #asm
69 ! imod.s
70 ! imod doesn`t preserve edx (returns quotient in it)
72 .globl imod
73 imod:
74 cdq
75 idiv ebx
76 mov eax,edx ! instruction queue full so xchg slower
77 ret
78 #endasm
79 #endif
81 #ifdef L___imodu
82 #asm
83 ! imodu.s
84 ! imodu doesn`t preserve edx (returns quotient in it)
86 .globl imodu
87 imodu:
88 xor edx,edx
89 div ebx
90 mov eax,edx ! instruction queue full so xchg slower
91 ret
92 #endasm
93 #endif
95 #ifdef L___imul
96 #asm
97 ! imul.s
98 ! imul_, imul_u don`t preserve edx
100 .globl imul_
101 .globl imul_u
102 imul_:
103 imul_u:
104 imul ebx
106 #endasm
107 #endif
109 #ifdef L___isl
110 #asm
111 ! isl.s
112 ! isl, islu don`t preserve cl
114 .globl isl
115 .globl islu
116 isl:
117 islu:
118 mov cl,bl
119 shl eax,cl
121 #endasm
122 #endif
124 #ifdef L___isr
125 #asm
126 ! isr.s
127 ! isr doesn`t preserve cl
129 .globl isr
130 isr:
131 mov cl,bl
132 sar eax,cl
134 #endasm
135 #endif
137 #ifdef L___isru
138 #asm
139 ! isru.s
140 ! isru doesn`t preserve cl
142 .globl isru
143 isru:
144 mov cl,bl
145 shr eax,cl
147 #endasm
148 #endif
150 #endif