freebsd: lib: Use __init_io.
* * lib/freebsd/x86-mes-gcc/crt1.c (_start): Replace manual initialization of __stdin, __stdout, __stderr, and environ with __init_io (). * lib/freebsd/x86-mes-mescc/crt1.c (_start): Likewise. * lib/freebsd/x86-mes-gcc/_write.c (SYS_exit): Remove. (SYS_write): New define.
This commit is contained in:
parent
88eb90dd38
commit
3502ad4f73
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2016,2017,2019,2020,2023 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2017,2018,2019,2023 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -19,45 +19,20 @@
|
|||
*/
|
||||
|
||||
#include <mes/lib-mini.h>
|
||||
//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"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2017,2018,2019,2021 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2017,2018,2019,2021,2023 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* 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");
|
||||
|
|
Loading…
Reference in a new issue