diff --git a/.gitignore b/.gitignore index e4ff6828..017b7400 100644 --- a/.gitignore +++ b/.gitignore @@ -51,17 +51,20 @@ !/lib/tests/*/*.exit !/lib/tests/*/*.stdout +/scaffold/*.M1 +/scaffold/*.m2 +/scaffold/*.hex2 /scaffold/argv /scaffold/hello /scaffold/main /scaffold/micro-mes /scaffold/tiny-mes -/scaffold/tests/[0-9a][0-9a-z]-* -/scaffold/tests/t.* -!/scaffold/tests/*.c -!/scaffold/tests/*.exit -!/scaffold/tests/*.stdout +/scaffold/argv-m2 +/scaffold/hello-m2 +/scaffold/main-m2 +/scaffold/micro-mes-m2 +/scaffold/tiny-mes-m2 /.config.make /.store diff --git a/lib/linux/x86-mes-m2/crt1.M1 b/lib/linux/x86-mes-m2/crt1.M1 new file mode 100644 index 00000000..73396bf4 --- /dev/null +++ b/lib/linux/x86-mes-m2/crt1.M1 @@ -0,0 +1,52 @@ +### GNU Mes --- Maxwell Equations of Software +### Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen +### +### This file is part of GNU Mes. +### +### GNU Mes is free software; you can redistribute it and/or modify it +### under the terms of the GNU General Public License as published by +### the Free Software Foundation; either version 3 of the License, or (at +### your option) any later version. +### +### GNU Mes 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 General Public License for more details. +### +### You should have received a copy of the GNU General Public License +### along with GNU Mes. If not, see . + +:_start + push___%ebp + mov____%esp,%ebp + sub____$i32,%esp %0x1054 + mov____$i8,%eax !0 + mov____%eax,0x32 &GLOBAL___stdin + mov____$i8,%eax !1 + mov____%eax,0x32 &GLOBAL___stdout + mov____$i8,%eax !2 + mov____%eax,0x32 &GLOBAL___stderr + mov____%ebp,%eax + add____$i8,%eax !4 + movzbl_(%eax),%eax + add____$i8,%eax !3 + shl____$i8,%eax !0x02 + add____%ebp,%eax + mov____%eax,0x32 &GLOBAL_environ + push___%eax + mov____%ebp,%eax + add____$i8,%eax !8 + push___%eax + mov____%ebp,%eax + add____$i8,%eax !4 + movzbl_(%eax),%eax + push___%eax + call32 %FUNCTION_main + add____$i8,%esp !0x0 + test___%eax,%eax + mov____%eax,%ebx + mov____$i32,%eax %1 + int____$0x80 + hlt + leave + ret diff --git a/lib/linux/x86-mes-m2/crt1.c b/lib/linux/x86-mes-m2/crt1.c new file mode 100644 index 00000000..596e7748 --- /dev/null +++ b/lib/linux/x86-mes-m2/crt1.c @@ -0,0 +1,68 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen + * + * This file is part of GNU Mes. + * + * GNU Mes is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or (at + * your option) any later version. + * + * GNU Mes 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ + +#include "mes/lib-mini.h" + +int __stdin; +int __stdout; +int __stderr; +char **environ; +int main (int argc, char **argv, char **envp); + +/* FIXME: this is going to be called `FUNCTION__start' +int +_start () +{ + asm ("mov____$i8,%eax !0"); + asm ("mov____%eax,0x32 &GLOBAL___stdin"); + + asm ("mov____$i8,%eax !1"); + asm ("mov____%eax,0x32 &GLOBAL___stdout"); + + asm ("mov____$i8,%eax !2"); + asm ("mov____%eax,0x32 &GLOBAL___stderr"); + + asm ("mov____%ebp,%eax"); + asm ("add____$i8,%eax !4"); + + asm ("movzbl_(%eax),%eax"); + asm ("add____$i8,%eax !3"); + + asm ("shl____$i8,%eax !0x02"); + asm ("add____%ebp,%eax"); + asm ("mov____%eax,0x32 &GLOBAL_environ"); + asm ("push___%eax"); + + asm ("mov____%ebp,%eax"); + asm ("add____$i8,%eax !8"); + asm ("push___%eax"); + + asm ("mov____%ebp,%eax"); + asm ("add____$i8,%eax !4"); + asm ("movzbl_(%eax),%eax"); + asm ("push___%eax"); + main (); + + asm ("mov____%eax,%ebx"); + asm ("mov____$i32,%eax %1"); + asm ("int____$0x80"); + asm ("hlt"); +} +*/ diff --git a/lib/linux/x86-mes-m2/mini.c b/lib/linux/x86-mes-m2/mini.c new file mode 100644 index 00000000..68d999f2 --- /dev/null +++ b/lib/linux/x86-mes-m2/mini.c @@ -0,0 +1,37 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2016,2017,2019 Jan (janneke) Nieuwenhuizen + * + * This file is part of GNU Mes. + * + * GNU Mes is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or (at + * your option) any later version. + * + * GNU Mes 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ + +void +_exit () +{ + asm ("mov____$i32,%eax SYS_exit"); + asm ("mov____0x8(%ebp),%ebx !-4"); + asm ("int____$0x80"); +} + +void +_write (int filedes, void *buffer, int size) +{ + asm ("mov____$i32,%eax SYS_write"); + asm ("mov____0x8(%ebp),%ebx !-4"); + asm ("mov____0x8(%ebp),%ecx !-8"); + asm ("mov____0x8(%ebp),%edx !-12"); + asm ("int____$0x80"); +} diff --git a/lib/m2/x86/ELF-i386-debug.hex2 b/lib/m2/x86/ELF-i386-debug.hex2 new file mode 100644 index 00000000..4aed1d47 --- /dev/null +++ b/lib/m2/x86/ELF-i386-debug.hex2 @@ -0,0 +1,74 @@ +### Copyright (C) 2016 Jeremiah Orians +### Copyright (C) 2017 Jan Nieuwenhuizen +### This file is part of M2-Planet. +### +### M2-Planet is free software: you can redistribute it and/or modify +### it under the terms of the GNU General Public License as published by +### the Free Software Foundation, either version 3 of the License, or +### (at your option) any later version. +### +### M2-Planet 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 General Public License for more details. +### +### You should have received a copy of the GNU General Public License +### along with M2-Planet. If not, see . + +### stage0's hex2 format +### !