diff --git a/lib/freebsd/x86-mes-gcc/_write.c b/lib/freebsd/x86-mes-gcc/_write.c index 54cfaf80..e9e7a0ba 100644 --- a/lib/freebsd/x86-mes-gcc/_write.c +++ b/lib/freebsd/x86-mes-gcc/_write.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017,2019,2020 Jan (janneke) Nieuwenhuizen + * Copyright © 2016,2017,2019,2020,2023 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -20,7 +20,7 @@ #include "mes/lib-mini.h" -#define SYS_exit "0x01" +#define SYS_write "0x04" // *INDENT-OFF* ssize_t diff --git a/lib/freebsd/x86-mes-gcc/crt1.c b/lib/freebsd/x86-mes-gcc/crt1.c index 151d0279..f282fbf2 100644 --- a/lib/freebsd/x86-mes-gcc/crt1.c +++ b/lib/freebsd/x86-mes-gcc/crt1.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen + * Copyright © 2017,2018,2019,2023 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -19,45 +19,20 @@ */ #include -//int main (int argc, char *argv[], char *envp[]); +int main (int argc, char *argv[], char *envp[]); // *INDENT-OFF* void _start () { asm ( - "mov $0,%%eax\n\t" - "mov %%eax,%0\n" - : "=r" (__stdin) - : //no inputs "" - ); - - asm ( - "mov $1,%%eax\n\t" - "mov %%eax,%0\n" - : "=r" (__stdout) - : //no inputs "" - ); - - asm ( - "mov $2,%%eax\n\t" - "mov %%eax,%0\n" - : "=r" (__stderr) - : //no inputs "" - ); - asm ( - "mov %%ebp,%%eax\n\t" - "add $4,%%eax\n\t" - "mov (%%eax),%%eax\n\t" - "add $3,%%eax\n\t" - "shl $2,%%eax\n\t" - "add %%ebp,%%eax\n\t" - "mov %%eax,%0\n\t" - "push %%eax\n\t" - : "=r" (environ) - : //no inputs "" - ); - asm ( + "mov %ebp,%eax\n\t" + "add $4,%eax\n\t" + "mov (%eax),%eax\n\t" + "add $3,%eax\n\t" + "shl $2,%eax\n\t" + "add %ebp,%eax\n\t" + "push %eax\n\t" "mov %ebp,%eax\n\t" "add $8,%eax\n\t" "push %eax\n\t" @@ -67,6 +42,7 @@ _start () "mov (%eax),%eax\n\t" "push %eax\n\t" + "call __init_io\n\t" "call main\n\t" "push %eax\n\t" diff --git a/lib/freebsd/x86-mes-mescc/crt1.c b/lib/freebsd/x86-mes-mescc/crt1.c index 83cde649..cb2ea878 100644 --- a/lib/freebsd/x86-mes-mescc/crt1.c +++ b/lib/freebsd/x86-mes-mescc/crt1.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017,2018,2019,2021 Jan (janneke) Nieuwenhuizen + * Copyright © 2017,2018,2019,2021,2023 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -19,21 +19,11 @@ */ #include "mes/lib-mini.h" - int main (int argc, char *argv[], char *envp[]); int _start () { - asm ("mov____$i8,%eax !0"); - asm ("mov____%eax,0x32 &__stdin"); - - asm ("mov____$i8,%eax !1"); - asm ("mov____%eax,0x32 &__stdout"); - - asm ("mov____$i8,%eax !2"); - asm ("mov____%eax,0x32 &__stderr"); - asm ("mov____%ebp,%eax"); asm ("add____$i8,%eax !4"); @@ -42,7 +32,6 @@ _start () asm ("shl____$i8,%eax !0x02"); asm ("add____%ebp,%eax"); - asm ("mov____%eax,0x32 &environ"); asm ("push___%eax"); asm ("mov____%ebp,%eax"); @@ -54,6 +43,7 @@ _start () asm ("mov____(%eax),%eax"); asm ("push___%eax"); + __init_io (); main (); asm ("mov____%eax,%ebx");