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/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.S15
-rw-r--r--mdk-stage1/dietlibc/i386/libm2.S666
-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/mmap.c16
-rw-r--r--mdk-stage1/dietlibc/i386/mmap64.S52
-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.S24
-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/write12.S37
60 files changed, 2498 insertions, 89 deletions
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..4429b6e22
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/ldexp.S
@@ -0,0 +1,15 @@
+.text
+.type ldexp,@function
+.global ldexp
+
+# double ldexp ( double value, int expo );
+
+ldexp:
+ fildl 12(%esp)
+ fldl 4(%esp)
+ fscale
+ fstp %st(1)
+ ret
+
+.ende:
+.size ldexp,.ende-ldexp
diff --git a/mdk-stage1/dietlibc/i386/libm2.S b/mdk-stage1/dietlibc/i386/libm2.S
new file mode 100644
index 000000000..8ad85b7f2
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/libm2.S
@@ -0,0 +1,666 @@
+.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 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
+
+.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..de01aa47f
--- /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
+ jcxz .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/mmap.c b/mdk-stage1/dietlibc/i386/mmap.c
deleted file mode 100644
index 26ecb55c0..000000000
--- a/mdk-stage1/dietlibc/i386/mmap.c
+++ /dev/null
@@ -1,16 +0,0 @@
-#include <linux/types.h>
-#include <linux/unistd.h>
-
-#define __NR__mmap __NR_mmap
-_syscall1(int,_mmap,unsigned long *,buffer)
-
-char *mmap(char *addr, size_t len, int prot, int flags, int fd, unsigned long off) {
- unsigned long buffer[6];
- buffer[0] = (unsigned long)addr;
- buffer[1] = (unsigned long)len;
- buffer[2] = (unsigned long)prot;
- buffer[3] = (unsigned long)flags;
- buffer[4] = (unsigned long)fd;
- buffer[5] = (unsigned long)off;
- return (char*) _mmap(buffer);
-}
diff --git a/mdk-stage1/dietlibc/i386/mmap64.S b/mdk-stage1/dietlibc/i386/mmap64.S
new file mode 100644
index 000000000..210fec6ce
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/mmap64.S
@@ -0,0 +1,52 @@
+#include <syscalls.h>
+#include <errno.h>
+
+.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
+ call __errno_location
+ 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..1c99b2d12
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/sin.S
@@ -0,0 +1,24 @@
+
+.text
+
+.global sinf,sin,sinl
+.type sinf,@function
+.type sin,@function
+.type sinl,@function
+sinf:
+ flds 4(%esp)
+ jmp __sin
+sin:
+ fldl 4(%esp)
+__sin:
+ call __fmod2pi
+ fsin
+ ret
+sinl:
+ fldt 4(%esp)
+ jmp __sin
+
+.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/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