summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/dietlibc/i386
diff options
context:
space:
mode:
Diffstat (limited to 'mdk-stage1/dietlibc/i386')
-rw-r--r--mdk-stage1/dietlibc/i386/Makefile.add7
-rw-r--r--mdk-stage1/dietlibc/i386/PIC.h82
-rw-r--r--mdk-stage1/dietlibc/i386/__half.S10
-rw-r--r--mdk-stage1/dietlibc/i386/__longjmp.S1
-rw-r--r--mdk-stage1/dietlibc/i386/__ten.S9
-rw-r--r--mdk-stage1/dietlibc/i386/__testandset.S1
-rw-r--r--mdk-stage1/dietlibc/i386/accept.S4
-rw-r--r--mdk-stage1/dietlibc/i386/acos.S30
-rw-r--r--mdk-stage1/dietlibc/i386/acosh.S18
-rw-r--r--mdk-stage1/dietlibc/i386/asin.S29
-rw-r--r--mdk-stage1/dietlibc/i386/asinh.S18
-rw-r--r--mdk-stage1/dietlibc/i386/atan.S27
-rw-r--r--mdk-stage1/dietlibc/i386/atan2.S12
-rw-r--r--mdk-stage1/dietlibc/i386/atanh.S19
-rw-r--r--mdk-stage1/dietlibc/i386/atol.S55
-rw-r--r--mdk-stage1/dietlibc/i386/atoll.S64
-rw-r--r--mdk-stage1/dietlibc/i386/bind.S4
-rw-r--r--mdk-stage1/dietlibc/i386/cbrt.S46
-rw-r--r--mdk-stage1/dietlibc/i386/ceil.S44
-rw-r--r--mdk-stage1/dietlibc/i386/clone.S29
-rw-r--r--mdk-stage1/dietlibc/i386/connect.S4
-rw-r--r--mdk-stage1/dietlibc/i386/copysign.S18
-rw-r--r--mdk-stage1/dietlibc/i386/cos.S35
-rw-r--r--mdk-stage1/dietlibc/i386/cosh.S29
-rw-r--r--mdk-stage1/dietlibc/i386/dyn_syscalls.S282
-rw-r--r--mdk-stage1/dietlibc/i386/exp.S35
-rw-r--r--mdk-stage1/dietlibc/i386/exp10.S27
-rw-r--r--mdk-stage1/dietlibc/i386/exp2.S18
-rw-r--r--mdk-stage1/dietlibc/i386/expm1.S23
-rw-r--r--mdk-stage1/dietlibc/i386/fabs.S11
-rw-r--r--mdk-stage1/dietlibc/i386/floor.S26
-rw-r--r--mdk-stage1/dietlibc/i386/fmod.S37
-rw-r--r--mdk-stage1/dietlibc/i386/getenv.S48
-rw-r--r--mdk-stage1/dietlibc/i386/getpeername.S4
-rw-r--r--mdk-stage1/dietlibc/i386/getsockname.S4
-rw-r--r--mdk-stage1/dietlibc/i386/getsockopt.S4
-rw-r--r--mdk-stage1/dietlibc/i386/htonl.S13
-rw-r--r--mdk-stage1/dietlibc/i386/htons.S11
-rw-r--r--mdk-stage1/dietlibc/i386/hypot.S15
-rw-r--r--mdk-stage1/dietlibc/i386/ilogb.S23
-rw-r--r--mdk-stage1/dietlibc/i386/ipow.S27
-rw-r--r--mdk-stage1/dietlibc/i386/isleap.S28
-rw-r--r--mdk-stage1/dietlibc/i386/ldexp.S28
-rw-r--r--mdk-stage1/dietlibc/i386/libm2.S643
-rw-r--r--mdk-stage1/dietlibc/i386/listen.S4
-rw-r--r--mdk-stage1/dietlibc/i386/log.S26
-rw-r--r--mdk-stage1/dietlibc/i386/log10.S11
-rw-r--r--mdk-stage1/dietlibc/i386/log1p.S12
-rw-r--r--mdk-stage1/dietlibc/i386/log2.S11
-rw-r--r--mdk-stage1/dietlibc/i386/ltostr.S62
-rw-r--r--mdk-stage1/dietlibc/i386/mcount.S44
-rw-r--r--mdk-stage1/dietlibc/i386/md5asm.S300
-rw-r--r--mdk-stage1/dietlibc/i386/memccpy.S39
-rw-r--r--mdk-stage1/dietlibc/i386/memchr.S24
-rw-r--r--mdk-stage1/dietlibc/i386/memcmp.S26
-rw-r--r--mdk-stage1/dietlibc/i386/memcpy.S16
-rw-r--r--mdk-stage1/dietlibc/i386/memset.S15
-rw-r--r--mdk-stage1/dietlibc/i386/mmap.S14
-rw-r--r--mdk-stage1/dietlibc/i386/mmap64.S63
-rw-r--r--mdk-stage1/dietlibc/i386/poly.S24
-rw-r--r--mdk-stage1/dietlibc/i386/pow.S67
-rw-r--r--mdk-stage1/dietlibc/i386/recv.S4
-rw-r--r--mdk-stage1/dietlibc/i386/recvfrom.S4
-rw-r--r--mdk-stage1/dietlibc/i386/recvmsg.S4
-rw-r--r--mdk-stage1/dietlibc/i386/rint.S23
-rw-r--r--mdk-stage1/dietlibc/i386/send.S4
-rw-r--r--mdk-stage1/dietlibc/i386/sendmsg.S4
-rw-r--r--mdk-stage1/dietlibc/i386/sendto.S4
-rw-r--r--mdk-stage1/dietlibc/i386/setjmp.S55
-rw-r--r--mdk-stage1/dietlibc/i386/setsockopt.S4
-rw-r--r--mdk-stage1/dietlibc/i386/shutdown.S4
-rw-r--r--mdk-stage1/dietlibc/i386/sin.S34
-rw-r--r--mdk-stage1/dietlibc/i386/sincos.S18
-rw-r--r--mdk-stage1/dietlibc/i386/sinh.S29
-rw-r--r--mdk-stage1/dietlibc/i386/sleep.S25
-rw-r--r--mdk-stage1/dietlibc/i386/socket.S4
-rw-r--r--mdk-stage1/dietlibc/i386/socketcall.S17
-rw-r--r--mdk-stage1/dietlibc/i386/socketpair.S4
-rw-r--r--mdk-stage1/dietlibc/i386/sqrt.S23
-rw-r--r--mdk-stage1/dietlibc/i386/sqrtl.S11
-rw-r--r--mdk-stage1/dietlibc/i386/start.S69
-rw-r--r--mdk-stage1/dietlibc/i386/stpcpy.S22
-rw-r--r--mdk-stage1/dietlibc/i386/strcasecmp.S31
-rw-r--r--mdk-stage1/dietlibc/i386/strcat.S29
-rw-r--r--mdk-stage1/dietlibc/i386/strchr.S22
-rw-r--r--mdk-stage1/dietlibc/i386/strcmp.S31
-rw-r--r--mdk-stage1/dietlibc/i386/strcpy.S24
-rw-r--r--mdk-stage1/dietlibc/i386/strlen.S18
-rw-r--r--mdk-stage1/dietlibc/i386/strncmp.S28
-rw-r--r--mdk-stage1/dietlibc/i386/strncpy.S42
-rw-r--r--mdk-stage1/dietlibc/i386/strrchr.S19
-rw-r--r--mdk-stage1/dietlibc/i386/syscalls.h303
-rw-r--r--mdk-stage1/dietlibc/i386/tan.S12
-rw-r--r--mdk-stage1/dietlibc/i386/tanh.S32
-rw-r--r--mdk-stage1/dietlibc/i386/unified.S35
-rw-r--r--mdk-stage1/dietlibc/i386/usleep.S31
-rw-r--r--mdk-stage1/dietlibc/i386/vfork.S9
-rw-r--r--mdk-stage1/dietlibc/i386/write12.S37
98 files changed, 3645 insertions, 84 deletions
diff --git a/mdk-stage1/dietlibc/i386/Makefile.add b/mdk-stage1/dietlibc/i386/Makefile.add
index b685cc360..83b18ae29 100644
--- a/mdk-stage1/dietlibc/i386/Makefile.add
+++ b/mdk-stage1/dietlibc/i386/Makefile.add
@@ -1,3 +1,8 @@
-CFLAGS+=-march=i386 -mcpu=i386 -Os -fomit-frame-pointer
+M:=$(shell ./findcflags.sh $(CC))
+LIBOBJ+=$(OBJDIR)/__ten.o $(OBJDIR)/md5asm.o $(OBJDIR)/mmap64.o
+LIBMATH+=acos.o asin.o atan.o atan2.o ceil.o cos.o exp.o exp10.o exp2.o expm1.o fabs.o floor.o hypot.o log.o log10.o log2.o sin.o sqrt.o tan.o copysign.o sincos.o __half.o ldexp.o pow.o ilogb.o cbrt.o log1p.o sqrtl.o fmod.o libm2.o
+#CFLAGS+=-march=i386 -Os -fomit-frame-pointer -malign-functions=0 -malign-jumps=0 -malign-loops=0 -mpreferred-stack-boundary=2
+CFLAGS+=$(M)
VPATH:=i386:syscalls.s:$(VPATH)
+LIBGMON_OBJS+=$(OBJDIR)/mcount.o
diff --git a/mdk-stage1/dietlibc/i386/PIC.h b/mdk-stage1/dietlibc/i386/PIC.h
new file mode 100644
index 000000000..45ddeb446
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/PIC.h
@@ -0,0 +1,82 @@
+#ifndef __I386_PIC_H__
+#define __I386_PIC_H__
+#ifdef __DYN_LIB
+
+#if 1
+/* don't trash the athlon return stack */
+.text
+.Lgetpic:
+ mov (%esp),%ebx
+ ret
+
+.macro PIC_INIT
+ call .Lgetpic
+ addl $_GLOBAL_OFFSET_TABLE_, %ebx
+.endm
+#else
+/* standard code for PIC init */
+.macro PIC_INIT
+ call 0f
+0: popl %ebx
+ addl $_GLOBAL_OFFSET_TABLE_+[.-0b], %ebx
+.endm
+#endif
+
+#define PIC_SAVE pushl %ebx
+#define PIC_RESTORE popl %ebx
+
+
+/* get memory variable (var) in register (reg) */
+.macro GET_VAR var reg
+ movl \var@GOT(%ebx), \reg
+ movl (\reg), \reg
+.endm
+
+/* put register (reg) into memory variable (var) TRASH register (tmp) */
+.macro PUT_VAR reg var tmp
+ movl \var@GOT(%ebx), \tmp
+ movl \reg, (\tmp)
+.endm
+
+/* get memory variable (var) in register (reg)
+ * IF no more PIC-code is needed */
+.macro GET_1VAR var reg
+ PIC_SAVE
+ PIC_INIT
+ GET_VAR \var, \reg
+ PIC_RESTORE
+.endm
+
+/* put register (reg) into memory variable (var)
+ * IF no more PIC-code is needed */
+.macro PUT_1VAR reg var
+ PIC_SAVE
+ PIC_INIT
+ PUT_VAR \reg, \var, %ebx
+ PIC_RESTORE
+.endm
+
+#else
+
+#define PIC_SAVE
+#define PIC_RESTORE
+#define PIC_INIT
+
+.macro GET_VAR var reg
+ movl \var, \reg
+.endm
+
+.macro PUT_VAR reg var tmp
+ movl \reg, \var
+.endm
+
+.macro GET_1VAR var reg
+ GET_VAR \var, \reg
+.endm
+
+.macro PUT_1VAR reg var
+ PUT_VAR \reg, \var, none
+.endm
+
+#endif
+#endif
diff --git a/mdk-stage1/dietlibc/i386/__half.S b/mdk-stage1/dietlibc/i386/__half.S
new file mode 100644
index 000000000..6355c93e4
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/__half.S
@@ -0,0 +1,10 @@
+#
+# Definiert Konstante (float)0.5 unter dem Namen __half
+# Wird von etlichen Funktionen benutzt (sinh, cosh, atanh)
+#
+
+.global __half
+.data
+.type __half,@object
+.size __half,4
+__half: .long 0x3f000000
diff --git a/mdk-stage1/dietlibc/i386/__longjmp.S b/mdk-stage1/dietlibc/i386/__longjmp.S
index 098275037..a09191f0b 100644
--- a/mdk-stage1/dietlibc/i386/__longjmp.S
+++ b/mdk-stage1/dietlibc/i386/__longjmp.S
@@ -2,6 +2,7 @@
.text
.global __longjmp
+.type __longjmp,@function
__longjmp:
movl 4(%esp), %ecx /* User's jmp_buf in %ecx. */
movl 8(%esp), %eax /* Second argument is return value. */
diff --git a/mdk-stage1/dietlibc/i386/__ten.S b/mdk-stage1/dietlibc/i386/__ten.S
new file mode 100644
index 000000000..47b9431f4
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/__ten.S
@@ -0,0 +1,9 @@
+#
+# Definiert Konstante (float)10. unter dem Namen __ten
+#
+
+.global __ten
+.data
+.type __ten,@object
+.size __ten,4
+__ten: .long 0x41200000
diff --git a/mdk-stage1/dietlibc/i386/__testandset.S b/mdk-stage1/dietlibc/i386/__testandset.S
index af7b4d5a0..29b02d57a 100644
--- a/mdk-stage1/dietlibc/i386/__testandset.S
+++ b/mdk-stage1/dietlibc/i386/__testandset.S
@@ -1,5 +1,6 @@
.text
.global __testandset
+.type __testandset,@function
__testandset:
xorl %eax, %eax
movl 0x4(%esp),%edx
diff --git a/mdk-stage1/dietlibc/i386/accept.S b/mdk-stage1/dietlibc/i386/accept.S
new file mode 100644
index 000000000..d8be36a54
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/accept.S
@@ -0,0 +1,4 @@
+#include <linuxnet.h>
+#include <syscalls.h>
+
+__socketcall(accept,ACCEPT)
diff --git a/mdk-stage1/dietlibc/i386/acos.S b/mdk-stage1/dietlibc/i386/acos.S
new file mode 100644
index 000000000..baabf9f04
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/acos.S
@@ -0,0 +1,30 @@
+
+.text
+
+.global acosf,acos,acosl # ,__acos
+ .type acosf,@function
+ .type acos,@function
+ .type acosl,@function
+# .type __acos,@function
+acosf:
+ flds 4(%esp)
+ jmp __acos
+acosl:
+ fldt 4(%esp)
+ jmp __acos
+acos:
+ fldl 4(%esp)
+__acos:
+ fld %st
+ fmul %st
+ fld1
+ fsubp
+ fsqrt
+ fxch %st(1)
+ fpatan
+ ret
+
+.ende:
+.size acos,.ende-acos
+.size acosf,.ende-acosf
+.size acosl,.ende-acosl
diff --git a/mdk-stage1/dietlibc/i386/acosh.S b/mdk-stage1/dietlibc/i386/acosh.S
new file mode 100644
index 000000000..0611c9d31
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/acosh.S
@@ -0,0 +1,18 @@
+.text
+.global acosh
+.type acosh,@function
+
+acosh:
+ fldln2
+ fldl 4(%esp)
+ fld %st(0)
+ fmul %st(0),%st(0)
+ fld1
+ fsubrp %st(0),%st(1)
+ fsqrt
+ faddp %st(0),%st(1)
+ fyl2x
+ ret
+
+.Lende:
+ .size acosh,.Lende-acosh
diff --git a/mdk-stage1/dietlibc/i386/asin.S b/mdk-stage1/dietlibc/i386/asin.S
new file mode 100644
index 000000000..7b0c31407
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/asin.S
@@ -0,0 +1,29 @@
+
+.text
+
+.global asinf,asin,asinl # ,__asin
+ .type asinf,@function
+ .type asin,@function
+ .type asinl,@function
+# .type __asin,@function
+asinf:
+ flds 4(%esp)
+ jmp __asin
+asinl:
+ fldt 4(%esp)
+ jmp __asin
+asin:
+ fldl 4(%esp)
+__asin:
+ fld %st
+ fmul %st
+ fld1
+ fsubp
+ fsqrt
+ fpatan
+ ret
+
+.ende:
+.size asin,.ende-asin
+.size asinf,.ende-asinf
+.size asinl,.ende-asinl
diff --git a/mdk-stage1/dietlibc/i386/asinh.S b/mdk-stage1/dietlibc/i386/asinh.S
new file mode 100644
index 000000000..8c3964392
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/asinh.S
@@ -0,0 +1,18 @@
+.text
+.global asinh
+.type asinh,@function
+
+asinh:
+ fldln2
+ fldl 4(%esp)
+ fld %st(0)
+ fmul %st(0),%st(0)
+ fld1
+ faddp %st(0),%st(1)
+ fsqrt
+ faddp %st(0),%st(1)
+ fyl2x
+ ret
+
+.Lende:
+ .size asinh,.Lende-asinh
diff --git a/mdk-stage1/dietlibc/i386/atan.S b/mdk-stage1/dietlibc/i386/atan.S
new file mode 100644
index 000000000..76513f928
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/atan.S
@@ -0,0 +1,27 @@
+
+.text
+
+.global atanf,atan,atanl
+ .type atanf,@function
+ .type atan,@function
+ .type atanl,@function
+atanf:
+ flds 4(%esp)
+ fld1
+ fpatan
+ ret
+atan:
+ fldl 4(%esp)
+ fld1
+ fpatan
+ ret
+atanl:
+ fldt 4(%esp)
+ fld1
+ fpatan
+ ret
+
+.ende:
+.size atan,.ende-atan
+.size atanf,.ende-atanf
+.size atanl,.ende-atanl
diff --git a/mdk-stage1/dietlibc/i386/atan2.S b/mdk-stage1/dietlibc/i386/atan2.S
new file mode 100644
index 000000000..acf6e03ae
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/atan2.S
@@ -0,0 +1,12 @@
+
+.text
+.type atan2,@function
+.global atan2
+atan2:
+ fldl 4(%esp)
+ fldl 12(%esp)
+ fpatan
+ ret
+
+.ende:
+.size atan2,.ende-atan2
diff --git a/mdk-stage1/dietlibc/i386/atanh.S b/mdk-stage1/dietlibc/i386/atanh.S
new file mode 100644
index 000000000..b75f0fa8e
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/atanh.S
@@ -0,0 +1,19 @@
+.text
+.global atanh
+.type atanh,@function
+
+atanh:
+ fldln2
+ fldl 4(%esp)
+ fld1
+ fld %st(1)
+ fadd %st(1),%st(0)
+ fxch %st(1)
+ fsubp %st(0),%st(2)
+ fdivp %st(0),%st(1)
+ fyl2x
+ fmuls __half
+ ret
+
+.Lende:
+ .size atanh,.Lende-atanh
diff --git a/mdk-stage1/dietlibc/i386/atol.S b/mdk-stage1/dietlibc/i386/atol.S
new file mode 100644
index 000000000..5bd7f2c24
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/atol.S
@@ -0,0 +1,55 @@
+/*
+ Copyright (C) 2001, 2002 Thomas M. Ogrisegg
+
+ This is free software. You can redistribute and
+ modify it under the terms of the GNU General Public
+ Public License.
+
+ atol.S
+ i386 assembler implementation of atoi(3) & atol(3)
+*/
+
+.text
+.globl atoi
+.globl atol
+.type atoi,@function
+.type atol,@function
+
+atoi:
+atol:
+ pushl %esi
+ movl 0x8(%esp), %esi
+ xorl %eax, %eax
+ xorl %edx, %edx
+ xorb %cl, %cl
+.LSpace:
+ lodsb
+ cmpb $0x21, %al
+ jng .LSpace
+ cmpb $'+', %al
+ jz .Lfe5
+ cmpb $'-', %al
+ jnz .Lfe3
+ inc %cl
+ jmp .Lfe5
+.Lfe2:
+ imul $0xa, %edx
+ addl %eax, %edx
+.Lfe5:
+ lodsb
+.Lfe3:
+ cmpb $47, %al
+ jng .Lout
+ subb $('0'), %al
+ cmpb $9, %al
+ jng .Lfe2
+.Lout:
+ movl %edx, %eax
+ or %cl, %cl
+ jz .Lreturn
+ negl %eax
+.Lreturn:
+ popl %esi
+ ret
+.size atoi, . - atoi
+.size atol, . - atol
diff --git a/mdk-stage1/dietlibc/i386/atoll.S b/mdk-stage1/dietlibc/i386/atoll.S
new file mode 100644
index 000000000..093bf762a
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/atoll.S
@@ -0,0 +1,64 @@
+
+.text
+.type atoll,@function
+.global atoll
+
+atoll:
+ movl 4(%esp),%ecx
+ push %edi
+
+ xorl %edi,%edi # sign = 0
+
+ decl %ecx
+.Lspaces:
+ incl %ecx # while ( isspace(*p) ) p++;
+ movb (%ecx),%al
+ cmpb $' ',%al
+ je .Lspaces
+ subb $9,%al
+ cmpb $5,%al
+ jc .Lspaces # c = *p - 9;
+
+ cmpb $'+'-9,%al # if ( c == '+' - 9 ) p++;
+ je .Lpos
+ cmpb $'-'-9,%al # else if ( c == '-' - 9 ) sign = -sign, p++;
+ jne .Lnosign
+ decl %edi
+.Lpos: incl %ecx
+.Lnosign:
+
+ push %ebx
+ push %esi
+ push %ebp
+ movl $10,%ebp
+
+ xorl %esi,%esi # Hi(value) = 0;
+ xorl %eax,%eax # Lo(value) = 0;
+.Lcont: movzbl (%ecx),%ebx # while ( (unsigned) (*p - '0') < 10 )
+ inc %ecx
+ subl $'0',%ebx
+ cmpl %ebp,%ebx
+ jnc .Lfini
+ imull %ebp,%esi # value *= 10,
+ mull %ebp
+ addl %edx,%esi
+ addl %ebx,%eax # value += (*p - '0');
+ adcl $0,%esi
+ jmp .Lcont
+
+.Lfini: xchg %edx,%esi # return sign== 0 ? +value
+ xorl %edi,%eax # sign==-1 ? -value
+ xorl %edi,%edx
+ subl %edi,%eax
+ sbbl %edi,%edx
+
+ pop %ebp
+ pop %esi
+ pop %ebx
+ pop %edi
+ ret
+
+.Lende:
+
+.size atoll,.Lende-atoll
+
diff --git a/mdk-stage1/dietlibc/i386/bind.S b/mdk-stage1/dietlibc/i386/bind.S
new file mode 100644
index 000000000..caff9bb8b
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/bind.S
@@ -0,0 +1,4 @@
+#include <linuxnet.h>
+#include <syscalls.h>
+
+__socketcall(bind,BIND)
diff --git a/mdk-stage1/dietlibc/i386/cbrt.S b/mdk-stage1/dietlibc/i386/cbrt.S
new file mode 100644
index 000000000..9d8aebd1e
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/cbrt.S
@@ -0,0 +1,46 @@
+.text
+
+tab: .byte 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4
+ .byte 4, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9
+ .byte 10,10,11,11,12,12,12,13,13,14,14,14,15,15,15,16
+
+_3: .long 0x40400000
+
+
+.global cbrt
+cbrt:
+ fldl 4(%esp)
+ movw 10(%esp),%ax
+ movb %ah,%ch
+ andw $0x7FFF,%ax
+ jz zero /* cbrt(0) = 0 */
+ pushl %ebx
+ cwd
+ movl $16*3,%ebx /* AX 3FE0 3FF0 4000 4010 */
+ divw %bx /* AX 154 155 155 155 */
+ /* DX 20 0 10 20 */
+ shlw $5,%ax
+ addb %ch,%ch
+ rcrw %ax /* AX 1540 1550 1550 1550 */
+ addw $0x3FF0-0x1550,%ax /* AX 3FE0 3FF0 3FF0 3FF0 */
+ movw %dx,%bx
+ addb tab(%ebx),%al
+ adcb $0,%ah
+ popl %ebx
+ movw %ax,10(%esp)
+ fldl 4(%esp) /* y x */
+
+ movl $4,%ecx
+lop:
+ fld %st(0) /* y y x */
+ fmul %st(0),%st(0) /* y^2 y x */
+ fdivr %st(2),%st(0) /* x/y^2 y x */
+ fadd %st(1),%st(0) /* x/y^2+y y x */
+ faddp /* x/y^2+2y x */
+ fdivs _3 /* y' x */
+ loop lop
+
+ fstp %st(1) /* y' */
+zero:
+ ret
+
diff --git a/mdk-stage1/dietlibc/i386/ceil.S b/mdk-stage1/dietlibc/i386/ceil.S
new file mode 100644
index 000000000..e6a4e989c
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/ceil.S
@@ -0,0 +1,44 @@
+.text
+
+.global ceilf,ceil,ceill,__flcetr
+ .type ceilf,@function
+ .type ceil,@function
+ .type ceill,@function
+ .type __flcetr,@function
+
+ceilf:
+ flds 4(%esp)
+ movb $0x08,%ah
+ jmp __flcetr
+
+ceill:
+ fldt 4(%esp)
+ movb $0x08,%ah
+ jmp __flcetr
+
+ceil:
+ fldl 4(%esp)
+ movb $0x08,%ah
+
+# Wspolny kod dla funkcji floor, ceil i trunc
+# W ah maska bitow 11 i 10 rejestru sterowania koprocesora
+__flcetr:
+ xorl %ecx,%ecx # wyzerowanie rejestru
+ movb %ah,%ch # i utworzenie maski w cx
+ pushl %eax # krotsze niz subl $4,%esp
+ fstcw (%esp)
+ movw (%esp),%ax
+ andb $0x03,%ah # wyzerowanie bitow 11 i 10
+ orl %ecx,%eax # ustawienie bitow z maski
+ movw %ax,2(%esp)
+ fldcw 2(%esp)
+ frndint
+ fldcw (%esp) # odtworzenie rejestru sterowania
+ popl %eax # i polozenia stosu
+ ret
+
+.Lende:
+.size ceil,.Lende-ceil
+.size ceill,.Lende-ceill
+.size ceilf,.Lende-ceilf
+.size flcetr,.Lende-__flcetr
diff --git a/mdk-stage1/dietlibc/i386/clone.S b/mdk-stage1/dietlibc/i386/clone.S
index ac02eb468..ea43bc2e2 100644
--- a/mdk-stage1/dietlibc/i386/clone.S
+++ b/mdk-stage1/dietlibc/i386/clone.S
@@ -1,17 +1,21 @@
-#include <asm/unistd.h>
+#include "syscalls.h"
+#include <errno.h>
+#include "PIC.h"
.text
+.type clone,@function
.weak clone
clone:
+.type __clone,@function
.global __clone
__clone:
+ mov $-EINVAL, %eax
+
movl 4(%esp), %ecx /* have non null thread_funcion */
- testl %ecx, %ecx
- je .Lclone_error
+ jecxz .Lclone_error
movl 8(%esp), %ecx /* have non null child_stack pointer */
- testl %ecx, %ecx
- je .Lclone_error
+ jecxz .Lclone_error
/* put the parameter on thread stack */
subl $8, %ecx
@@ -31,9 +35,7 @@ __clone:
testl %eax, %eax
jl .Lclone_error
- je .Lstart_thread
- ret
-
+ jne .Lreturn
.Lstart_thread:
xorl %ebp,%ebp
call *%ebx
@@ -43,9 +45,16 @@ __clone:
.Lclone_error:
negl %eax
pushl %eax
+#ifdef PIC
+ pushl %ebx
+ PIC_INIT
+ call __errno_location@PLT
+ popl %ebx
+#else
call __errno_location
+#endif
popl %ecx
movl %ecx, (%eax)
- xorl %eax, %eax
- decl %eax
+ orl $-1, %eax
+.Lreturn:
ret
diff --git a/mdk-stage1/dietlibc/i386/connect.S b/mdk-stage1/dietlibc/i386/connect.S
new file mode 100644
index 000000000..a295a8814
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/connect.S
@@ -0,0 +1,4 @@
+#include <linuxnet.h>
+#include <syscalls.h>
+
+__socketcall(connect,CONNECT)
diff --git a/mdk-stage1/dietlibc/i386/copysign.S b/mdk-stage1/dietlibc/i386/copysign.S
new file mode 100644
index 000000000..3a495efee
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/copysign.S
@@ -0,0 +1,18 @@
+
+.text
+.type copysign,@function
+.global copysign
+
+# double copysign ( double value, double sign );
+
+copysign:
+ movb 12+7(%esp),%al
+ movb 4+7(%esp),%ah
+ andw $0x7F80,%ax
+ orb %ah,%al
+ movb 4+7(%esp),%al
+ fldl 4(%esp)
+ ret
+
+.ende:
+.size copysign,.ende-copysign
diff --git a/mdk-stage1/dietlibc/i386/cos.S b/mdk-stage1/dietlibc/i386/cos.S
new file mode 100644
index 000000000..f95c81ca7
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/cos.S
@@ -0,0 +1,35 @@
+.text
+
+.global cosf,cos,cosl
+.type cosf,@function
+.type cos,@function
+.type cosl,@function
+
+cosf:
+ flds 4(%esp)
+ jmp 1f
+cos:
+ fldl 4(%esp)
+1:
+ fcos
+ fnstsw %ax
+ testb $0x04, %ah
+ je 3f
+ fldpi
+ fadd %st
+ fxch %st(1)
+2: fprem1
+ fnstsw %ax
+ testb $0x04, %ah
+ jne 2b
+ fstp %st(1)
+ fcos
+3: ret
+cosl:
+ fldt 4(%esp)
+ jmp 1b
+
+.Lende:
+.size cos,.Lende-cos
+.size cosl,.Lende-cosl
+.size cosf,.Lende-cosf
diff --git a/mdk-stage1/dietlibc/i386/cosh.S b/mdk-stage1/dietlibc/i386/cosh.S
new file mode 100644
index 000000000..f6a33704d
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/cosh.S
@@ -0,0 +1,29 @@
+
+.text
+.type cosh,@function
+.global cosh
+
+cosh: # note: exp(x) = 2^(x*log2(e))
+ fldl2e
+ fmull 4(%esp) # x*log2(e)
+ fld %st(0) # x*log2(e) x*log2(e)
+ frndint # int(x*log2(e)) x*log2(e)
+ fxch # x*log2(e) int(x*log2(e))
+ fsub %st(1),%st(0) # frac(x*log2(e)) int(x*log2(e))
+ f2xm1 # 2^(fract(x*log2(e)))-1 int(x*log2(e))
+ fld1 # 1 2^(fract(x*log2(e)))-1 int(x*log2(e))
+ faddp %st(0),%st(1) # 2^(fract(x*log2(e))) int(x*log2(e))
+ fscale # 2^(x*log2(e)) int(x*log2(e))
+ fstp %st(1) # 2^(x*log2(e))
+
+# now we have y = exp(x), but cosh(x) = (y + 1/y) * 0.5
+
+ fld1
+ fdiv %st(1),%st(0)
+ faddp
+ fmuls __half
+ ret
+
+.Lende:
+
+.size cosh,.ende-cosh
diff --git a/mdk-stage1/dietlibc/i386/dyn_syscalls.S b/mdk-stage1/dietlibc/i386/dyn_syscalls.S
new file mode 100644
index 000000000..c4fd2fff5
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/dyn_syscalls.S
@@ -0,0 +1,282 @@
+/*
+ * dynamic unified-syscalls
+ * Olaf Dreesen
+ */
+
+#include "../syscalls.s/environ.S"
+#include "../syscalls.s/errno.S"
+
+#include <dietfeatures.h>
+#include "syscalls.h"
+#include "PIC.h"
+
+/* ok now include all syscalls.s (*.S) and sysdep *.S */
+
+#include "mmap.S"
+
+/* here on i386 I had split them some pre- some post-unified-syscall,
+ * because the jumps pre-u.s.c. have only a 1 byte displacement. the first
+ * post-u.s.c. have also 1 byte dsplacement the rest a 4 byte.
+ * this pre/post split saves about 250 byte of code ....
+ *
+ * Please put additional syscalls AFTER the post-u.s.c.
+ * or try to not break the savings :) */
+
+#include "select.S"
+
+#include "../syscalls.s/fork.S"
+#include "../syscalls.s/read.S"
+#include "../syscalls.s/write.S"
+#include "../syscalls.s/open.S"
+#include "../syscalls.s/close.S"
+#include "../syscalls.s/waitpid.S"
+
+#include "../syscalls.s/getgid.S"
+#include "../syscalls.s/getpgid.S"
+#include "../syscalls.s/getpid.S"
+#include "../syscalls.s/getppid.S"
+#include "../syscalls.s/getuid.S"
+#include "../syscalls.s/kill.S"
+#include "../syscalls.s/ioctl.S"
+#include "../syscalls.s/_llseek.S"
+#include "../syscalls.s/lseek.S"
+#include "../syscalls.s/lstat.S"
+#include "../syscalls.s/lstat64.S"
+#include "../syscalls.s/mkdir.S"
+#include "../syscalls.s/mprotect.S"
+#include "../syscalls.s/nanosleep.S"
+#include "../syscalls.s/pipe.S"
+#include "../syscalls.s/poll.S"
+#include "../syscalls.s/readv.S"
+#include "../syscalls.s/stat.S"
+#include "../syscalls.s/stat64.S"
+#include "../syscalls.s/truncate.S"
+#include "../syscalls.s/umask.S"
+#include "../syscalls.s/wait4.S"
+#include "../syscalls.s/writev.S"
+#include "../syscalls.s/__getpagesize.S"
+
+/* OK this is basicaly unified.S */
+.text
+.type __unified_syscall_256,@function
+__unified_syscall_256:
+ movzwl %ax, %eax
+ jmp .L23
+.L22:
+.size __unified_syscall_256,.L22-__unified_syscall_256
+.type exit,@function
+.weak exit
+exit:
+.type _exit,@function
+.global _exit
+_exit:
+__exit:
+ mov $__NR_exit, %al
+__unified_syscall:
+ movzbl %al, %eax
+.L23:
+ push %edi
+ push %esi
+ push %ebx
+ movl %esp,%edi
+ movl 0x10(%edi),%ebx
+ movl 0x14(%edi),%ecx
+ movl 0x18(%edi),%edx
+ movl 0x1c(%edi),%esi
+ movl 0x20(%edi),%edi
+ int $0x80
+ cmp $-124,%eax
+ jbe .Lnoerror
+ neg %eax
+
+ /* PIC-code Ohhhhh My. */
+ push %eax
+ PIC_INIT
+ call __errno_location@PLT
+ popl %ebx
+ movl %ebx,(%eax)
+ orl $-1,%eax
+.Lnoerror:
+ pop %ebx
+ pop %esi
+ pop %edi
+#include "dietuglyweaks.h"
+ ret
+
+#include "../syscalls.s/__pread.S"
+#include "../syscalls.s/__pwrite.S"
+#include "../syscalls.s/__reboot.S"
+#include "../syscalls.s/access.S"
+#include "../syscalls.s/adjtimex.S"
+#include "../syscalls.s/brk.S"
+#include "../syscalls.s/chdir.S"
+#include "../syscalls.s/chmod.S"
+#include "../syscalls.s/chown.S"
+#include "../syscalls.s/chroot.S"
+#include "../syscalls.s/dup.S"
+#include "../syscalls.s/dup2.S"
+#include "../syscalls.s/execve.S"
+#include "../syscalls.s/fchdir.S"
+#include "../syscalls.s/fchmod.S"
+#include "../syscalls.s/fchown.S"
+#include "../syscalls.s/fcntl.S"
+#include "../syscalls.s/flock.S"
+#include "../syscalls.s/fstat.S"
+#include "../syscalls.s/fstat64.S"
+#include "../syscalls.s/fstatfs.S"
+#include "../syscalls.s/fsync.S"
+#include "../syscalls.s/fdatasync.S"
+#include "../syscalls.s/ftruncate.S"
+#include "../syscalls.s/getcwd.S"
+#include "../syscalls.s/getdents.S"
+#include "../syscalls.s/getdents64.S"
+#include "../syscalls.s/getegid.S"
+#include "../syscalls.s/geteuid.S"
+#include "../syscalls.s/getgroups.S"
+#include "../syscalls.s/getitimer.S"
+#include "../syscalls.s/getpriority.S"
+#include "../syscalls.s/getresgid.S"
+#include "../syscalls.s/getresuid.S"
+#include "../syscalls.s/getrlimit.S"
+#include "../syscalls.s/getrusage.S"
+#include "../syscalls.s/getsid.S"
+#include "../syscalls.s/gettimeofday.S"
+#include "../syscalls.s/ioperm.S"
+#include "../syscalls.s/iopl.S"
+#include "../syscalls.s/ipc.S"
+#include "../syscalls.s/lchown.S"
+#include "../syscalls.s/link.S"
+#include "../syscalls.s/mknod.S"
+#include "../syscalls.s/mlock.S"
+#include "../syscalls.s/mlockall.S"
+#include "../syscalls.s/mount.S"
+#include "../syscalls.s/mremap.S"
+#include "../syscalls.s/munlockall.S"
+#include "../syscalls.s/munmap.S"
+#include "../syscalls.s/n_sigaction.S"
+#include "../syscalls.s/n_sigpending.S"
+#include "../syscalls.s/n_sigprocmask.S"
+#include "../syscalls.s/n_sigsuspend.S"
+#include "../syscalls.s/nice.S"
+#include "../syscalls.s/pause.S"
+#include "../syscalls.s/personality.S"
+#include "../syscalls.s/query_module.S"
+#include "../syscalls.s/init_module.S"
+#include "../syscalls.s/delete_module.S"
+#include "../syscalls.s/create_module.S"
+#include "../syscalls.s/readlink.S"
+#include "../syscalls.s/rename.S"
+#include "../syscalls.s/rmdir.S"
+#include "../syscalls.s/rt_sigaction.S"
+#include "../syscalls.s/rt_sigpending.S"
+#include "../syscalls.s/rt_sigprocmask.S"
+#include "../syscalls.s/rt_sigqueueinfo.S"
+#include "../syscalls.s/rt_sigsuspend.S"
+#include "../syscalls.s/rt_sigtimedwait.S"
+#include "../syscalls.s/sched_get_priority_max.S"
+#include "../syscalls.s/sched_get_priority_min.S"
+#include "../syscalls.s/sched_getparam.S"
+#include "../syscalls.s/sched_getscheduler.S"
+#include "../syscalls.s/sched_rr_get_interval.S"
+#include "../syscalls.s/sched_setparam.S"
+#include "../syscalls.s/sched_setscheduler.S"
+#include "../syscalls.s/sched_yield.S"
+#include "../syscalls.s/sendfile.S"
+#include "../syscalls.s/setdomainname.S"
+#include "../syscalls.s/setfsgid.S"
+#include "../syscalls.s/setfsuid.S"
+#include "../syscalls.s/setgid.S"
+#include "../syscalls.s/setgroups.S"
+#include "../syscalls.s/sethostname.S"
+#include "../syscalls.s/setitimer.S"
+#include "../syscalls.s/setpgid.S"
+#include "../syscalls.s/setpriority.S"
+#include "../syscalls.s/setregid.S"
+#include "../syscalls.s/setresgid.S"
+#include "../syscalls.s/setresuid.S"
+#include "../syscalls.s/setreuid.S"
+#include "../syscalls.s/setrlimit.S"
+#include "../syscalls.s/setsid.S"
+#include "../syscalls.s/setuid.S"
+#include "../syscalls.s/sigaltstack.S"
+#include "../syscalls.s/statfs.S"
+#include "../syscalls.s/stime.S"
+#include "../syscalls.s/swapoff.S"
+#include "../syscalls.s/swapon.S"
+#include "../syscalls.s/symlink.S"
+#include "../syscalls.s/sync.S"
+#include "../syscalls.s/sysctl.S"
+#include "../syscalls.s/sysinfo.S"
+#include "../syscalls.s/syslog.S"
+#include "../syscalls.s/time.S"
+#include "../syscalls.s/times.S"
+#include "../syscalls.s/umount.S"
+#include "../syscalls.s/umount2.S"
+#include "../syscalls.s/uname.S"
+#include "../syscalls.s/unlink.S"
+#include "../syscalls.s/utime.S"
+#include "../syscalls.s/vhangup.S"
+
+#include "../syscalls.s/chown32.S"
+#include "../syscalls.s/fchown32.S"
+#include "../syscalls.s/getegid32.S"
+#include "../syscalls.s/geteuid32.S"
+#include "../syscalls.s/getgid32.S"
+#include "../syscalls.s/getgroups32.S"
+#include "../syscalls.s/getresgid32.S"
+#include "../syscalls.s/getuid32.S"
+#include "../syscalls.s/lchown32.S"
+#include "../syscalls.s/setfsgid32.S"
+#include "../syscalls.s/setfsuid32.S"
+#include "../syscalls.s/setgid32.S"
+#include "../syscalls.s/setregid32.S"
+#include "../syscalls.s/setresgid32.S"
+#include "../syscalls.s/setreuid32.S"
+#include "../syscalls.s/setuid32.S"
+#include "../syscalls.s/alarm.S"
+#include "../syscalls.s/ptrace.S"
+#include "../syscalls.s/truncate64.S"
+#include "../syscalls.s/ftruncate64.S"
+#include "../syscalls.s/epoll_create.S"
+#include "../syscalls.s/epoll_ctl.S"
+#include "../syscalls.s/epoll_wait.S"
+
+#undef __PIC__
+#undef __socketcall
+/* oh what a kludge! */
+#define socketcall .Lsocketcall
+#include "../i386/send.S"
+#include "../i386/recv.S"
+#include "../i386/socket.S"
+#include "../i386/accept.S"
+#include "../i386/shutdown.S"
+#include "../i386/socketpair.S"
+#include "../i386/setsockopt.S"
+#include "../i386/sendto.S"
+#include "../i386/sendmsg.S"
+#include "../i386/recvmsg.S"
+#include "../i386/recvfrom.S"
+#include "../i386/listen.S"
+#include "../i386/getsockopt.S"
+#include "../i386/getsockname.S"
+#include "../i386/getpeername.S"
+#include "../i386/connect.S"
+#include "../i386/bind.S"
+#undef socketcall
+.Lsocketcall:
+#include "../i386/socketcall.S"
+#define __PIC__
+#undef __socketcall
+
+
+/* so now this was the last u.s.c. */
+
+/* other asm-files ... */
+#define PIC
+
+#define _exit __exit
+#include "clone.S"
+#undef _exit
+
+#include "__longjmp.S"
+#include "setjmp.S"
diff --git a/mdk-stage1/dietlibc/i386/exp.S b/mdk-stage1/dietlibc/i386/exp.S
new file mode 100644
index 000000000..6c82128e4
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/exp.S
@@ -0,0 +1,35 @@
+.text
+
+.global expf,exp,expl,__finexp
+ .type expf,@function
+ .type exp,@function
+ .type expl,@function
+ .type __finexp,@function
+expf:
+ fldl2e
+ fmuls 4(%esp)
+ jmp __finexp
+expl:
+ fldl2e
+ fldt 4(%esp)
+ fmulp
+ jmp __finexp
+exp:
+ fldl2e
+ fmull 4(%esp)
+__finexp:
+ fst %st(1)
+ frndint
+ fst %st(2)
+ fsubrp
+ f2xm1
+ fld1
+ faddp
+ fscale
+ ret
+
+.Lende:
+.size exp,.Lende-exp
+.size expl,.Lende-expl
+.size expf,.Lende-expf
+.size __finexp,.Lende-__finexp
diff --git a/mdk-stage1/dietlibc/i386/exp10.S b/mdk-stage1/dietlibc/i386/exp10.S
new file mode 100644
index 000000000..6223e5f85
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/exp10.S
@@ -0,0 +1,27 @@
+
+.text
+.type exp10,@function
+.global exp10
+.type pow10,@function
+.global pow10
+
+
+pow10:
+exp10: # note: 10^(x) = 2^(x*log2(10))
+ fldl2t
+ fmull 4(%esp) # x*log2(10)
+ fld %st(0) # x*log2(10) x*log2(10)
+ frndint # int(x*log2(10)) x*log2(10)
+ fxch # x*log2(10) int(x*log2(10))
+ fsub %st(1),%st(0) # frac(x*log2(10)) int(x*log2(10))
+ f2xm1 # 2^(fract(x*log2(10)))-1 int(x*log2(10))
+ fld1 # 1 2^(fract(x*log2(10)))-1 int(x*log2(10))
+ faddp %st(0),%st(1) # 2^(fract(x*log2(10))) int(x*log2(10))
+ fscale # 2^(x*log2(10)) int(x*log2(10))
+ fstp %st(1) # 2^(x*log2(10))
+ ret
+
+.ende:
+
+.size exp10,.ende-exp10
+.size pow10,.ende-pow10
diff --git a/mdk-stage1/dietlibc/i386/exp2.S b/mdk-stage1/dietlibc/i386/exp2.S
new file mode 100644
index 000000000..d5389a22e
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/exp2.S
@@ -0,0 +1,18 @@
+.text
+.type exp2,@function
+.global exp2
+exp2: # note: exp2(x) = 2^x
+ fldl 4(%esp) # x
+ fld %st(0) # x x
+ frndint # int(x) x
+ fxch # x int(x)
+ fsub %st(1),%st(0) # frac(x) int(x)
+ f2xm1 # 2^(fract(x))-1 int(x)
+ fld1 # 1 2^(fract(x))-1 int(x)
+ faddp %st(0),%st(1) # 2^(fract(x)) int(x)
+ fscale # 2^x int(x)
+ fstp %st(1) # 2^x
+ ret
+
+.ende:
+.size exp2,.ende-exp2
diff --git a/mdk-stage1/dietlibc/i386/expm1.S b/mdk-stage1/dietlibc/i386/expm1.S
new file mode 100644
index 000000000..677f4723f
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/expm1.S
@@ -0,0 +1,23 @@
+.text
+.type expm1,@function
+.global expm1
+expm1: # note: exp(x) = 2^(x*log2(e))
+ fldl2e
+ fmull 4(%esp) # x*log2(e)
+ fld %st(0) # x*log2(e) x*log2(e)
+ frndint # int(x*log2(e)) x*log2(e)
+ fxch # x*log2(e) int(x*log2(e))
+ fsub %st(1),%st(0) # frac(x*log2(e)) int(x*log2(e))
+ f2xm1 # 2^(fract(x*log2(e)))-1 int(x*log2(e))
+ fscale # 2^(x*log2(e))-2^int(x*log2(e)) int(x*log2(e))
+ fxch # int(x*log2(e)) 2^(x*log2(e))-2^int(x*log2(e))
+ fld1 # 1 int(x*log2(e)) 2^(x*log2(e))-2^int(x*log2(e))
+ fscale # 2^int(x*log2(e)) int(x*log2(e)) 2^(x*log2(e))-2^int(x*log2(e))
+ fstp %st(1) # 2^int(x*log2(e)) 2^(x*log2(e))-2^int(x*log2(e))
+ fld1 # 1 2^int(x*log2(e)) 2^(x*log2(e))-2^int(x*log2(e))
+ fsubrp %st(1) # 2^int(x*log2(e))-1 2^(x*log2(e))-2^int(x*log2(e))
+ faddp %st(1)
+ ret
+
+.ende:
+.size expm1,.ende-expm1
diff --git a/mdk-stage1/dietlibc/i386/fabs.S b/mdk-stage1/dietlibc/i386/fabs.S
new file mode 100644
index 000000000..d9c1c2212
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/fabs.S
@@ -0,0 +1,11 @@
+
+.text
+.type fabs,@function
+.global fabs
+fabs:
+ fldl 4(%esp)
+ fabs
+ ret
+
+.ende:
+.size fabs,.ende-fabs
diff --git a/mdk-stage1/dietlibc/i386/floor.S b/mdk-stage1/dietlibc/i386/floor.S
new file mode 100644
index 000000000..af26d0c94
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/floor.S
@@ -0,0 +1,26 @@
+.text
+
+.global floorf,floor,floorl
+ .type floorf,@function
+ .type floor,@function
+ .type floorf,@function
+
+floorf:
+ flds 4(%esp)
+ movb $0x04,%ah
+ jmp __flcetr
+
+floor:
+ fldl 4(%esp)
+ movb $0x04,%ah
+ jmp __flcetr
+
+floorl:
+ fldt 4(%esp)
+ movb $0x04,%ah
+ jmp __flcetr
+
+.Lende:
+.size floor,.Lende-floor
+.size floorl,.Lende-floorl
+.size floorf,.Lende-floorf
diff --git a/mdk-stage1/dietlibc/i386/fmod.S b/mdk-stage1/dietlibc/i386/fmod.S
new file mode 100644
index 000000000..5bf4c06ab
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/fmod.S
@@ -0,0 +1,37 @@
+.text
+.type fmod,@function
+.type fmodf,@function
+.type fmodl,@function
+.type __fmod2pi,@function
+.global fmod, fmodl, fmodf, __fmod2pi
+
+__fmod2pi:
+ fldpi
+ fadd %st(0)
+ fxch
+ jmp .Lfmod
+
+fmodf:
+ flds 8(%esp) # y
+ flds 4(%esp) # x
+ jmp .Lfmod
+fmod:
+ fldl 12(%esp)
+ fldl 4(%esp)
+.Lfmod:
+ fprem
+ fstsw %ax
+ sahf
+ jp .Lfmod
+ ret
+
+fmodl:
+ fldt 16(%esp)
+ fldt 4(%esp)
+ jmp .Lfmod
+
+
+.ende:
+.size fmod,.ende-fmod
+.size fmodl,.ende-fmodl
+.size fmodf,.ende-fmodf
diff --git a/mdk-stage1/dietlibc/i386/getenv.S b/mdk-stage1/dietlibc/i386/getenv.S
new file mode 100644
index 000000000..dafbf37ee
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/getenv.S
@@ -0,0 +1,48 @@
+#include "PIC.h"
+
+.text
+.global getenv
+.type getenv,@function
+getenv:
+ pushl %esi
+ pushl %edi
+ movl 0xc(%esp), %edi
+ cld
+ movl %edi, %edx
+ xorl %eax, %eax
+ leal -1(%eax), %ecx
+ repnz scasb
+ not %ecx
+ dec %ecx
+ pushl %ecx
+ movl (%edx), %ecx
+
+ GET_1VAR environ, %esi # non-PIC: movl environ, %esi
+ jmp .Lloop
+
+.Lprepare:
+ movl (%edx), %ecx
+ movl %eax, %esi
+.Lloop:
+ lodsl
+ or %eax, %eax
+ jz .Lout
+ cmpb %cl, (%eax)
+ jnz .Lloop
+
+ movl %edx, %edi
+ xchg %esi, %eax
+ movl (%esp), %ecx
+ repz cmpsb
+ jne .Lprepare
+ or %ecx, %ecx
+ jnz .Lprepare
+ cmpb $'=', (%esi)
+ jne .Lprepare
+ leal 0x1(%esi), %eax
+.Lout:
+ popl %ecx
+ popl %edi
+ popl %esi
+ ret
+.size getenv, . - getenv
diff --git a/mdk-stage1/dietlibc/i386/getpeername.S b/mdk-stage1/dietlibc/i386/getpeername.S
new file mode 100644
index 000000000..833322941
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/getpeername.S
@@ -0,0 +1,4 @@
+#include <linuxnet.h>
+#include <syscalls.h>
+
+__socketcall(getpeername,GETPEERNAME)
diff --git a/mdk-stage1/dietlibc/i386/getsockname.S b/mdk-stage1/dietlibc/i386/getsockname.S
new file mode 100644
index 000000000..f0618481c
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/getsockname.S
@@ -0,0 +1,4 @@
+#include <linuxnet.h>
+#include <syscalls.h>
+
+__socketcall(getsockname,GETSOCKNAME)
diff --git a/mdk-stage1/dietlibc/i386/getsockopt.S b/mdk-stage1/dietlibc/i386/getsockopt.S
new file mode 100644
index 000000000..23d7c2470
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/getsockopt.S
@@ -0,0 +1,4 @@
+#include <linuxnet.h>
+#include <syscalls.h>
+
+__socketcall(getsockopt,GETSOCKOPT)
diff --git a/mdk-stage1/dietlibc/i386/htonl.S b/mdk-stage1/dietlibc/i386/htonl.S
new file mode 100644
index 000000000..f3732d16a
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/htonl.S
@@ -0,0 +1,13 @@
+.text
+.global htonl
+.type htonl,@function
+.global ntohl
+.type ntohl,@function
+
+htonl:
+ntohl:
+ movl 4(%esp),%eax
+ xchgb %al,%ah
+ rorl $16,%eax
+ xchgb %al,%ah
+ ret
diff --git a/mdk-stage1/dietlibc/i386/htons.S b/mdk-stage1/dietlibc/i386/htons.S
new file mode 100644
index 000000000..367d6d03c
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/htons.S
@@ -0,0 +1,11 @@
+.text
+.global htons
+.type htons,@function
+.global ntohs
+.type ntohs,@function
+
+htons:
+ntohs:
+ movzwl 4(%esp),%eax
+ xchgb %al,%ah
+ ret
diff --git a/mdk-stage1/dietlibc/i386/hypot.S b/mdk-stage1/dietlibc/i386/hypot.S
new file mode 100644
index 000000000..730b2c5c9
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/hypot.S
@@ -0,0 +1,15 @@
+
+.text
+.type hypot,@function
+.global hypot
+hypot:
+ fldl 4(%esp)
+ fmul %st(0),%st(0)
+ fldl 12(%esp)
+ fmul %st(0),%st(0)
+ faddp
+ fsqrt
+ ret
+
+.ende:
+.size hypot,.ende-hypot
diff --git a/mdk-stage1/dietlibc/i386/ilogb.S b/mdk-stage1/dietlibc/i386/ilogb.S
new file mode 100644
index 000000000..3bebd88ba
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/ilogb.S
@@ -0,0 +1,23 @@
+#
+# int ilogb ( double x );
+#
+# returns (int) log2 (fabs(x)) for x!=0
+# returns MIN_INT for x==0
+#
+
+.text
+.global ilogb
+.type ilogb,@function
+
+ilogb:
+ movl 8(%esp),%eax
+ addl %eax,%eax
+ jz .Lzero
+ shrl $21,%eax
+ subl $1023,%eax
+ ret
+
+.Lzero:
+ stc
+ rcrl %eax
+ ret
diff --git a/mdk-stage1/dietlibc/i386/ipow.S b/mdk-stage1/dietlibc/i386/ipow.S
new file mode 100644
index 000000000..cca6a0ce1
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/ipow.S
@@ -0,0 +1,27 @@
+#
+# This is not standard, but often you only need such this function
+# which is much shorter than the generic pow() function.
+#
+# double ipow ( double mant, int expo );
+#
+
+.text
+.global ipow
+.type ipow,@function
+
+ipow: fld1
+ movl 12(%esp),%ecx
+ fldl 4(%esp)
+ and %ecx,%ecx
+ jns .Lstart
+ negl %ecx
+ fdivr %st(1),%st(0)
+ jmp .Lstart
+
+.Lnext: fmul %st(0),%st(0)
+.Lstart:shrl %ecx
+ jnc .Lnomul
+ fmul %st(0),%st(1)
+.Lnomul:jnz .Lnext
+ fcomp
+ ret
diff --git a/mdk-stage1/dietlibc/i386/isleap.S b/mdk-stage1/dietlibc/i386/isleap.S
new file mode 100644
index 000000000..28d1ee0ce
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/isleap.S
@@ -0,0 +1,28 @@
+.text
+.globl __isleap
+.type __isleap,@function
+
+__isleap:
+ movl 4(%esp),%eax
+ testb $3,%al
+ jne .Lretzero
+#if 1
+ movb $100,%cl /* this works only for 0 a.D. ... 25599 a.C. */
+ divb %cl
+ andb %ah,%ah
+#else
+ cltd /* This works for 2147483648 b.C. ... 2147483647 a.C. */
+ movl $100,%ecx
+ divl %ecx
+ andl %edx,%edx
+#endif
+ jne .Lretone
+ testb $3,%al
+ jne .Lretzero
+.Lretone: xorl %eax,%eax
+ incl %eax
+ ret
+
+.Lretzero:xorl %eax,%eax
+ ret
+
diff --git a/mdk-stage1/dietlibc/i386/ldexp.S b/mdk-stage1/dietlibc/i386/ldexp.S
new file mode 100644
index 000000000..51d9bae89
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/ldexp.S
@@ -0,0 +1,28 @@
+.text
+.global ldexpf,ldexp,ldexpl
+ .type ldexpf,@function
+ .type ldexp,@function
+ .type ldexpl,@function
+
+ldexpf:
+ fildl 8(%esp)
+ flds 4(%esp)
+ fscale
+ ret
+
+ldexp:
+ fildl 12(%esp)
+ fldl 4(%esp)
+ fscale
+ ret
+
+ldexpl:
+ fildl 16(%esp)
+ fldt 4(%esp)
+ fscale
+ ret
+
+.ende:
+.size ldexpl,.ende-ldexpl
+.size ldexp,ldexpl-ldexp
+.size ldexpf,ldexp-ldexpf
diff --git a/mdk-stage1/dietlibc/i386/libm2.S b/mdk-stage1/dietlibc/i386/libm2.S
new file mode 100644
index 000000000..91c4437cd
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/libm2.S
@@ -0,0 +1,643 @@
+.text
+#d.half:
+# .long 0x3f000000 # 1/2
+#d.log1p:
+# .long 0x3ed413cc # < sqrt(2)-1-2^(-25)
+
+.global fabsf,fabs,fabsl
+ .type fabsf,@function
+ .type fabs,@function
+ .type fabsl,@function
+fabsf:
+ flds 4(%esp)
+ fabs
+ ret
+fabs:
+ fldl 4(%esp)
+ fabs
+ ret
+fabsl:
+ fldt 4(%esp)
+ fabs
+ ret
+
+.global sincosf,sincos,sincosl
+.type sincosf,@function
+.type sincos,@function
+.type sincosl,@function
+# void sincos ( double x, double* sinx, double* cosx );
+
+sincosf:
+ flds 4(%esp)
+ call __fmod2pi
+ movl 12(%esp),%eax
+ movl 8(%esp),%ecx
+ fsincos
+ fstps (%eax)
+ fstps (%ecx)
+ ret
+sincos:
+ fldl 4(%esp)
+ call __fmod2pi
+ movl 16(%esp),%eax
+ movl 12(%esp),%ecx
+ fsincos
+ fstpl (%eax)
+ fstpl (%ecx)
+ ret
+sincosl:
+ fldt 4(%esp)
+ call __fmod2pi
+ movl 20(%esp),%eax
+ movl 16(%esp),%ecx
+ fsincos
+ fstpt (%eax)
+ fstpt (%ecx)
+ ret
+
+.global tanf,tan,tanl
+.type tanf,@function
+.type tan,@function
+.type tanl,@function
+tanf:
+ flds 4(%esp)
+ jmp __tan
+tan:
+ fldl 4(%esp)
+__tan:
+ call __fmod2pi
+ fsincos
+ fdivrp
+ ret
+tanl:
+ fldt 4(%esp)
+ jmp __tan
+
+.global atan2f,atan2,atan2l
+ .type atan2f,@function
+ .type atan2,@function
+ .type atan2l,@function
+atan2f:
+ flds 4(%esp)
+ flds 8(%esp)
+ fpatan
+ ret
+atan2l:
+ fldt 4(%esp)
+ fldt 16(%esp)
+ fpatan
+ ret
+atan2:
+ fldl 4(%esp)
+ fldl 12(%esp)
+ fpatan
+ ret
+
+.global cbrtf,cbrt,cbrtl
+ .type cbrtf,@function
+ .type cbrt,@function
+ .type cbrtl,@function
+cbrtf:
+ flds 4(%esp)
+ jmp __cbrt
+cbrtl:
+ fldt 4(%esp)
+ jmp __cbrt
+cbrt:
+ fldl 4(%esp)
+# fldt 1/3
+__cbrt:
+ pushl $0x00003ffd # yes, this method of loading 1/3
+ pushl $0xaaaaaaaa # is shorter than keeping the data
+ pushl $0xaaaaaaab # separate
+ fldt (%esp)
+ addl $12,%esp
+ fxch # st(0)=x, st(1)=1/3
+ ftst
+ fstsw %ax
+ sahf
+ jz 1f
+ jnc finpow
+ fchs
+ call finpow
+ fchs
+1: ret
+
+# x^y; st(0)=x, st(1)=y (x > 0)
+finpow:
+ fyl2x
+ jmp __finexp
+
+.global exp2f,exp2,exp2l
+ .type exp2f,@function
+ .type exp2,@function
+ .type exp2l,@function
+exp2f:
+ flds 4(%esp)
+ jmp __finexp
+exp2:
+ fldl 4(%esp)
+ jmp __finexp
+exp2l:
+ fldt 4(%esp)
+ jmp __finexp
+
+.global exp10f,exp10,exp10l #,pow10f,pow10,pow10l
+ .type exp10f,@function
+ .type exp10,@function
+ .type exp10l,@function
+# .type pow10f,@function
+# .type pow10,@function
+# .type pow10l,@function
+exp10f:
+#pow10f:
+ fldl2t
+ fmuls 4(%esp)
+ jmp __finexp
+exp10:
+#pow10:
+ fldl2t
+ fmull 4(%esp)
+ jmp __finexp
+exp10l:
+#pow10l:
+ fldl2t
+ fldt 4(%esp)
+ fmulp
+ jmp __finexp
+
+# exp(x)-1
+.global expm1f,expm1,expm1l
+ .type expm1f,@function
+ .type expm1,@function
+ .type expm1l,@function
+expm1f:
+ fldl2e
+ fmuls 4(%esp)
+ jmp finem1
+expm1l:
+ fldl2e
+ fldt 4(%esp)
+ fmulp
+ jmp finem1
+expm1:
+ fldl2e
+ fmull 4(%esp)
+# -1 <= st <= 1 ?
+finem1:
+ fst %st(1) # st(1)=st(0)
+ fabs
+ fld1
+ fcompp
+ fstsw %ax
+ sahf
+# |x| >= 1
+ jc 1f
+ f2xm1
+ ret
+1: call __finexp
+ fld1
+ fsubrp
+ ret
+
+# sinh(x)=(exp(x)-exp(-x))/2
+# cosh(x)=(exp(x)+exp(-x))/2
+# tanh(x)=sinh(x)/cosh(x)
+.global sinhf,sinh,sinhl
+ .type sinhf,@function
+ .type sinh,@function
+ .type sinhl,@function
+sinhf:
+ fldl2e
+ fmuls 4(%esp)
+ jmp finsinh
+sinh:
+ fldl2e
+ fmull 4(%esp)
+finsinh:
+ call __finexp
+ fld1
+ fdiv %st(1),%st(0) # st(0)=1/exp(x), st(1)=exp(x)
+ fsubrp %st(0),%st(1)
+ pushl $0x3f000000 # 1/2
+ flds (%esp)
+ popl %eax
+ fmulp
+ ret
+
+sinhl:
+ fldl2e
+ fldt 4(%esp)
+ fmulp
+ jmp finsinh
+
+.global coshf,cosh,coshl
+ .type coshf,@function
+ .type cosh,@function
+ .type coshl,@function
+coshf:
+ fldl2e
+ fmuls 4(%esp)
+ jmp fincosh
+cosh:
+ fldl2e
+ fmull 4(%esp)
+fincosh:
+ call __finexp
+ fld1
+ fdiv %st(1),%st(0) # st(0)=1/exp(x), st(1)=exp(x)
+ faddp %st,%st(1)
+ pushl $0x3f000000 # 1/2
+ flds (%esp)
+ popl %eax
+ fmulp
+ ret
+
+coshl:
+ fldl2e
+ fldt 4(%esp)
+ fmulp
+ jmp fincosh
+
+.global tanhf,tanh,tanhl
+ .type tanhf,@function
+ .type tanh,@function
+ .type tanhl,@function
+tanhf:
+ fldl2e
+ fmuls 4(%esp)
+ call __finexp
+ jmp fintanh
+tanh:
+ fldl2e
+ fmull 4(%esp)
+ call __finexp
+fintanh:
+ fld1
+ fdiv %st(1),%st # st(0)=1/exp(x), st(1)=exp(x)
+ fst %st(2) # st(2)=1/exp(x)
+ fadd %st(1),%st(0)
+ fstp %st(3) # st(2)=exp(x)+exp(-x), st(1)=exp(-x), st(0)=exp(x)
+ fsubp # st(1)=exp(x)+exp(-x), st(0)=exp(x)-exp(-x)
+ fdivp
+ ret
+
+tanhl:
+ fldl2e
+ fldt 4(%esp)
+ fmulp
+ call __finexp
+ jmp fintanh
+
+.global hypotf,hypot,hypotl # ,__hypot
+ .type hypotf,@function
+ .type hypot,@function
+ .type hypotl,@function
+# .type __hypot,@function
+hypotf:
+ flds 8(%esp)
+ flds 4(%esp)
+ jmp __hypot
+hypotl:
+ fldt 16(%esp)
+ fldt 4(%esp)
+ jmp __hypot
+hypot:
+ fldl 12(%esp)
+ fldl 4(%esp)
+__hypot:
+ fmul %st(0),%st(0)
+ fxch
+ fmul %st(0),%st(0)
+ faddp
+ fsqrt
+ ret
+
+.global log1pf,log1p,log1pl
+ .type log1pf,@function
+ .type log1p,@function
+ .type log1pl,@function
+log1pf:
+ flds 4(%esp)
+ jmp __log1p
+log1pl:
+ fldt 4(%esp)
+ jmp __log1p
+log1p:
+ fldl 4(%esp)
+__log1p:
+# Sprawdzenie zakresu parametru
+ fst %st(1)
+ pushl $0x3ed413cc # sqrt(2)-1-2^(-25)
+ fabs
+ flds (%esp)
+ popl %eax
+ fcompp # porownanie
+ fstsw %ax
+ fldln2
+ fxch
+ sahf
+# |x| >= sqrt(2)-1
+ jc 1f
+ fyl2xp1
+ ret
+1: fld1 # x = x + 1
+ faddp
+ fyl2x
+ ret
+
+.global log10f,log10,log10l
+ .type log10f,@function
+ .type log10,@function
+ .type log10l,@function
+log10f:
+ fldlg2
+ flds 4(%esp)
+ fyl2x
+ ret
+log10l:
+ fldlg2
+ fldt 4(%esp)
+ fyl2x
+ ret
+log10:
+ fldlg2
+ fldl 4(%esp)
+ fyl2x
+ ret
+
+.global log2f,log2,log2l
+ .type log2f,@function
+ .type log2,@function
+ .type log2l,@function
+log2f:
+ fld1
+ flds 4(%esp)
+ fyl2x
+ ret
+log2l:
+ fld1
+ fldt 4(%esp)
+ fyl2x
+ ret
+log2:
+ fld1
+ fldl 4(%esp)
+ fyl2x
+ ret
+
+.global fmaf,fma,fmal
+ .type fmaf,@function
+ .type fma,@function
+ .type fmal,@function
+fmaf:
+ flds 4(%esp)
+ fmuls 8(%esp)
+ fadds 12(%esp)
+ ret
+fma:
+ fldl 4(%esp)
+ fmull 12(%esp)
+ faddl 20(%esp)
+ ret
+fmal:
+ fldt 4(%esp)
+ fldt 16(%esp)
+ fmulp %st,%st(1)
+ fldt 28(%esp)
+ faddp %st,%st(1)
+ ret
+
+.global asinhf,asinh,asinhl
+ .type asinhf,@function
+ .type asinh,@function
+ .type asinhl,@function
+asinhf:
+ flds 4(%esp)
+ jmp __asinh
+asinh:
+ fldl 4(%esp)
+__asinh:
+ fld %st(0)
+ fmul %st(0),%st(0)
+ fld1
+ faddp %st(0),%st(1)
+finasch:
+ fsqrt
+ faddp %st(0),%st(1)
+ fldln2
+ fxch
+ fyl2x
+ ret
+asinhl:
+ fldt 4(%esp)
+ jmp __asinh
+
+.global acoshf,acosh,acoshl
+ .type acoshf,@function
+ .type acosh,@function
+ .type acoshl,@function
+acoshf:
+ flds 4(%esp)
+ jmp __acosh
+acosh:
+ fldl 4(%esp)
+__acosh:
+ fld %st(0)
+ fmul %st(0),%st(0)
+ fld1
+ fsubrp %st(0),%st(1) # st1=st1-st0; pop
+ jmp finasch
+acoshl:
+ fldt 4(%esp)
+ jmp __acosh
+
+.global atanhf,atanh,atanhl
+ .type atanhf,@function
+ .type atanh,@function
+ .type atanhl,@function
+atanhf:
+ flds 4(%esp)
+ jmp __atanh
+atanh:
+ fldl 4(%esp)
+__atanh:
+ fst %st(1)
+ fld1 # st0=1, st1=x, st2=x
+ fadd %st(0),%st(2) # st0=1, st1=x, st2=x+1
+ fsubp %st(0),%st(1) # st0=1-x, st1=x+1
+ fdivrp %st(0),%st(1)
+ fsqrt
+ fldln2
+ fxch
+ fyl2x
+ ret
+atanhl:
+ fldt 4(%esp)
+ jmp __atanh
+
+.global dremf,drem,dreml
+ .type dremf,@function
+ .type drem,@function
+ .type dreml,@function
+dremf:
+ flds 8(%esp) # y
+ flds 4(%esp) # x
+ jmp __drem
+drem:
+ fldl 12(%esp)
+ fldl 4(%esp)
+__drem:
+ fprem1
+ fstsw %ax
+ sahf
+ jp __drem
+ ret
+
+dreml:
+ fldt 16(%esp)
+ fldt 4(%esp)
+ jmp __drem
+
+# |ret| = |x|, sign(ret) = sign(y)
+.global copysignf,copysign,copysignl
+ .type copysignf,@function
+ .type copysign,@function
+ .type copysignl,@function
+copysignf:
+ flds 4(%esp) # x
+ flds 8(%esp) # y
+ jmp __copysign
+copysign:
+ fldl 4(%esp)
+ fldl 12(%esp)
+__copysign:
+ fmul %st(1),%st # st = x*y
+ ftst
+ fstsw %ax
+ fincstp
+ sahf
+ jnc 1f
+ fchs
+1: ret
+
+copysignl:
+ fldt 4(%esp)
+ fldt 16(%esp)
+ jmp __copysign
+
+.global fdimf,fdim,fdiml
+ .type fdimf,@function
+ .type fdim,@function
+ .type fdiml,@function
+fdimf:
+ flds 4(%esp)
+ fsubl 12(%esp)
+ jmp __fdim
+fdim:
+ fldl 4(%esp)
+ fsubl 12(%esp)
+__fdim:
+ fstsw %ax
+ sahf
+ jnc 1f
+ fldz
+1: ret
+fdiml:
+ fldt 4(%esp)
+ fldt 16(%esp)
+ fsubp
+ jmp __fdim
+
+
+.global truncf,trunc,truncl
+ .type truncf,@function
+ .type trunc,@function
+ .type truncl,@function
+
+truncf:
+ flds 4(%esp)
+ movb $0x0c,%ah
+ jmp __flcetr
+
+trunc:
+ fldl 4(%esp)
+ movb $0x0c,%ah
+ jmp __flcetr
+
+truncl:
+ fldt 4(%esp)
+ movb $0x0c,%ah
+ jmp __flcetr
+
+.global frexpf,frexp,frexpl
+ .type frexpf,@function
+ .type frexp,@function
+ .type frexpl,@function
+
+frexpf:
+ flds 4(%esp)
+ movl 8(%esp),%eax
+ jmp __frexp
+
+frexp:
+ fldl 4(%esp)
+ movl 12(%esp),%eax
+__frexp:
+ fxtract
+ fxch
+ fistpl (%eax)
+ pushl $0x3f000000 # 1/2
+ fmuls (%esp)
+ incl (%eax)
+ popl %eax
+ ret
+
+frexpl:
+ fldt 4(%esp)
+ movl 16(%esp),%eax
+ jmp __frexp
+
+.global logbf,logb,logbl
+ .type logbf,@function
+ .type logb,@function
+ .type logbl,@function
+
+#logbf: flds 4(%esp)
+# fxtract
+# fxch
+# ret
+
+#logb: fldl 4(%esp)
+# fxtract
+# fxch
+# ret
+
+#logbl: fldt 4(%esp)
+# fxtract
+# fxch
+# ret
+
+.global ilogbf,ilogb,ilogbl
+ .type ilogbf,@function
+ .type ilogb,@function
+ .type ilogbl,@function
+
+logbf:
+ilogbf: flds 4(%esp)
+ jmp __ilogb
+
+logb:
+ilogb: fldl 4(%esp)
+__ilogb:
+ fxtract
+ pushl %eax
+ fxch
+ fistl (%esp)
+ popl %eax
+ ret
+
+logbl:
+ilogbl: fldt 4(%esp)
+ jmp __ilogb
+
diff --git a/mdk-stage1/dietlibc/i386/listen.S b/mdk-stage1/dietlibc/i386/listen.S
new file mode 100644
index 000000000..a0879be37
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/listen.S
@@ -0,0 +1,4 @@
+#include <linuxnet.h>
+#include <syscalls.h>
+
+__socketcall(listen,LISTEN)
diff --git a/mdk-stage1/dietlibc/i386/log.S b/mdk-stage1/dietlibc/i386/log.S
new file mode 100644
index 000000000..0d42c9297
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/log.S
@@ -0,0 +1,26 @@
+.text
+
+.global logf,log,logl
+ .type logf,@function
+ .type log,@function
+ .type logl,@function
+logf:
+ fldln2
+ flds 4(%esp)
+ fyl2x
+ ret
+logl:
+ fldln2
+ fldt 4(%esp)
+ fyl2x
+ ret
+log:
+ fldln2
+ fldl 4(%esp)
+ fyl2x
+ ret
+
+.Lende:
+.size log,.Lende-log
+.size logl,.Lende-logl
+.size logf,.Lende-logf
diff --git a/mdk-stage1/dietlibc/i386/log10.S b/mdk-stage1/dietlibc/i386/log10.S
new file mode 100644
index 000000000..dcd08cc3f
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/log10.S
@@ -0,0 +1,11 @@
+.text
+.type log10,@function
+.global log10
+log10:
+ fldlg2
+ fldl 4(%esp)
+ fyl2x
+ ret
+
+.ende:
+.size log10,.ende-log10
diff --git a/mdk-stage1/dietlibc/i386/log1p.S b/mdk-stage1/dietlibc/i386/log1p.S
new file mode 100644
index 000000000..4dd2d58b4
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/log1p.S
@@ -0,0 +1,12 @@
+.text
+.type log1p,@function
+.global log1p
+log1p:
+ fldln2
+ fldl 4(%esp)
+ fyl2xp1
+ ret
+
+.ende:
+.size log1p,.ende-log1p
+
diff --git a/mdk-stage1/dietlibc/i386/log2.S b/mdk-stage1/dietlibc/i386/log2.S
new file mode 100644
index 000000000..80e99a8c9
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/log2.S
@@ -0,0 +1,11 @@
+.text
+.type log2,@function
+.global log2
+log2:
+ fld1
+ fldl 4(%esp)
+ fyl2x
+ ret
+
+.ende:
+.size log2,.ende-log2
diff --git a/mdk-stage1/dietlibc/i386/ltostr.S b/mdk-stage1/dietlibc/i386/ltostr.S
new file mode 100644
index 000000000..ddf85a4f6
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/ltostr.S
@@ -0,0 +1,62 @@
+/*
+ Copyright (C) 2002 Thomas M. Ogrisegg
+
+ __ltostr.S -- convert an integer into a string
+
+ %eax = dividend
+ %ebx = divisor
+ %ecx = size of output-buffer
+ %edi = output-buffer
+ %ebp = if uppercase is set, then %ebp is 'A'-10 else %ebp is 'a'-10
+
+*/
+
+.text
+.globl __ltostr
+__ltostr:
+ pushl %esi
+ pushl %edi # destination
+ pushl %ebp
+ pushl %ebx
+ movl %esp, %eax
+ movl 0x14(%eax), %edi
+ movl 0x18(%eax), %ecx # size
+ movl 0x20(%eax), %ebx # divisor
+ movl 0x1c(%eax), %eax # dividend
+ decl %ecx
+ movl %ecx, %esi
+ movl $('A'-0xa), %ebp
+ xorl %edx, %edx # must be 0 -- used by idiv
+ cmpl $0x0, 36(%esp) # check for uppercase
+ jnz .Lnext
+ addl $0x20, %ebp # set lowercase
+.Lnext:
+ idiv %ebx, %eax
+ cmpb $0x9, %dl
+ jg .Lnext2
+ addb $'0', %dl
+ jmp .Lstos
+.Lnext2:
+ addl %ebp, %edx
+.Lstos:
+ movb %dl, (%edi, %ecx)
+ xorl %edx, %edx
+ decl %ecx
+ jz .Lout
+ orl %eax, %eax
+ jnz .Lnext
+.Lout:
+ cld
+ movl %esi, %ebx
+ leal 1(%edi, %ecx), %esi
+ subl %ebx, %ecx
+ negl %ecx
+ movl %ecx, %eax
+ repnz movsb
+ movb $0x0, (%edi)
+ popl %ebx
+ popl %ebp
+ popl %edi
+ popl %esi
+ ret
+.size __ltostr, . - __ltostr
diff --git a/mdk-stage1/dietlibc/i386/mcount.S b/mdk-stage1/dietlibc/i386/mcount.S
new file mode 100644
index 000000000..11feed5e0
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/mcount.S
@@ -0,0 +1,44 @@
+/*
+ Copyright (C) 2001, 2002 Thomas M. Ogrisegg
+
+ This is free software. You can redistribute and
+ modify it under the terms of the GNU General Public
+ Public License.
+
+ mcount.S
+ i386 assembler implementation of mcount
+*/
+
+/* .section ".profile" */
+.text
+.globl mcount
+.type mcount,@function
+mcount:
+/*
+ save all generic registers which
+ might be used by __mcount, but aren't
+ automatically saved
+ */
+ pushl %eax
+ pushl %ecx
+ pushl %edx
+
+/* push the instruction pointer of the calling function */
+ pushl 0xc(%esp)
+
+/* push the instruction pointer of the
+ function that called the calling function */
+ pushl 0x4(%ebp)
+
+ call __mcount
+
+/* clean up stack */
+ addl $0x8, %esp
+
+/* restore the previously saved registers */
+ popl %edx
+ popl %ecx
+ popl %eax
+ ret
+
+.size mcount,.-mcount
diff --git a/mdk-stage1/dietlibc/i386/md5asm.S b/mdk-stage1/dietlibc/i386/md5asm.S
new file mode 100644
index 000000000..a99a92934
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/md5asm.S
@@ -0,0 +1,300 @@
+#define S11 7
+#define S12 12
+#define S13 17
+#define S14 22
+#define S21 5
+#define S22 9
+#define S23 14
+#define S24 20
+#define S31 4
+#define S32 11
+#define S33 16
+#define S34 23
+#define S41 6
+#define S42 10
+#define S43 15
+#define S44 21
+
+
+// #define F(x, y, z) (x & y) + (~x & z) = x&y + (z - z&x) = z + y&x - z&x
+//#define F(x, y, z) movl x,%ebx; movl x,%eax; notl %ebx; andl y,%eax; andl z,%ebx; addl %ebx,%eax
+#define F(x, y, z) movl y,%eax; movl z,%ebx; andl x,%eax; andl x,%ebx; addl z,%eax; subl %ebx,%eax
+
+// #define G(x, y, z) (x & z) + (y & ~z) = x&z + (y - y&z) = y + x&z - y&z
+#define G(x, y, z) movl z,%ebx; movl z,%eax; notl %ebx; andl x,%eax; andl y,%ebx; addl %ebx,%eax
+//#define G(x, y, z) movl x,%eax; movl y,%ebx; andl z,%eax; andl z,%ebx; addl y,%eax; subl %ebx,%eax
+//#define G(x, y, z) movl z,%eax; movl z,%ebx; andl x,%eax; andl y,%ebx; addl y,%eax; subl %ebx,%eax
+
+// #define H(x, y, z) x ^ y ^ z
+#define H(x, y, z) movl z,%eax; xorl y,%eax; xorl x,%eax
+
+// #define I(x, y, z) y ^ (x | ~z)
+#define I(x, y, z) movl z,%eax; notl %eax; orl x,%eax; xorl y,%eax
+
+
+// #define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
+#define ROTATE_LEFT(x, n) roll $n,x
+
+// #define FF(a, b, c, d, x, s, ac) { (a) += F (b, c, d) + (x) + (word)(ac); (a) = ROTATE_LEFT (a, s); (a) += (b); }
+// #define GG(a, b, c, d, x, s, ac) { (a) += G (b, c, d) + (x) + (word)(ac); (a) = ROTATE_LEFT (a, s); (a) += (b); }
+// #define HH(a, b, c, d, x, s, ac) { (a) += H (b, c, d) + (x) + (word)(ac); (a) = ROTATE_LEFT (a, s); (a) += (b); }
+// #define II(a, b, c, d, x, s, ac) { (a) += I (b, c, d) + (x) + (word)(ac); (a) = ROTATE_LEFT (a, s); (a) += (b); }
+
+#define FF(a, b, c, d, x, s, ac) addl x, a; addl $ac,a; F (b, c, d); addl %eax,a; roll $s,a; addl b,a
+#define GG(a, b, c, d, x, s, ac) addl x, a; addl $ac,a; G (b, c, d); addl %eax,a; roll $s,a; addl b,a
+#define HH(a, b, c, d, x, s, ac) addl x, a; addl $ac,a; H (b, c, d); addl %eax,a; roll $s,a; addl b,a
+#define II(a, b, c, d, x, s, ac) addl x, a; addl $ac,a; I (b, c, d); addl %eax,a; roll $s,a; addl b,a
+
+
+// // x is ecx
+// word a = state [0]; // a is edx
+// word b = state [1]; // b is esi
+// word c = state [2]; // c is edi
+// word d = state [3]; // d is ebp
+
+#define X(n) 4*(n)(%ecx)
+#define X0 (%ecx)
+#define a %edx
+#define b %esi
+#define c %edi
+#define d %ebp
+
+
+
+/* MD5 basic transformation: Transforms state based on data block */
+
+// void __MD5Transform ( word state[4], const word* x, size_t repeat )
+
+.text
+.type __MD5Transform, @function
+.align 32
+.global __MD5Transform
+
+ .align 32
+.Lrepeat:
+
+ /* Round 1 */
+ FF (a, b, c, d, X0 , S11, 0xd76aa478); /* 1 */
+ FF (d, a, b, c, X( 1), S12, 0xe8c7b756); /* 2 */
+ FF (c, d, a, b, X( 2), S13, 0x242070db); /* 3 */
+ FF (b, c, d, a, X( 3), S14, 0xc1bdceee); /* 4 */
+ FF (a, b, c, d, X( 4), S11, 0xf57c0faf); /* 5 */
+ FF (d, a, b, c, X( 5), S12, 0x4787c62a); /* 6 */
+ FF (c, d, a, b, X( 6), S13, 0xa8304613); /* 7 */
+ FF (b, c, d, a, X( 7), S14, 0xfd469501); /* 8 */
+ FF (a, b, c, d, X( 8), S11, 0x698098d8); /* 9 */
+ FF (d, a, b, c, X( 9), S12, 0x8b44f7af); /* 10 */
+ FF (c, d, a, b, X(10), S13, 0xffff5bb1); /* 11 */
+ FF (b, c, d, a, X(11), S14, 0x895cd7be); /* 12 */
+ FF (a, b, c, d, X(12), S11, 0x6b901122); /* 13 */
+ FF (d, a, b, c, X(13), S12, 0xfd987193); /* 14 */
+ FF (c, d, a, b, X(14), S13, 0xa679438e); /* 15 */
+ FF (b, c, d, a, X(15), S14, 0x49b40821); /* 16 */
+
+ /* Round 2 */
+ GG (a, b, c, d, X( 1), S21, 0xf61e2562); /* 17 */
+ GG (d, a, b, c, X( 6), S22, 0xc040b340); /* 18 */
+ GG (c, d, a, b, X(11), S23, 0x265e5a51); /* 19 */
+ GG (b, c, d, a, X0 , S24, 0xe9b6c7aa); /* 20 */
+ GG (a, b, c, d, X( 5), S21, 0xd62f105d); /* 21 */
+ GG (d, a, b, c, X(10), S22, 0x02441453); /* 22 */
+ GG (c, d, a, b, X(15), S23, 0xd8a1e681); /* 23 */
+ GG (b, c, d, a, X( 4), S24, 0xe7d3fbc8); /* 24 */
+ GG (a, b, c, d, X( 9), S21, 0x21e1cde6); /* 25 */
+ GG (d, a, b, c, X(14), S22, 0xc33707d6); /* 26 */
+ GG (c, d, a, b, X( 3), S23, 0xf4d50d87); /* 27 */
+ GG (b, c, d, a, X( 8), S24, 0x455a14ed); /* 28 */
+ GG (a, b, c, d, X(13), S21, 0xa9e3e905); /* 29 */
+ GG (d, a, b, c, X( 2), S22, 0xfcefa3f8); /* 30 */
+ GG (c, d, a, b, X( 7), S23, 0x676f02d9); /* 31 */
+ GG (b, c, d, a, X(12), S24, 0x8d2a4c8a); /* 32 */
+
+ /* Round 3 */
+ HH (a, b, c, d, X( 5), S31, 0xfffa3942); /* 33 */
+ HH (d, a, b, c, X( 8), S32, 0x8771f681); /* 34 */
+ HH (c, d, a, b, X(11), S33, 0x6d9d6122); /* 35 */
+ HH (b, c, d, a, X(14), S34, 0xfde5380c); /* 36 */
+ HH (a, b, c, d, X( 1), S31, 0xa4beea44); /* 37 */
+ HH (d, a, b, c, X( 4), S32, 0x4bdecfa9); /* 38 */
+ HH (c, d, a, b, X( 7), S33, 0xf6bb4b60); /* 39 */
+ HH (b, c, d, a, X(10), S34, 0xbebfbc70); /* 40 */
+ HH (a, b, c, d, X(13), S31, 0x289b7ec6); /* 41 */
+ HH (d, a, b, c, X0 , S32, 0xeaa127fa); /* 42 */
+ HH (c, d, a, b, X( 3), S33, 0xd4ef3085); /* 43 */
+ HH (b, c, d, a, X( 6), S34, 0x04881d05); /* 44 */
+ HH (a, b, c, d, X( 9), S31, 0xd9d4d039); /* 45 */
+ HH (d, a, b, c, X(12), S32, 0xe6db99e5); /* 46 */
+ HH (c, d, a, b, X(15), S33, 0x1fa27cf8); /* 47 */
+ HH (b, c, d, a, X( 2), S34, 0xc4ac5665); /* 48 */
+
+ /* Round 4 */
+ II (a, b, c, d, X0 , S41, 0xf4292244); /* 49 */
+ II (d, a, b, c, X( 7), S42, 0x432aff97); /* 50 */
+ II (c, d, a, b, X(14), S43, 0xab9423a7); /* 51 */
+ II (b, c, d, a, X( 5), S44, 0xfc93a039); /* 52 */
+ II (a, b, c, d, X(12), S41, 0x655b59c3); /* 53 */
+ II (d, a, b, c, X( 3), S42, 0x8f0ccc92); /* 54 */
+ II (c, d, a, b, X(10), S43, 0xffeff47d); /* 55 */
+ II (b, c, d, a, X( 1), S44, 0x85845dd1); /* 56 */
+ II (a, b, c, d, X( 8), S41, 0x6fa87e4f); /* 57 */
+ II (d, a, b, c, X(15), S42, 0xfe2ce6e0); /* 58 */
+ II (c, d, a, b, X( 6), S43, 0xa3014314); /* 59 */
+ II (b, c, d, a, X(13), S44, 0x4e0811a1); /* 60 */
+ II (a, b, c, d, X( 4), S41, 0xf7537e82); /* 61 */
+ II (d, a, b, c, X(11), S42, 0xbd3af235); /* 62 */
+ II (c, d, a, b, X( 2), S43, 0x2ad7d2bb); /* 63 */
+ II (b, c, d, a, X( 9), S44, 0xeb86d391); /* 64 */
+
+// state [0] += a;
+// state [1] += b;
+// state [2] += c;
+// state [3] += d;
+
+ addl $64,%ecx
+
+ movl 4+32(%esp),%eax // state
+ addl (%eax),a
+ addl 4(%eax),b
+ addl 8(%eax),c
+ addl 12(%eax),d
+ movl a, (%eax)
+ movl b, 4(%eax)
+ movl c, 8(%eax)
+ movl d,12(%eax)
+
+.Lstart:
+ decl 12+32(%esp)
+ jns .Lrepeat
+
+ popal
+ ret
+
+__MD5Transform:
+__MD5TransformLocal:
+ pushal
+ movl 8+32(%esp),%ecx // x
+ movl 4+32(%esp),%eax // state
+ movl (%eax),a
+ movl 4(%eax),b
+ movl 8(%eax),c
+ movl 12(%eax),d
+ jmp .Lstart
+
+.Lende:
+.size __MD5Transform, .Lende-__MD5Transform
+
+.type MD5Init,@function
+.global MD5Init
+
+MD5Init:
+ movl 4(%esp), %ecx
+ xorl %eax,%eax
+ movl $0x67452301, (%ecx)
+ movl $0xefcdab89, 4(%ecx)
+ movl $0x98badcfe, 8(%ecx)
+ movl $0x10325476, 12(%ecx)
+ movl %eax, 16(%ecx)
+ movl %eax, 20(%ecx)
+ ret
+
+
+.global MD5Update
+.type MD5Update,@function
+
+
+// void MD5Update ( MD5_CTX* context, const byte* input, size_t inputBytes )
+
+#define CONTEXT 4+32(%esp)
+#define INPUT 8+32(%esp)
+#define INPUTBYTES 12+32(%esp)
+
+#define COUNT 16(%ebx)
+#define BUFFER 24(%ebx)
+
+
+MD5Update:
+ pushal
+ cld
+ movl CONTEXT, %ebx
+
+// ByteIndex = (context->count[0] >> 3) & 0x3F;
+
+ movl COUNT, %ebp
+ shrl $3, %ebp
+ andl $63,%ebp // ebp = ByteIndex
+
+// if ( (context->count[0] += inputBytes << 3 ) < (inputBytes << 3) )
+// context->count[1]++;
+// context->count[1] += inputBytes >> (32-3);
+
+ movl $8, %eax
+ mull INPUTBYTES
+ addl %eax, 0+COUNT
+ adcl %edx, 4+COUNT
+
+// partLen = 64 - ByteIndex;
+
+ movl $64, %eax
+ subl %ebp, %eax // eax = partLen
+
+// i = 0;
+// if ( partLen <= inputBytes ) {
+
+ xorl %ecx,%ecx // ecx = i
+ cmpl INPUTBYTES, %eax
+ ja .Lende2
+
+// memcpy ( context->buffer + ByteIndex, input, partLen );
+
+ leal 24(%ebx,%ebp,1), %edi
+ movl INPUT, %esi
+ movl %eax, %ecx
+ rep movsb
+
+// MD5Transform ( context->state, context->buffer, 1 );
+
+ pushl $1
+ leal BUFFER, %ecx
+ pushl %ecx
+ push %ebx
+ call __MD5TransformLocal
+
+// len = (inputBytes - partLen) / 64;
+
+ movl 12+INPUTBYTES, %ecx
+ subl %eax, %ecx
+ shrl $6, %ecx
+
+// MD5Transform ( context->state, input+partLen, len );
+
+ pushl %ecx
+ pushl %esi
+ pushl %ebx
+ call __MD5TransformLocal
+ addl $24,%esp
+
+// i = partLen + 64 * len;
+// ByteIndex = 0;
+
+ shll $6, %ecx
+ addl %eax, %ecx
+ xorl %ebp, %ebp
+
+.Lende2:
+
+// }
+// memcpy ( context->buffer + ByteIndex, input + i, inputBytes - i );
+
+ movl INPUT, %esi
+ addl %ecx, %esi
+
+ negl %ecx
+ addl INPUTBYTES, %ecx
+
+ leal 24(%ebx,%ebp,1), %edi
+ rep movsb
+
+ popal
+ ret
+
+
diff --git a/mdk-stage1/dietlibc/i386/memccpy.S b/mdk-stage1/dietlibc/i386/memccpy.S
new file mode 100644
index 000000000..0b7dce49e
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/memccpy.S
@@ -0,0 +1,39 @@
+/*
+ Copyright (C) 2002 Thomas M. Ogrisegg
+
+ This is free software. You can redistribute and
+ modify it under the terms of the GNU General Public
+ Public License.
+
+ memccpy.S
+ i386 assembler implementation of memccpy(3)
+*/
+
+.text
+.global memccpy
+.type memccpy,@function
+memccpy:
+ pushl %esi
+ pushl %edi
+
+ movl %esp, %ecx
+ movl 0x0c(%ecx), %edi
+ movl 0x10(%ecx), %esi
+ movb 0x14(%ecx), %dl
+ movl 0x18(%ecx), %ecx
+ cld
+.Lloop:
+ lodsb
+ stosb
+ cmp %al, %dl
+ jz .Lout
+ decl %ecx
+ jnz .Lloop
+ xorl %edi, %edi
+.Lout:
+ movl %edi, %eax
+ popl %edi
+ popl %esi
+ ret
+.Lende:
+.size memccpy,.Lende-memccpy
diff --git a/mdk-stage1/dietlibc/i386/memchr.S b/mdk-stage1/dietlibc/i386/memchr.S
new file mode 100644
index 000000000..7d04f990b
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/memchr.S
@@ -0,0 +1,24 @@
+.text
+.align 0
+.global memchr
+.type memchr,@function
+memchr:
+ pushl %edi
+ movl 8(%esp),%edi
+ movl 12(%esp),%eax
+ movl 16(%esp),%ecx
+ cld
+ jecxz .Lnotfound
+
+ repne scasb
+
+ je .Lfound
+.Lnotfound:
+ xorl %edi, %edi
+ incl %edi
+.Lfound:
+ movl %edi, %eax
+ decl %eax
+
+ popl %edi
+ ret
diff --git a/mdk-stage1/dietlibc/i386/memcmp.S b/mdk-stage1/dietlibc/i386/memcmp.S
new file mode 100644
index 000000000..aa6d55f23
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/memcmp.S
@@ -0,0 +1,26 @@
+.text
+.align 0
+.global memcmp
+.type memcmp,@function
+memcmp:
+ xorl %eax,%eax
+ orl 12(%esp),%eax
+ jz .Lempty
+ pushl %esi
+ pushl %edi
+ movl 12(%esp),%esi
+ movl 16(%esp),%edi
+ movl %eax,%ecx
+
+ rep cmpsb
+
+ decl %esi
+ decl %edi
+ lodsb
+ subb (%edi), %al
+ movsx %al, %eax
+
+ popl %edi
+ popl %esi
+.Lempty:
+ ret
diff --git a/mdk-stage1/dietlibc/i386/memcpy.S b/mdk-stage1/dietlibc/i386/memcpy.S
new file mode 100644
index 000000000..cbe74459f
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/memcpy.S
@@ -0,0 +1,16 @@
+.text
+.align 0
+.global memcpy
+.type memcpy,@function
+memcpy:
+ pushl %esi
+ pushl %edi
+ movl 12(%esp),%edi
+ movl 16(%esp),%esi
+ movl 20(%esp),%ecx
+ movl %edi, %eax
+ cld
+ rep movsb
+ popl %edi
+ popl %esi
+ ret
diff --git a/mdk-stage1/dietlibc/i386/memset.S b/mdk-stage1/dietlibc/i386/memset.S
new file mode 100644
index 000000000..472390b84
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/memset.S
@@ -0,0 +1,15 @@
+.text
+.align 0
+.global memset
+.type memset,@function
+memset:
+ pushl %edi
+ movl 8(%esp),%edi
+ movl 12(%esp),%eax
+ movl 16(%esp),%ecx
+ cld
+ pushl %edi
+ rep stosb
+ popl %eax
+ popl %edi
+ ret
diff --git a/mdk-stage1/dietlibc/i386/mmap.S b/mdk-stage1/dietlibc/i386/mmap.S
new file mode 100644
index 000000000..c824aa037
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/mmap.S
@@ -0,0 +1,14 @@
+#include "syscalls.h"
+
+.text
+.global mmap
+.type mmap,@function
+mmap:
+ mov $__NR_mmap,%al
+ lea 0x4(%esp,1),%edx
+ push %edx
+ call __unified_syscall
+ pop %ecx
+ ret
+.Lende3:
+.size mmap,.Lende3-mmap
diff --git a/mdk-stage1/dietlibc/i386/mmap64.S b/mdk-stage1/dietlibc/i386/mmap64.S
new file mode 100644
index 000000000..421325260
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/mmap64.S
@@ -0,0 +1,63 @@
+#include <dietfeatures.h>
+#include <syscalls.h>
+#include <errno.h>
+
+#ifdef __DYN_LIB
+#ifndef WANT_THREAD_SAFE
+#define WANT_THREAD_SAFE
+#endif
+#endif
+
+.text
+.global mmap64
+.type mmap64,@function
+mmap64:
+/* man is this ugly! */
+ push %ebp
+ push %edi
+ push %esi
+ push %ebx
+ movl %esp, %edi
+ movl 0x28(%edi), %eax
+ movl 0x2c(%edi), %edx
+ testl $0xfff, %eax /* offset in pages */
+ jnz .Leinval
+ shrdl $12, %edx, %eax
+ shrl $12, %edx
+ jnz .Leinval
+ movl %eax, %ebp
+ movl 0x14(%edi),%ebx
+ movl 0x18(%edi),%ecx
+ movl 0x1c(%edi),%edx
+ movl 0x20(%edi),%esi
+ movl 0x24(%edi),%edi
+ movl $__NR_mmap2,%eax
+ int $0x80
+ cmp $-124,%eax
+ jbe .Lnoerror
+ neg %eax
+.Lerror:
+#ifdef WANT_THREAD_SAFE
+ movl %eax,%ebx
+#ifdef __DYN_LIB
+ call __errno_location@PLT
+#else
+ call __errno_location
+#endif
+ movl %ebx,(%eax)
+ orl $-1,%eax
+#else
+ mov %eax,errno
+ sbb %eax,%eax # eax = eax - eax - CY = -1
+#endif
+.Lnoerror:
+ pop %ebx
+ pop %esi
+ pop %edi
+ pop %ebp
+ ret
+.Leinval:
+ movl $EINVAL,%eax
+ jmp .Lerror
+.Lende2:
+.size mmap64,.Lende2-mmap64
diff --git a/mdk-stage1/dietlibc/i386/poly.S b/mdk-stage1/dietlibc/i386/poly.S
new file mode 100644
index 000000000..d8be7d7f5
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/poly.S
@@ -0,0 +1,24 @@
+
+.text
+.global __poly
+.type __poly,@function
+
+
+#
+# double __poly ( double x, int n, const double* c );
+#
+
+__poly:
+ movl 16(%esp),%eax
+ movl 12(%esp),%ecx
+ leal (%eax,%ecx,8),%eax
+ fldl 4(%esp)
+ fldz
+.Lloop:
+ fmul %st(1),%st(0)
+ faddl (%eax)
+ addl $-8,%eax
+ decl %ecx
+ jns .Lloop
+ fstp %st(1)
+ ret
diff --git a/mdk-stage1/dietlibc/i386/pow.S b/mdk-stage1/dietlibc/i386/pow.S
new file mode 100644
index 000000000..46562a299
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/pow.S
@@ -0,0 +1,67 @@
+.text
+.global pow
+.type pow,@function
+
+# pow(x,y)
+.global powf,pow,powl
+ .type powf,@function
+ .type pow,@function
+ .type powl,@function
+powf:
+ flds 4(%esp) # x
+ flds 8(%esp) # y
+ jmp .L__pow
+powl:
+ fldt 4(%esp)
+ fldt 16(%esp)
+ jmp .L__pow
+pow:
+ fldl 4(%esp)
+ fldl 12(%esp)
+# x^y; st(0)=y, st(1)=x
+.L__pow:
+ ftst # y = 0 ?
+ fstsw %ax
+ fld1 # st(0)=1, st(1)=y, st(2)=x
+ sahf
+ jz 1f # return 1
+ fcomp %st(1) # y = 1 ?
+ fstsw %ax
+ fxch # st(0)=x, st(1)=y
+ sahf
+ jz 1f # return x
+ ftst # x = 0 ?
+ fstsw %ax
+ sahf
+ jz 1f
+ jnc .Lfinpow # x > 0
+ fxch # st(0)=y, st(1)=x
+ fld %st(0) # st(0)=y, st(1)=y, st(2)=x
+ frndint # st(0)=int(y)
+ fcomp %st(1) # y = int(y)?
+ fstsw %ax
+ fxch
+ sahf
+ jnz .Lfinpow # fyl2x -> st(0) = NaN
+# y even or odd ?
+ fld1
+ fadd %st(0) # st(0) = 2
+ fdivr %st(2),%st(0) # st(0)=st(2)/2
+ frndint
+ fadd %st(0),%st(0)
+ fcomp %st(2) # st(0) = x, st(1) = y
+ fstsw %ax
+ fchs # st(0) = -x
+ sahf
+ jz .Lfinpow # y even
+ call .Lfinpow # y odd
+ fchs
+1: ret
+.Lfinpow:
+ fyl2x
+ jmp __finexp
+
+.Lende:
+.size pow,.Lende-pow
+.size powf,.Lende-powf
+.size powl,.Lende-powl
diff --git a/mdk-stage1/dietlibc/i386/recv.S b/mdk-stage1/dietlibc/i386/recv.S
new file mode 100644
index 000000000..215343ccc
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/recv.S
@@ -0,0 +1,4 @@
+#include <linuxnet.h>
+#include <syscalls.h>
+
+__socketcall(recv,RECV)
diff --git a/mdk-stage1/dietlibc/i386/recvfrom.S b/mdk-stage1/dietlibc/i386/recvfrom.S
new file mode 100644
index 000000000..a9dde840d
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/recvfrom.S
@@ -0,0 +1,4 @@
+#include <linuxnet.h>
+#include <syscalls.h>
+
+__socketcall(recvfrom,RECVFROM)
diff --git a/mdk-stage1/dietlibc/i386/recvmsg.S b/mdk-stage1/dietlibc/i386/recvmsg.S
new file mode 100644
index 000000000..cb26e2f08
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/recvmsg.S
@@ -0,0 +1,4 @@
+#include <linuxnet.h>
+#include <syscalls.h>
+
+__socketcall(recvmsg,RECVMSG)
diff --git a/mdk-stage1/dietlibc/i386/rint.S b/mdk-stage1/dietlibc/i386/rint.S
new file mode 100644
index 000000000..f56ab1f93
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/rint.S
@@ -0,0 +1,23 @@
+.text
+
+.global rintf,rint,rintl
+ .type rintf,@function
+ .type rint,@function
+ .type rintl,@function
+rintf:
+ flds 4(%esp)
+ frndint
+ ret
+rint:
+ fldl 4(%esp)
+ frndint
+ ret
+rintl:
+ fldt 4(%esp)
+ frndint
+ ret
+
+.Lende:
+.size rint,.Lende-rint
+.size rintl,.Lende-rintl
+.size rintf,.Lende-rintf
diff --git a/mdk-stage1/dietlibc/i386/send.S b/mdk-stage1/dietlibc/i386/send.S
new file mode 100644
index 000000000..f2dd7e3d5
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/send.S
@@ -0,0 +1,4 @@
+#include <linuxnet.h>
+#include <syscalls.h>
+
+__socketcall(send,SEND)
diff --git a/mdk-stage1/dietlibc/i386/sendmsg.S b/mdk-stage1/dietlibc/i386/sendmsg.S
new file mode 100644
index 000000000..484d62e50
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/sendmsg.S
@@ -0,0 +1,4 @@
+#include <linuxnet.h>
+#include <syscalls.h>
+
+__socketcall(sendmsg,SENDMSG)
diff --git a/mdk-stage1/dietlibc/i386/sendto.S b/mdk-stage1/dietlibc/i386/sendto.S
new file mode 100644
index 000000000..04270f0f0
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/sendto.S
@@ -0,0 +1,4 @@
+#include <linuxnet.h>
+#include <syscalls.h>
+
+__socketcall(sendto,SENDTO)
diff --git a/mdk-stage1/dietlibc/i386/setjmp.S b/mdk-stage1/dietlibc/i386/setjmp.S
index 9bfecf565..09b266c61 100644
--- a/mdk-stage1/dietlibc/i386/setjmp.S
+++ b/mdk-stage1/dietlibc/i386/setjmp.S
@@ -1,61 +1,40 @@
#include <setjmp.h>
-/* setjmp for i386.
- Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the GNU C Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-.section .rodata
.text
.weak setjmp
+.type setjmp,@function
setjmp:
.globl __setjmp
+.type __setjmp,@function
__setjmp:
- popl %eax /* Pop return address. */
- popl %ecx /* Pop jmp_buf. */
- pushl $0 /* Push zero argument. */
- pushl %ecx /* Push jmp_buf. */
- pushl %eax /* Push back return address. */
+ popl %eax
+ popl %ecx
+ pushl $0
+ pushl %ecx
+ pushl %eax
.globl __sigsetjmp
+.type __sigsetjmp,@function
__sigsetjmp:
- movl 4(%esp), %eax /* User's jmp_buf in %eax. */
+ movl 4(%esp), %eax
+
/* Save registers. */
movl %ebx, (JB_BX*4)(%eax)
movl %esi, (JB_SI*4)(%eax)
movl %edi, (JB_DI*4)(%eax)
movl %ebp, (JB_BP*4)(%eax)
- leal 4(%esp), %ecx /* Save SP as it will be after we return. */
- movl %ecx, (JB_SP*4)(%eax)
+ leal 4(%esp), %edx /* Save SP as it will be after we return. */
movl 0(%esp), %ecx /* Save PC we are returning to now. */
+ movl %edx, (JB_SP*4)(%eax)
movl %ecx, (JB_PC*4)(%eax)
/* Make a tail call to __sigjmp_save; it takes the same args. */
#ifdef PIC
- /* We cannot use the PLT, because it requires that %ebx be set, but
- we can't save and restore our caller's value. Instead, we do an
- indirect jump through the GOT, using for the temporary register
- %ecx, which is call-clobbered. */
- call L(here)
-L(here):
- popl %ecx
- addl $_GLOBAL_OFFSET_TABLE_+[.-L(here)], %ecx
- movl C_SYMBOL_NAME(__sigjmp_save@GOT)(%ecx), %ecx
- jmp *%ecx
+ call 1f
+ addl $_GLOBAL_OFFSET_TABLE_, %ecx
+ jmp *__sigjmp_save@GOT(%ecx)
+1: movl (%esp), %ecx
+ ret
#else
jmp __sigjmp_save
#endif
diff --git a/mdk-stage1/dietlibc/i386/setsockopt.S b/mdk-stage1/dietlibc/i386/setsockopt.S
new file mode 100644
index 000000000..6a81aec82
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/setsockopt.S
@@ -0,0 +1,4 @@
+#include <linuxnet.h>
+#include <syscalls.h>
+
+__socketcall(setsockopt,SETSOCKOPT)
diff --git a/mdk-stage1/dietlibc/i386/shutdown.S b/mdk-stage1/dietlibc/i386/shutdown.S
new file mode 100644
index 000000000..f9dc707e8
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/shutdown.S
@@ -0,0 +1,4 @@
+#include <linuxnet.h>
+#include <syscalls.h>
+
+__socketcall(shutdown,SHUTDOWN)
diff --git a/mdk-stage1/dietlibc/i386/sin.S b/mdk-stage1/dietlibc/i386/sin.S
new file mode 100644
index 000000000..404bf5eed
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/sin.S
@@ -0,0 +1,34 @@
+
+.text
+
+.global sinf,sin,sinl
+.type sinf,@function
+.type sin,@function
+.type sinl,@function
+sinf:
+ flds 4(%esp)
+ jmp 1f
+sin:
+ fldl 4(%esp)
+1: fsin
+ fnstsw %ax
+ testb $0x04, %ah
+ je 3f
+ fldpi
+ fadd %st
+ fxch %st(1)
+2: fprem1
+ fnstsw %ax
+ testb $0x04, %ah
+ jne 2b
+ fstp %st(1)
+ fsin
+3: ret
+sinl:
+ fldt 4(%esp)
+ jmp 1b
+
+.ende:
+.size sin,.ende-sin
+.size sinf,.ende-sinf
+.size sinl,.ende-sinl
diff --git a/mdk-stage1/dietlibc/i386/sincos.S b/mdk-stage1/dietlibc/i386/sincos.S
new file mode 100644
index 000000000..7395075f3
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/sincos.S
@@ -0,0 +1,18 @@
+
+.text
+.type sincos,@function
+.global sincos
+
+# void sincos ( double x, double* sinx, double* cosx );
+
+sincos:
+ fldl 4(%esp)
+ fsincos
+ movl 16(%esp),%eax
+ movl 12(%esp),%ecx
+ fstpl (%eax)
+ fstpl (%ecx)
+ ret
+
+.ende:
+.size sincos,.ende-sincos
diff --git a/mdk-stage1/dietlibc/i386/sinh.S b/mdk-stage1/dietlibc/i386/sinh.S
new file mode 100644
index 000000000..98f7ee752
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/sinh.S
@@ -0,0 +1,29 @@
+
+.text
+.type sinh,@function
+.global sinh
+
+sinh: # note: exp(x) = 2^(x*log2(e))
+ fldl2e
+ fmull 4(%esp) # x*log2(e)
+ fld %st(0) # x*log2(e) x*log2(e)
+ frndint # int(x*log2(e)) x*log2(e)
+ fxch # x*log2(e) int(x*log2(e))
+ fsub %st(1),%st(0) # frac(x*log2(e)) int(x*log2(e))
+ f2xm1 # 2^(fract(x*log2(e)))-1 int(x*log2(e))
+ fld1 # 1 2^(fract(x*log2(e)))-1 int(x*log2(e))
+ faddp %st(0),%st(1) # 2^(fract(x*log2(e))) int(x*log2(e))
+ fscale # 2^(x*log2(e)) int(x*log2(e))
+ fstp %st(1) # 2^(x*log2(e))
+
+# now we have y = exp(x), but sinh(x) = (y - 1/y) * 0.5
+
+ fld1
+ fdiv %st(1),%st(0)
+ fsubrp
+ fmuls __half
+ ret
+
+.Lende:
+
+.size sinh,.ende-sinh
diff --git a/mdk-stage1/dietlibc/i386/sleep.S b/mdk-stage1/dietlibc/i386/sleep.S
new file mode 100644
index 000000000..356552dc2
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/sleep.S
@@ -0,0 +1,25 @@
+#include "PIC.h"
+
+.text
+.global sleep
+.type sleep,@function
+
+sleep:
+ movl 4(%esp),%eax # Argument holen
+ PIC_SAVE # non-PIC: empty line
+ PIC_INIT # non-PIC: empty line
+ pushl $0 # 0 ns
+ pushl %eax # 'x' µs warten
+ movl %esp,%eax
+ pushl %eax # zweimal ein Zeiger auf das Stackobjekt
+ pushl %eax # ptr ptr sec nsec return arg
+#ifdef __DYN_LIB
+ call nanosleep@PLT
+#else
+ call nanosleep
+#endif
+ movl 20(%esp),%eax # 'x' holen
+ subl 8(%esp),%eax # schon abgelaufende Zeit subtrahieren
+ addl $16,%esp
+ PIC_RESTORE # non-PIC: empty line
+ ret
diff --git a/mdk-stage1/dietlibc/i386/socket.S b/mdk-stage1/dietlibc/i386/socket.S
new file mode 100644
index 000000000..bc8cbe536
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/socket.S
@@ -0,0 +1,4 @@
+#include <linuxnet.h>
+#include <syscalls.h>
+
+__socketcall(socket,SOCKET)
diff --git a/mdk-stage1/dietlibc/i386/socketcall.S b/mdk-stage1/dietlibc/i386/socketcall.S
new file mode 100644
index 000000000..4e8019ec2
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/socketcall.S
@@ -0,0 +1,17 @@
+#include <syscalls.h>
+
+.text
+.global socketcall
+.type socketcall,@function
+socketcall:
+ leal 4(%esp), %ecx
+ pushl %ecx
+ movzbl %al,%eax
+ pushl %eax
+ movb $__NR_socketcall,%al
+ call __unified_syscall
+ popl %ecx
+ popl %ecx
+ retl
+.Lende:
+.size socketcall,.Lende-socketcall
diff --git a/mdk-stage1/dietlibc/i386/socketpair.S b/mdk-stage1/dietlibc/i386/socketpair.S
new file mode 100644
index 000000000..a5de65f25
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/socketpair.S
@@ -0,0 +1,4 @@
+#include <linuxnet.h>
+#include <syscalls.h>
+
+__socketcall(socketpair,SOCKETPAIR)
diff --git a/mdk-stage1/dietlibc/i386/sqrt.S b/mdk-stage1/dietlibc/i386/sqrt.S
new file mode 100644
index 000000000..5e4527612
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/sqrt.S
@@ -0,0 +1,23 @@
+.text
+
+.global sqrtf,sqrt,sqrtl
+ .type sqrtf,@function
+ .type sqrt,@function
+ .type sqrtl,@function
+sqrtf:
+ flds 4(%esp)
+ fsqrt
+ ret
+sqrt:
+ fldl 4(%esp)
+ fsqrt
+ ret
+sqrtl:
+ fldt 4(%esp)
+ fsqrt
+ ret
+
+.ende:
+.size sqrt,.ende-sqrt
+.size sqrtf,.ende-sqrtf
+.size sqrtl,.ende-sqrtl
diff --git a/mdk-stage1/dietlibc/i386/sqrtl.S b/mdk-stage1/dietlibc/i386/sqrtl.S
new file mode 100644
index 000000000..c1a931fd8
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/sqrtl.S
@@ -0,0 +1,11 @@
+.text
+.type sqrtl,@function
+.global sqrtl
+sqrtl:
+ fldt 4(%esp)
+ fsqrt
+ ret
+
+.ende:
+.size sqrtl,.ende-sqrtl
+
diff --git a/mdk-stage1/dietlibc/i386/start.S b/mdk-stage1/dietlibc/i386/start.S
index 167bb779c..1a825fc2a 100644
--- a/mdk-stage1/dietlibc/i386/start.S
+++ b/mdk-stage1/dietlibc/i386/start.S
@@ -1,42 +1,51 @@
-#include "start.h"
+#include "dietfeatures.h"
+#include "PIC.h"
-#ifdef __i386__
.text
-.globl _start
+.global _start
_start:
-#if 0
- popl %ecx
- movl %esp, %esi
- leal 4(%esp,%ecx,4),%eax
+#if 1
+ popl %ecx /* %ecx = argc */
+ movl %esp,%esi /* %esi = argv */
+ pushl %ecx
#else
- movl (%esp),%ecx /* %ecx = argc */
- leal 4(%esp),%esi /* %esi = argv */
-
- leal 4(%esi,%ecx,4),%eax /* eax = 4*ecx+4 = envp */
+ movl (%esp),%ecx /* %ecx = argc */
+ leal 4(%esp),%esi /* %esi = argv */
#endif
- pushl %eax
- pushl %esi
- pushl %ecx
- movl %eax,environ
+ leal 4(%esi,%ecx,4),%eax /* %eax = envp = (4*ecx)+%esi+4 */
#ifdef WANT_DYNAMIC
-/* in %edx we have the dynamic _fini ( register this if non null ) */
- test %edx, %edx
- je .Linit
+/* in %edx we have the ld.so dynamic _fini ( register this if non null ) */
push %edx
- call atexit
- pop %edx
-.Linit:
- call _init
- push $_fini
- call atexit
- pop %edx
#endif
- call main
- pushl %eax
- call exit
-.Lfefe:
- .size _start,.Lfefe-_start
+ pushl %eax
+ pushl %esi
+ pushl %ecx
+ PIC_INIT /* non-PIC: this is an empty line */
+ PUT_VAR %eax, environ, %ecx /* non-PIC: movl %eax,environ */
+
+#ifdef PROFILING
+ pushl $_etext
+ pushl $.text
+ call monitor
+ addl $0x8, %esp
+#endif
+
+#ifdef WANT_DYNAMIC
+ call _dyn_start
+#else
+ call main
+#endif
+
+#ifdef PROFILING
+ pushl %eax
+ call _stop_monitor
+ popl %eax
#endif
+ pushl %eax
+ call exit
+ hlt /* die now ! will ya ... */
+.Lstart:
+ .size _start,.Lstart-_start
diff --git a/mdk-stage1/dietlibc/i386/stpcpy.S b/mdk-stage1/dietlibc/i386/stpcpy.S
new file mode 100644
index 000000000..1cb74b2ea
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/stpcpy.S
@@ -0,0 +1,22 @@
+.text
+.global stpcpy
+.type stpcpy,@function
+stpcpy:
+ pushl %edi
+ pushl %esi
+ movl 0xc(%esp), %edi
+ movl 0x10(%esp), %esi
+
+.Lcopy:
+ lodsb
+ stosb
+ testb %al, %al
+ jnz .Lcopy
+
+ movl %edi, %eax
+ decl %eax
+ popl %esi
+ popl %edi
+ ret
+.Lende:
+.size stpcpy,.Lende-stpcpy
diff --git a/mdk-stage1/dietlibc/i386/strcasecmp.S b/mdk-stage1/dietlibc/i386/strcasecmp.S
new file mode 100644
index 000000000..a836680db
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/strcasecmp.S
@@ -0,0 +1,31 @@
+.text
+.globl strcasecmp
+
+strcasecmp:
+ pushl %esi
+ movl 0x8(%esp), %esi
+ movl 0xc(%esp), %edx
+ xorl %eax, %eax
+ xorl %ecx, %ecx
+ cld
+.Lloop:
+ lodsb
+ movb (%edx), %cl
+ incl %edx
+ or %al, %al
+ jz .Lfinifirst
+ cmp $'A', %al
+ jnge .Lcmp
+ cmp $'z', %al
+ jg .Lcmp
+ or $0x20, %al
+ or $0x20, %cl
+.Lcmp:
+ subl %ecx, %eax
+ jz .Lloop
+.Lret:
+ popl %esi
+ ret
+.Lfinifirst:
+ subl %ecx, %eax
+ jmp .Lret
diff --git a/mdk-stage1/dietlibc/i386/strcat.S b/mdk-stage1/dietlibc/i386/strcat.S
new file mode 100644
index 000000000..e7d74ef13
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/strcat.S
@@ -0,0 +1,29 @@
+.text
+.align 0
+.global strcat
+.type strcat,@function
+strcat:
+ pushl %edi
+ pushl %esi
+
+ movl 12(%esp), %edi
+ movl 16(%esp), %esi
+
+ pushl %edi
+
+ xorl %eax, %eax
+ xorl %ecx, %ecx
+ decl %ecx
+ repne scasb
+ decl %edi
+
+.Lloop:
+ lodsb
+ stosb
+ testb %al, %al
+ jnz .Lloop
+
+ popl %eax
+ popl %esi
+ popl %edi
+ ret
diff --git a/mdk-stage1/dietlibc/i386/strchr.S b/mdk-stage1/dietlibc/i386/strchr.S
new file mode 100644
index 000000000..4515d9835
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/strchr.S
@@ -0,0 +1,22 @@
+
+.text
+.type strchr,@function
+.global strchr
+.weak index
+.type index,@function
+
+index:
+strchr:
+ movl 4(%esp),%ecx
+ movb 8(%esp),%dl
+.Lloop:
+ movb (%ecx),%al
+ cmpb %al,%dl
+ jz .Lfound
+ incl %ecx
+ testb %al,%al
+ jnz .Lloop
+ xorl %ecx,%ecx
+.Lfound:
+ movl %ecx,%eax
+ ret
diff --git a/mdk-stage1/dietlibc/i386/strcmp.S b/mdk-stage1/dietlibc/i386/strcmp.S
new file mode 100644
index 000000000..e01064ffb
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/strcmp.S
@@ -0,0 +1,31 @@
+.text
+.global strcmp
+.type strcmp,@function
+.weak strcoll
+.type strcoll,@function
+
+#ifdef HIGH_PERFORMANCE
+.align 16
+#endif
+
+.Ldiff:
+ movzbl (%edx), %ecx
+ subl %ecx, %eax # (unsigned char)*p - (unsigned char)*q, so wie die Original libc
+ ret # und ohne Überlaufprobleme:
+ # (int) ((signed char)c - (signed char)d) != (int)(signed char) ((unsigned char)c - (unsigned char)d)
+ # c = 'ä', d = 'e': left expression: -129, right expression: 127
+
+strcoll:
+strcmp:
+ movl 4(%esp), %ecx
+ movl 8(%esp), %edx
+ xorl %eax, %eax
+.Lloop: # Schleifenanfang liegt genau auf Modulanfang + 0x10, damit alignbar
+ movb (%ecx), %al
+ cmpb (%edx), %al
+ jnz .Ldiff
+ incl %edx
+ incl %ecx
+ testb %al, %al
+ jnz .Lloop
+ ret
diff --git a/mdk-stage1/dietlibc/i386/strcpy.S b/mdk-stage1/dietlibc/i386/strcpy.S
new file mode 100644
index 000000000..a597436bc
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/strcpy.S
@@ -0,0 +1,24 @@
+
+.text
+.align 0
+.global strcpy
+.type strcpy,@function
+strcpy:
+ pushl %esi
+ pushl %edi
+
+ movl 12(%esp), %edx
+ movl 16(%esp), %esi
+ movl %edx, %edi
+ cld
+
+.Lloop:
+ lodsb
+ stosb
+ orb %al, %al
+ jnz .Lloop
+
+ popl %edi
+ popl %esi
+ movl %edx,%eax
+ ret
diff --git a/mdk-stage1/dietlibc/i386/strlen.S b/mdk-stage1/dietlibc/i386/strlen.S
new file mode 100644
index 000000000..66f8ee553
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/strlen.S
@@ -0,0 +1,18 @@
+
+.text
+.type strlen,@function
+.global strlen
+
+strlen:
+ movl 4(%esp),%ecx
+ xorl %eax,%eax
+ jecxz .Lnull
+ decl %eax
+.Llbl: incl %eax
+ cmpb $0,(%ecx, %eax)
+ jne .Llbl
+.Lnull: ret
+
+.Lende:
+
+.size strlen,.Lende-strlen
diff --git a/mdk-stage1/dietlibc/i386/strncmp.S b/mdk-stage1/dietlibc/i386/strncmp.S
new file mode 100644
index 000000000..bf07b07d0
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/strncmp.S
@@ -0,0 +1,28 @@
+.text
+.align 0
+.global strncmp
+.type strncmp,@function
+strncmp:
+ push %ebx
+ movl %esp,%ebx
+ movl 12(%ebx),%edx
+ movl 16(%ebx),%ecx
+ movl 8(%ebx),%ebx
+.Lloop:
+ jecxz .Ldone
+ decl %ecx
+ movb (%ebx),%al
+ incl %edx
+ incl %ebx
+ movb %al,%ah
+ subb -1(%edx),%al
+ jnz .Lnotequal
+ testb %ah,%ah
+ jnz .Lloop
+
+.Ldone:
+ xorl %eax,%eax
+.Lnotequal:
+ movsx %al, %eax
+ popl %ebx
+ ret
diff --git a/mdk-stage1/dietlibc/i386/strncpy.S b/mdk-stage1/dietlibc/i386/strncpy.S
new file mode 100644
index 000000000..837b43c41
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/strncpy.S
@@ -0,0 +1,42 @@
+/*
+ Copyright (C) 2002 Thomas M. Ogrisegg
+
+ This is free software. You can redistribute and
+ modify it under the terms of the GNU General Public
+ Public License.
+
+ strncpy.S
+ i386 assembler implementation of strncpy(3)
+*/
+
+#include "dietfeatures.h"
+
+.text
+.globl strncpy
+.type strncpy,@function
+
+strncpy:
+ pushl %esi
+ pushl %edi
+ movl %esp, %ecx
+ movl 0x0c(%ecx), %edi
+ movl 0x10(%ecx), %esi
+ movl 0x14(%ecx), %ecx
+
+ movl %edi, %edx
+
+.Lloop:
+ dec %ecx
+ js .Lout
+ lodsb
+ stosb
+ or %al, %al
+ jnz .Lloop
+#ifdef WANT_FULL_POSIX_COMPAT
+ repnz stosb
+#endif
+.Lout:
+ movl %edx, %eax
+ popl %edi
+ popl %esi
+ ret
diff --git a/mdk-stage1/dietlibc/i386/strrchr.S b/mdk-stage1/dietlibc/i386/strrchr.S
new file mode 100644
index 000000000..9fd6e8b32
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/strrchr.S
@@ -0,0 +1,19 @@
+.text
+.globl strrchr
+.type strrchr,@function
+
+strrchr:
+ movl 0x4(%esp), %edx
+ movb 0x8(%esp), %cl
+ xorl %eax, %eax
+ decl %edx
+.Lloop:
+ incl %edx
+ cmpb $0x0,(%edx)
+ jz .Lret
+ cmpb %cl, (%edx)
+ jnz .Lloop
+ movl %edx, %eax
+ jmp .Lloop
+.Lret:
+ ret
diff --git a/mdk-stage1/dietlibc/i386/syscalls.h b/mdk-stage1/dietlibc/i386/syscalls.h
new file mode 100644
index 000000000..3cbf7b605
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/syscalls.h
@@ -0,0 +1,303 @@
+
+#define __NR_exit 1
+#define __NR_fork 2
+#define __NR_read 3
+#define __NR_write 4
+#define __NR_open 5
+#define __NR_close 6
+#define __NR_waitpid 7
+#define __NR_creat 8
+#define __NR_link 9
+#define __NR_unlink 10
+#define __NR_execve 11
+#define __NR_chdir 12
+#define __NR_time 13
+#define __NR_mknod 14
+#define __NR_chmod 15
+#define __NR_lchown 16
+#define __NR_break 17
+#define __NR_oldstat 18
+#define __NR_lseek 19
+#define __NR_getpid 20
+#define __NR_mount 21
+#define __NR_umount 22
+#define __NR_setuid 23
+#define __NR_getuid 24
+#define __NR_stime 25
+#define __NR_ptrace 26
+#define __NR_alarm 27
+#define __NR_oldfstat 28
+#define __NR_pause 29
+#define __NR_utime 30
+#define __NR_stty 31
+#define __NR_gtty 32
+#define __NR_access 33
+#define __NR_nice 34
+#define __NR_ftime 35
+#define __NR_sync 36
+#define __NR_kill 37
+#define __NR_rename 38
+#define __NR_mkdir 39
+#define __NR_rmdir 40
+#define __NR_dup 41
+#define __NR_pipe 42
+#define __NR_times 43
+#define __NR_prof 44
+#define __NR_brk 45
+#define __NR_setgid 46
+#define __NR_getgid 47
+#define __NR_signal 48
+#define __NR_geteuid 49
+#define __NR_getegid 50
+#define __NR_acct 51
+#define __NR_umount2 52
+#define __NR_lock 53
+#define __NR_ioctl 54
+#define __NR_fcntl 55
+#define __NR_mpx 56
+#define __NR_setpgid 57
+#define __NR_ulimit 58
+#define __NR_oldolduname 59
+#define __NR_umask 60
+#define __NR_chroot 61
+#define __NR_ustat 62
+#define __NR_dup2 63
+#define __NR_getppid 64
+#define __NR_getpgrp 65
+#define __NR_setsid 66
+#define __NR_sigaction 67
+#define __NR_sgetmask 68
+#define __NR_ssetmask 69
+#define __NR_setreuid 70
+#define __NR_setregid 71
+#define __NR_sigsuspend 72
+#define __NR_sigpending 73
+#define __NR_sethostname 74
+#define __NR_setrlimit 75
+#define __NR_getrlimit 76 /* Back compatible 2Gig limited rlimit */
+#define __NR_getrusage 77
+#define __NR_gettimeofday 78
+#define __NR_settimeofday 79
+#define __NR_getgroups 80
+#define __NR_setgroups 81
+#define __NR_select 82
+#define __NR_symlink 83
+#define __NR_oldlstat 84
+#define __NR_readlink 85
+#define __NR_uselib 86
+#define __NR_swapon 87
+#define __NR_reboot 88
+#define __NR_readdir 89
+#define __NR_mmap 90
+#define __NR_munmap 91
+#define __NR_truncate 92
+#define __NR_ftruncate 93
+#define __NR_fchmod 94
+#define __NR_fchown 95
+#define __NR_getpriority 96
+#define __NR_setpriority 97
+#define __NR_profil 98
+#define __NR_statfs 99
+#define __NR_fstatfs 100
+#define __NR_ioperm 101
+#define __NR_socketcall 102
+#define __NR_syslog 103
+#define __NR_setitimer 104
+#define __NR_getitimer 105
+#define __NR_stat 106
+#define __NR_lstat 107
+#define __NR_fstat 108
+#define __NR_olduname 109
+#define __NR_iopl 110
+#define __NR_vhangup 111
+#define __NR_idle 112
+#define __NR_vm86old 113
+#define __NR_wait4 114
+#define __NR_swapoff 115
+#define __NR_sysinfo 116
+#define __NR_ipc 117
+#define __NR_fsync 118
+#define __NR_sigreturn 119
+#define __NR_clone 120
+#define __NR_setdomainname 121
+#define __NR_uname 122
+#define __NR_modify_ldt 123
+#define __NR_adjtimex 124
+#define __NR_mprotect 125
+#define __NR_sigprocmask 126
+#define __NR_create_module 127
+#define __NR_init_module 128
+#define __NR_delete_module 129
+#define __NR_get_kernel_syms 130
+#define __NR_quotactl 131
+#define __NR_getpgid 132
+#define __NR_fchdir 133
+#define __NR_bdflush 134
+#define __NR_sysfs 135
+#define __NR_personality 136
+#define __NR_afs_syscall 137 /* Syscall for Andrew File System */
+#define __NR_setfsuid 138
+#define __NR_setfsgid 139
+#define __NR__llseek 140
+#define __NR_getdents 141
+#define __NR__newselect 142
+#define __NR_flock 143
+#define __NR_msync 144
+#define __NR_readv 145
+#define __NR_writev 146
+#define __NR_getsid 147
+#define __NR_fdatasync 148
+#define __NR__sysctl 149
+#define __NR_mlock 150
+#define __NR_munlock 151
+#define __NR_mlockall 152
+#define __NR_munlockall 153
+#define __NR_sched_setparam 154
+#define __NR_sched_getparam 155
+#define __NR_sched_setscheduler 156
+#define __NR_sched_getscheduler 157
+#define __NR_sched_yield 158
+#define __NR_sched_get_priority_max 159
+#define __NR_sched_get_priority_min 160
+#define __NR_sched_rr_get_interval 161
+#define __NR_nanosleep 162
+#define __NR_mremap 163
+#define __NR_setresuid 164
+#define __NR_getresuid 165
+#define __NR_vm86 166
+#define __NR_query_module 167
+#define __NR_poll 168
+#define __NR_nfsservctl 169
+#define __NR_setresgid 170
+#define __NR_getresgid 171
+#define __NR_prctl 172
+#define __NR_rt_sigreturn 173
+#define __NR_rt_sigaction 174
+#define __NR_rt_sigprocmask 175
+#define __NR_rt_sigpending 176
+#define __NR_rt_sigtimedwait 177
+#define __NR_rt_sigqueueinfo 178
+#define __NR_rt_sigsuspend 179
+#define __NR_pread 180
+#define __NR_pwrite 181
+#define __NR_chown 182
+#define __NR_getcwd 183
+#define __NR_capget 184
+#define __NR_capset 185
+#define __NR_sigaltstack 186
+#define __NR_sendfile 187
+#define __NR_getpmsg 188 /* some people actually want streams */
+#define __NR_putpmsg 189 /* some people actually want streams */
+#define __NR_vfork 190
+#define __NR_ugetrlimit 191 /* SuS compliant getrlimit */
+#define __NR_mmap2 192
+#define __NR_truncate64 193
+#define __NR_ftruncate64 194
+#define __NR_stat64 195
+#define __NR_lstat64 196
+#define __NR_fstat64 197
+#define __NR_lchown32 198
+#define __NR_getuid32 199
+#define __NR_getgid32 200
+#define __NR_geteuid32 201
+#define __NR_getegid32 202
+#define __NR_setreuid32 203
+#define __NR_setregid32 204
+#define __NR_getgroups32 205
+#define __NR_setgroups32 206
+#define __NR_fchown32 207
+#define __NR_setresuid32 208
+#define __NR_getresuid32 209
+#define __NR_setresgid32 210
+#define __NR_getresgid32 211
+#define __NR_chown32 212
+#define __NR_setuid32 213
+#define __NR_setgid32 214
+#define __NR_setfsuid32 215
+#define __NR_setfsgid32 216
+#define __NR_pivot_root 217
+#define __NR_mincore 218
+#define __NR_madvise 219
+#define __NR_madvise1 219 /* delete when C lib stub is removed */
+#define __NR_getdents64 220
+#define __NR_fcntl64 221
+#define __NR_security 223 /* syscall for security modules */
+#define __NR_gettid 224
+#define __NR_readahead 225
+#define __NR_setxattr 226
+#define __NR_lsetxattr 227
+#define __NR_fsetxattr 228
+#define __NR_getxattr 229
+#define __NR_lgetxattr 230
+#define __NR_fgetxattr 231
+#define __NR_listxattr 232
+#define __NR_llistxattr 233
+#define __NR_flistxattr 234
+#define __NR_removexattr 235
+#define __NR_lremovexattr 236
+#define __NR_fremovexattr 237
+#define __NR_tkill 238
+#define __NR_sendfile64 239
+#define __NR_futex 240
+#define __NR_sched_setaffinity 241
+#define __NR_sched_getaffinity 242
+#define __NR_set_thread_area 243
+#define __NR_get_thread_area 244
+#define __NR_io_setup 245
+#define __NR_io_destroy 246
+#define __NR_io_getevents 247
+#define __NR_io_submit 248
+#define __NR_io_cancel 249
+#define __NR_alloc_hugepages 250
+#define __NR_free_hugepages 251
+#define __NR_exit_group 252
+#define __NR_lookup_dcookie 253
+#define __NR_sys_epoll_create 254
+#define __NR_sys_epoll_ctl 255
+#define __NR_sys_epoll_wait 256
+#define __NR_remap_file_pages 257
+#define __NR_set_tid_address 258
+
+#define syscall_weak(name,wsym,sym) \
+.text; \
+.type wsym,@function; \
+.weak wsym; \
+wsym: ; \
+.type sym,@function; \
+.global sym; \
+sym: \
+ movb $__NR_##name,%al; \
+ jmp __unified_syscall; \
+.Lend##sym: ; \
+.size sym,.Lend##sym-sym
+
+#define syscall(name,sym) \
+.text; \
+.type sym,@function; \
+.global sym; \
+sym: \
+.ifle __NR_##name-255; \
+ movb $__NR_##name,%al; \
+ jmp __unified_syscall; \
+.else; \
+ movw $__NR_##name,%ax; \
+ jmp __unified_syscall_256; \
+.endif; \
+.Lend##sym: ; \
+.size sym,.Lend##sym-sym
+
+#ifndef __PIC__
+#define __socketcall(name,NAME) \
+.text; \
+.type name,@function; \
+.weak name; \
+name: ; \
+.global __libc_##name; \
+__libc_##name: ; \
+ movb $SYS_##NAME,%al; \
+ jmp socketcall; \
+.Lend##name:; \
+.size name,.Lend##name-name
+#else
+#define __socketcall(name,NAME)
+#endif
diff --git a/mdk-stage1/dietlibc/i386/tan.S b/mdk-stage1/dietlibc/i386/tan.S
new file mode 100644
index 000000000..4904c2d59
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/tan.S
@@ -0,0 +1,12 @@
+
+.text
+.type tan,@function
+.global tan
+tan:
+ fldl 4(%esp)
+ fsincos
+ fdivrp
+ ret
+
+.Lende:
+.size tan,.Lende-tan
diff --git a/mdk-stage1/dietlibc/i386/tanh.S b/mdk-stage1/dietlibc/i386/tanh.S
new file mode 100644
index 000000000..61d3f3376
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/tanh.S
@@ -0,0 +1,32 @@
+
+.text
+.type tanh,@function
+.global tanh
+
+tanh: # note: exp(x) = 2^(x*log2(e))
+ fldl2e
+ fmull 4(%esp) # x*log2(e)
+ fld %st(0) # x*log2(e) x*log2(e)
+ frndint # int(x*log2(e)) x*log2(e)
+ fxch # x*log2(e) int(x*log2(e))
+ fsub %st(1),%st(0) # frac(x*log2(e)) int(x*log2(e))
+ f2xm1 # 2^(fract(x*log2(e)))-1 int(x*log2(e))
+ fld1 # 1 2^(fract(x*log2(e)))-1 int(x*log2(e))
+ faddp %st(0),%st(1) # 2^(fract(x*log2(e))) int(x*log2(e))
+ fscale # 2^(x*log2(e)) int(x*log2(e))
+ fstp %st(1) # 2^(x*log2(e))
+
+# now we have y = exp(x), but tanh(x) = (y - 1/y) / (y + 1/y)
+
+ fld1
+ fdiv %st(1),%st(0) # 1/y y
+ fld %st(0) # 1/y 1/y y
+ fadd %st(2) # y+1/y 1/y y
+ fxch %st(2) # y 1/y y+1/y
+ fsubp # y-1/y y+1/y
+ fdivp # (y-1/y)/(y+1/y)
+ ret
+
+.Lende:
+
+.size tanh,.ende-tanh
diff --git a/mdk-stage1/dietlibc/i386/unified.S b/mdk-stage1/dietlibc/i386/unified.S
index f182bdb4b..989bf37b5 100644
--- a/mdk-stage1/dietlibc/i386/unified.S
+++ b/mdk-stage1/dietlibc/i386/unified.S
@@ -1,13 +1,33 @@
+
#include <dietfeatures.h>
.text
+.global __unified_syscall_256
+.type __unified_syscall_256,@function
+__unified_syscall_256:
+ movzwl %ax,%eax
+ jmp .L1
+.L2:
+.size __unified_syscall_256,.L2-__unified_syscall_256
+.weak exit
+exit:
+.global _exit
+.type _exit,@function
+_exit:
+ movb $1,%al
.global __unified_syscall
+.type __unified_syscall,@function
__unified_syscall:
+.size _exit,__unified_syscall-_exit
movzbl %al, %eax
+.L1:
push %edi
push %esi
push %ebx
movl %esp,%edi
+ /* we use movl instead of pop because otherwise a signal would
+ destroy the stack frame and crash the program, although it
+ would save a few bytes. */
movl 0x10(%edi),%ebx
movl 0x14(%edi),%ecx
movl 0x18(%edi),%edx
@@ -16,19 +36,24 @@ __unified_syscall:
int $0x80
cmp $-124,%eax
jbe .Lnoerror
-#ifdef WANT_THREAD_SAVE
+ neg %eax
+#ifdef WANT_THREAD_SAFE
movl %eax,%ebx
call __errno_location
- neg %ebx
movl %ebx,(%eax)
+ orl $-1,%eax
#else
- neg %eax
mov %eax,errno
+ sbb %eax,%eax # eax = eax - eax - CY = -1
#endif
- xor %eax,%eax
- dec %eax
.Lnoerror:
pop %ebx
pop %esi
pop %edi
+
+/* here we go and "reuse" the return for weak-void functions */
+#include "dietuglyweaks.h"
+
ret
+.L3:
+.size __unified_syscall,.L3-__unified_syscall
diff --git a/mdk-stage1/dietlibc/i386/usleep.S b/mdk-stage1/dietlibc/i386/usleep.S
new file mode 100644
index 000000000..7c0cc6ce7
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/usleep.S
@@ -0,0 +1,31 @@
+#include "PIC.h"
+
+.text
+.global usleep
+.type usleep,@function
+
+usleep:
+ movl 4(%esp),%eax
+ PIC_SAVE # non-PIC: empty line
+ PIC_INIT # non-PIC: empty line
+ xorl %edx,%edx
+ movl $1000000,%ecx
+ divl %ecx
+ imull $1000,%edx
+ pushl %edx
+ pushl %eax
+ movl %esp,%eax
+ pushl %eax
+ pushl %eax
+#ifdef __DYN_LIB
+ call nanosleep@PLT
+#else
+ call nanosleep
+#endif
+ addl $16,%esp
+ PIC_RESTORE # non-PIC: empty line
+ ret
+
+.Lende:
+.size usleep,.Lende-usleep
+
diff --git a/mdk-stage1/dietlibc/i386/vfork.S b/mdk-stage1/dietlibc/i386/vfork.S
new file mode 100644
index 000000000..c07c5f6af
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/vfork.S
@@ -0,0 +1,9 @@
+.text
+.globl vfork
+vfork:
+ popl %edx
+ xorl %eax,%eax
+ movb $190, %al
+ int $0x80
+ jmpl *%edx
+.size vfork, . - vfork
diff --git a/mdk-stage1/dietlibc/i386/write12.S b/mdk-stage1/dietlibc/i386/write12.S
new file mode 100644
index 000000000..a40f63a86
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/write12.S
@@ -0,0 +1,37 @@
+#include "PIC.h"
+
+.text
+
+.global __write1
+.type __write1,@function
+
+.global __write2
+.type __write2,@function
+
+ # regparm=1, daher Stringadresse in %eax
+__write2:
+ clc # CY = 0
+ .byte 0xB2 # zusammen mit nächstem Byte: mov dl,0xF9
+__write1:
+ stc # CY = 1
+ sbbl %ecx,%ecx # __write2: ecx=0, __write1: ecx=-1
+ incl %ecx
+ incl %ecx # __write2: ecx=2, __write1: ecx=1
+ xorl %edx,%edx
+ decl %edx
+.Lnext: incl %edx
+ cmpb %ch,(%edx,%eax) # ch=0, da bei beiden Filedescriptoren Bits 15:8 0 sind
+ jnz .Lnext # Stringlänge in edx, ohne eax zerstört zu haben
+ PIC_SAVE # non-PIC: empty line
+ PIC_INIT # non-PIC: empty line
+ pushl %edx
+ pushl %eax
+ pushl %ecx
+#ifdef __DYN_LIB
+ call write@PLT
+#else
+ call write # alles ruf uf dn Stack und ab damit
+#endif
+ addl $12,%esp # und das leidvolle Putzen
+ PIC_RESTORE # non-PIC: empty line
+ ret