kaem: scaffold/argv.kaem.
* scaffold/argv.c (strcmp): Remove. (main): Update. * scaffold/argv.kaem: New file. lib/x86-mes/x86.M1 (mov____%edi,%ebp, mov____%esp,%edi): New macro.
This commit is contained in:
parent
e8b426ebce
commit
488d3f6afa
|
@ -33,14 +33,21 @@
|
||||||
shl____$i8,%eax !0x02
|
shl____$i8,%eax !0x02
|
||||||
add____%ebp,%eax
|
add____%ebp,%eax
|
||||||
mov____%eax,0x32 &GLOBAL_environ
|
mov____%eax,0x32 &GLOBAL_environ
|
||||||
push___%eax
|
|
||||||
mov____%ebp,%eax
|
mov____%esp,%edi ; M2-Planet calling convention pushes forward
|
||||||
add____$i8,%eax !8
|
mov____%ebp,%eax ; argc
|
||||||
push___%eax
|
|
||||||
mov____%ebp,%eax
|
|
||||||
add____$i8,%eax !4
|
add____$i8,%eax !4
|
||||||
mov____(%eax),%eax
|
mov____(%eax),%eax
|
||||||
push___%eax
|
push___%eax
|
||||||
|
|
||||||
|
mov____%ebp,%eax ; argv
|
||||||
|
add____$i8,%eax !8
|
||||||
|
push___%eax
|
||||||
|
|
||||||
|
mov____0x32,%eax &GLOBAL_environ
|
||||||
|
push___%eax
|
||||||
|
|
||||||
|
mov____%edi,%ebp ; M2-Planet calling convention
|
||||||
call32 %FUNCTION_main
|
call32 %FUNCTION_main
|
||||||
add____$i8,%esp !0x0
|
add____$i8,%esp !0x0
|
||||||
test___%eax,%eax
|
test___%eax,%eax
|
||||||
|
|
|
@ -107,9 +107,11 @@ DEFINE mov____%ebx,0x32 891d
|
||||||
DEFINE mov____%ebx,0x32(%ebp) 899d
|
DEFINE mov____%ebx,0x32(%ebp) 899d
|
||||||
DEFINE mov____%ebx,0x8(%ebp) 895d
|
DEFINE mov____%ebx,0x8(%ebp) 895d
|
||||||
DEFINE mov____%ecx,(%ebx) 890b
|
DEFINE mov____%ecx,(%ebx) 890b
|
||||||
|
DEFINE mov____%edi,%ebp 89fd
|
||||||
DEFINE mov____%edx,%eax 89d0
|
DEFINE mov____%edx,%eax 89d0
|
||||||
DEFINE mov____%edx,%ebx 89d3
|
DEFINE mov____%edx,%ebx 89d3
|
||||||
DEFINE mov____%esp,%ebp 89e5
|
DEFINE mov____%esp,%ebp 89e5
|
||||||
|
DEFINE mov____%esp,%edi 89e7
|
||||||
DEFINE mov____(%eax),%cl 8a08
|
DEFINE mov____(%eax),%cl 8a08
|
||||||
DEFINE mov____(%eax),%cx 668b08
|
DEFINE mov____(%eax),%cx 668b08
|
||||||
DEFINE mov____(%eax),%eax 8b00
|
DEFINE mov____(%eax),%eax 8b00
|
||||||
|
|
|
@ -22,18 +22,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
int
|
int
|
||||||
strcmp (char const *a, char const *b)
|
main (int argc, char **argv)
|
||||||
{
|
|
||||||
while (*a && *b && *a == *b)
|
|
||||||
{
|
|
||||||
a++;
|
|
||||||
b++;
|
|
||||||
}
|
|
||||||
return *a - *b;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
main (int argc, char *argv[])
|
|
||||||
{
|
{
|
||||||
eputs ("Hi Mes!\n");
|
eputs ("Hi Mes!\n");
|
||||||
#if __MESC_MES__
|
#if __MESC_MES__
|
||||||
|
@ -41,7 +30,8 @@ main (int argc, char *argv[])
|
||||||
#else
|
#else
|
||||||
eputs ("MESC.GUILE\n");
|
eputs ("MESC.GUILE\n");
|
||||||
#endif
|
#endif
|
||||||
if (argc > 1 && !strcmp (argv[1], "--help"))
|
if (argc > 1)
|
||||||
|
if (strcmp (argv[1], "--help") == 0)
|
||||||
{
|
{
|
||||||
eputs ("argc > 1 && --help\n");
|
eputs ("argc > 1 && --help\n");
|
||||||
return argc;
|
return argc;
|
||||||
|
|
60
scaffold/argv.kaem
Normal file
60
scaffold/argv.kaem
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
#! /bin/sh
|
||||||
|
# Copyright © 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
|
#
|
||||||
|
# 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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# Usage:
|
||||||
|
# kaem --verbose --strict --file scaffold/argv.kaem
|
||||||
|
# scaffold/argv-m2
|
||||||
|
|
||||||
|
mes_cpu=${mes_cpu:-x86}
|
||||||
|
stage0_cpu=${stage0_cpu:-x86}
|
||||||
|
|
||||||
|
M2-Planet \
|
||||||
|
--debug \
|
||||||
|
--architecture ${stage0_cpu} \
|
||||||
|
-f include/m2/lib.h \
|
||||||
|
-f lib/linux/${mes_cpu}-mes-m2/crt1.c \
|
||||||
|
-f lib/linux/${mes_cpu}-mes-m2/_exit.c \
|
||||||
|
-f lib/linux/${mes_cpu}-mes-m2/_write.c \
|
||||||
|
-f lib/string/strlen.c \
|
||||||
|
-f lib/mes/mini-write.c \
|
||||||
|
-f lib/mes/eputs.c \
|
||||||
|
-f lib/string/strcmp.c \
|
||||||
|
-f scaffold/argv.c \
|
||||||
|
-o scaffold/argv.M1
|
||||||
|
|
||||||
|
blood-elf -f scaffold/argv.M1 -o scaffold/argv.blood-elf-M1
|
||||||
|
|
||||||
|
M1 \
|
||||||
|
--architecture ${stage0_cpu} \
|
||||||
|
--little-endian \
|
||||||
|
-f lib/m2/${mes_cpu}/${mes_cpu}_defs.M1 \
|
||||||
|
-f lib/${mes_cpu}-mes/${mes_cpu}.M1 \
|
||||||
|
-f lib/linux/${mes_cpu}-mes-m2/crt1.M1 \
|
||||||
|
-f scaffold/argv.M1 \
|
||||||
|
-f scaffold/argv.blood-elf-M1 \
|
||||||
|
-o scaffold/argv.hex2
|
||||||
|
|
||||||
|
hex2 \
|
||||||
|
--architecture ${stage0_cpu} \
|
||||||
|
--little-endian \
|
||||||
|
--base-address 0x1000000 \
|
||||||
|
-f lib/m2/${mes_cpu}/ELF-${mes_cpu}.hex2 \
|
||||||
|
-f scaffold/argv.hex2 \
|
||||||
|
-o scaffold/argv-m2
|
||||||
|
|
||||||
|
echo Now run: scaffold/argv-m2
|
Loading…
Reference in a new issue