kaem: scaffold/argv.kaem
This commit is contained in:
parent
59c1570c57
commit
fe2d7c7b4f
|
@ -1,3 +1,5 @@
|
||||||
|
DEFINE mov____%edi,%ebp 89fd
|
||||||
|
DEFINE mov____%esp,%edi 89e7
|
||||||
:_start
|
:_start
|
||||||
push___%ebp
|
push___%ebp
|
||||||
mov____%esp,%ebp
|
mov____%esp,%ebp
|
||||||
|
@ -15,14 +17,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
|
||||||
movzbl_(%eax),%eax
|
movzbl_(%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
|
||||||
|
|
|
@ -22,18 +22,19 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
int
|
int
|
||||||
strcmp (char const *a, char const *b)
|
strcmp (char *a, char *b)
|
||||||
{
|
{
|
||||||
while (*a && *b && *a == *b)
|
while (a[0] != 0 && b[0] != 0 && a[0] == b[0])
|
||||||
{
|
{
|
||||||
a++;
|
a = a + 1;
|
||||||
b++;
|
b = b + 1;
|
||||||
}
|
}
|
||||||
return *a - *b;
|
|
||||||
|
return a[0] - b[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
eputs ("Hi Mes!\n");
|
eputs ("Hi Mes!\n");
|
||||||
#if __MESC_MES__
|
#if __MESC_MES__
|
||||||
|
@ -41,7 +42,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"))
|
||||||
{
|
{
|
||||||
eputs ("argc > 1 && --help\n");
|
eputs ("argc > 1 && --help\n");
|
||||||
return argc;
|
return argc;
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
#!/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 lib/linux/x86-mes-m2/crt1.c \
|
||||||
|
-f lib/linux/x86-mes-m2/mini.c \
|
||||||
|
-f lib/m2/strlen.c \
|
||||||
|
-f lib/m2/write.c \
|
||||||
|
-f lib/m2/eputs.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
|
|
@ -36,7 +36,6 @@ M1 \
|
||||||
--LittleEndian \
|
--LittleEndian \
|
||||||
--architecture x86 \
|
--architecture x86 \
|
||||||
-f lib/m2/x86/x86_defs.M1 \
|
-f lib/m2/x86/x86_defs.M1 \
|
||||||
-f scaffold/extra.M1 \
|
|
||||||
-f lib/x86-mes/x86.M1 \
|
-f lib/x86-mes/x86.M1 \
|
||||||
-f lib/linux/x86-mes-m2/crt1.M1 \
|
-f lib/linux/x86-mes-m2/crt1.M1 \
|
||||||
-f scaffold/hello.M1 \
|
-f scaffold/hello.M1 \
|
||||||
|
|
Loading…
Reference in New Issue