kaem: scaffold/argv.kaem.

* scaffold/argv.c (strcmp): Remove.
(main): Update.
* scaffold/argv.kaem: New file.
This commit is contained in:
Jan Nieuwenhuizen 2019-10-23 22:15:36 +02:00
parent c65d20dcc0
commit 314dadd569
No known key found for this signature in database
GPG Key ID: F3C1A0D9C1D65273
3 changed files with 77 additions and 22 deletions

View File

@ -1,3 +1,5 @@
DEFINE mov____%edi,%ebp 89fd
DEFINE mov____%esp,%edi 89e7
:_start
push___%ebp
mov____%esp,%ebp
@ -15,14 +17,21 @@
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
mov____%esp,%edi ; M2-Planet calling convention pushes forward
mov____%ebp,%eax ; argc
add____$i8,%eax !4
movzbl_(%eax),%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
add____$i8,%esp !0x0
test___%eax,%eax

View File

@ -22,18 +22,7 @@
#include <string.h>
int
strcmp (char const *a, char const *b)
{
while (*a && *b && *a == *b)
{
a++;
b++;
}
return *a - *b;
}
int
main (int argc, char *argv[])
main (int argc, char **argv)
{
eputs ("Hi Mes!\n");
#if __MESC_MES__
@ -41,10 +30,11 @@ main (int argc, char *argv[])
#else
eputs ("MESC.GUILE\n");
#endif
if (argc > 1 && !strcmp (argv[1], "--help"))
{
eputs ("argc > 1 && --help\n");
return argc;
}
if (argc > 1)
if (strcmp (argv[1], "--help") == 0)
{
eputs ("argc > 1 && --help\n");
return argc;
}
return 42;
}

56
scaffold/argv.kaem Normal file
View File

@ -0,0 +1,56 @@
#!/bin/bash
# Copyright (C) 2019 Jeremiah Orians <jeremiah@pdp10.guru>
# 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
M2-Planet \
--debug \
--architecture x86 \
-f include/m2/lib.h \
-f lib/linux/x86-mes-m2/crt1.c \
-f lib/linux/x86-mes-m2/mini.c \
-f lib/string/strlen.c \
-f lib/m2/write.c \
-f lib/m2/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 \
--LittleEndian \
--architecture x86 \
-f lib/m2/x86/x86_defs.M1 \
-f lib/x86-mes/x86.M1 \
-f lib/linux/x86-mes-m2/crt1.M1 \
-f scaffold/argv.M1 \
-f scaffold/argv.blood-elf-M1 \
-o scaffold/argv.hex2
hex2 \
--LittleEndian \
--architecture x86 \
--BaseAddress 0x1000000 \
--exec_enable \
-f lib/x86-mes/elf32-header.hex2 \
-f scaffold/argv.hex2 \
-o scaffold/argv-m2
echo Now run: scaffold/argv-m2