diff options
author | Robert de Bath <rdebath@poboxes.com> | 1996-11-03 22:33:35 +0100 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2013-10-23 23:33:35 +0200 |
commit | c218c617b5be443b7968308506969ad2b726d73c (patch) | |
tree | 0051f396af56133d24fcf2ab757fabc78c1a09bf /libc/bcc/bcc_i386.c | |
parent | 0936b9aeab611665645a4e6bafaded7ca76dd189 (diff) | |
parent | 0d2fbe9b1bd284ce2cad55be17e8f2c896031a25 (diff) | |
download | dev86-c218c617b5be443b7968308506969ad2b726d73c.tar.gz |
Import Dev86src-0.0.8.tar.gzv0.0.8
Diffstat (limited to 'libc/bcc/bcc_i386.c')
-rw-r--r-- | libc/bcc/bcc_i386.c | 149 |
1 files changed, 149 insertions, 0 deletions
diff --git a/libc/bcc/bcc_i386.c b/libc/bcc/bcc_i386.c new file mode 100644 index 0000000..d994628 --- /dev/null +++ b/libc/bcc/bcc_i386.c @@ -0,0 +1,149 @@ +/************************************************************************/ +/* This file contains the BCC compiler helper functions */ +/* 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 |