* lib/x86-mes: Move from stage0.
* build-aux/build-cc.sh: Create libraries in lib/gcc. Update users.
* build-aux/build-mes.sh: Create libraries in lib/x86-mes. Update users.
* build-aux/build-mes-gcc.sh: Rename from build-mlibc.sh. Create
libraries in lib/x86-mes-gcc. Update callers.
* build-aux/cc-mes-gcc.sh: Rename from cc-mlibc.sh. Update callers.
*-
-*.blood-elf-M1
-*.blood-elf-hex2
-*.go
*~
.#*
-*.0-M1
-*.0-guile
-*.0-hex2
*.E
*.S
-*.o
*.blood-elf
+*.blood-elf-M1
+*.blood-elf-hex2
*.gcc
+*.gcc-o
+*.gcc-out
+*.go
*.guile
*.log
-*.gcc-o
+*.mes-gcc
+*.mes-gcc-o
+*.mes-gcc-out
+*.mes-gcc-out
+*.mes-gcc-stdout
*.mes-o
+*.mes-out
*.mes-stdout
*.mini-M1
*.mini-guile
*.mini-hex2
-*.mlibc-gcc
-*.mlibc-o
-*.mlibc-out
-*.mlibc-stdout
+*.o
+*.seed-out
*.stderr
*.stdout
-*.tcc-guile
-!/stage0/*
-!/stage0/*.c
-/stage0/exit-42.*
/src/*.h
/src/*.i
/.store
/.tarball-version
/ChangeLog
-/a.out
-*.gcc-out
-*.mes-out
-*.mlibc-out
-*.seed-out
#keep this: bootstrap
#/mes.mes
cc:
build-aux/build-cc.sh
-mlibc:
- build-aux/build-mlibc.sh
+mes-gcc:
+ build-aux/build-mes-gcc.sh
mes:
build-aux/build-mes.sh
MES=$(GUILE) GUILE=$(GUILE) SEED=1 build-aux/build-mes.sh
cd $(MES_SEED) && MES_PREFIX=$(PWD) ./refresh.sh
MES=$(GUILE) GUILE=$(GUILE) SEED=1 build-aux/build-mes.sh
- build-aux/build-mlibc.sh
+ build-aux/build-mes-gcc.sh
cd $(TINYCC_SEED) && MES_PREFIX=$(PWD) ./refresh.sh
define HELP_TOP
all update everything
all-go update .go files
cc update src/mes.gcc-out
- mlibc update src/mes.mlibc-out
+ mes-gcc update src/mes.mes-gcc-out
mes update src/mes
check run unit tests
clean run git clean -dfx
build-aux/mes-snarf.scm src/reader.c
build-aux/mes-snarf.scm src/vector.c
+ARCHDIR=1 NOLINK=1 sh build-aux/cc.sh lib/libmes
sh build-aux/cc.sh src/mes
--- /dev/null
+#! /bin/sh
+
+# Mes --- Maxwell Equations of Software
+# Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
+#
+# This file is part of Mes.
+#
+# 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.
+#
+# 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 Mes. If not, see <http://www.gnu.org/licenses/>.
+
+set -e
+
+if [ -n "$BUILD_DEBUG" ]; then
+ set -x
+fi
+
+export CC32 CPPFLAGS C32FLAGS
+
+CC32=${CC32-$(command -v i686-unknown-linux-gnu-gcc)}
+build-aux/mes-snarf.scm --mes src/gc.c
+build-aux/mes-snarf.scm --mes src/lib.c
+build-aux/mes-snarf.scm --mes src/math.c
+build-aux/mes-snarf.scm --mes src/mes.c
+build-aux/mes-snarf.scm --mes src/posix.c
+build-aux/mes-snarf.scm --mes src/reader.c
+build-aux/mes-snarf.scm --mes src/vector.c
+
+build-aux/mes-snarf.scm src/gc.c
+build-aux/mes-snarf.scm src/lib.c
+build-aux/mes-snarf.scm src/math.c
+build-aux/mes-snarf.scm src/mes.c
+build-aux/mes-snarf.scm src/posix.c
+build-aux/mes-snarf.scm src/reader.c
+build-aux/mes-snarf.scm src/vector.c
+
+CPPFLAGS=${CPPFLAGS-"
+-D VERSION=\"$VERSION\"
+-D MODULEDIR=\"$MODULEDIR\"
+-D PREFIX=\"$PREFIX\"
+-I src
+-I lib
+-I include
+"}
+
+C32FLAGS=${C32FLAGS-"
+--std=gnu99
+-O0
+-fno-stack-protector
+-g
+-m32
+-nostdinc
+-nostdlib
+"}
+
+ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes-gcc.sh lib/crt1
+ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes-gcc.sh lib/libc-mini
+ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes-gcc.sh lib/libc
+ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes-gcc.sh lib/libc+tcc
+
+sh build-aux/cc-mes-gcc.sh scaffold/main
+sh build-aux/cc-mes-gcc.sh scaffold/hello
+sh build-aux/cc-mes-gcc.sh scaffold/argv
+sh build-aux/cc-mes-gcc.sh scaffold/malloc
+sh build-aux/cc-mes-gcc.sh scaffold/micro-mes
+sh build-aux/cc-mes-gcc.sh scaffold/tiny-mes
+sh build-aux/cc-mes-gcc.sh scaffold/mini-mes
+
+sh build-aux/cc-mes-gcc.sh src/mes
if [ -d "$MES_SEED" ]; then
$M1\
$M1FLAGS\
- -f stage0/x86.M1\
- -f $MES_SEED/crt1.M1\
- -o lib/crt1.o
+ -f lib/x86-mes/x86.M1\
+ -f $MES_SEED/x86-mes/crt1.S\
+ -o lib/x86-mes/crt1.o
$M1\
$M1FLAGS\
- -f stage0/x86.M1\
- -f $MES_SEED/libc-mes.M1\
- -o lib/libc-mes.o
+ -f lib/x86-mes/x86.M1\
+ -f $MES_SEED/x86-mes/libc.S\
+ -o lib/x86-mes/libc.o
$M1\
--LittleEndian\
--Architecture=1\
- -f stage0/x86.M1\
- -f $MES_SEED/mes.M1\
+ -f lib/x86-mes/x86.M1\
+ -f $MES_SEED/x86-mes/mes.S\
-o src/mes.o
$BLOOD_ELF\
- -f stage0/x86.M1\
- -f $MES_SEED/mes.M1\
- -f $MES_SEED/libc-mes.M1\
+ -f lib/x86-mes/x86.M1\
+ -f $MES_SEED/x86-mes/mes.S\
+ -f $MES_SEED/x86-mes/libc.S\
-o src/mes.S.blood-elf
$M1\
--LittleEndian\
-o src/mes.o.blood-elf
$HEX2\
$HEX2FLAGS\
- -f stage0/elf32-header.hex2\
- -f lib/crt1.o\
- -f lib/libc-mes.o\
+ -f lib/x86-mes/elf32-header.hex2\
+ -f lib/x86-mes/crt1.o\
+ -f lib/x86-mes/libc.o\
-f src/mes.o\
-f src/mes.o.blood-elf\
--exec_enable\
cp src/mes.seed-out src/mes
$M1\
$M1FLAGS\
- -f stage0/x86.M1\
- -f $MES_SEED/libc+tcc-mes.M1\
- -o lib/libc+tcc-mes.o
+ -f lib/x86-mes/x86.M1\
+ -f $MES_SEED/x86-mes/libc+tcc.S\
+ -o lib/x86-mes/libc+tcc.o
fi
PREPROCESS=1
-NOLINK=1 sh build-aux/cc-mes.sh lib/crt1
-NOLINK=1 sh build-aux/cc-mes.sh lib/libc-mini-mes
-NOLINK=1 sh build-aux/cc-mes.sh lib/libc-mes
-NOLINK=1 sh build-aux/cc-mes.sh lib/libc+tcc-mes
-
-cp lib/crt1.mes-o lib/crt1.o
-cp lib/libc-mini-mes.mes-o lib/libc-mini-mes.o
-cp lib/libc-mes.mes-o lib/libc-mes.o
-cp lib/libc+tcc-mes.mes-o lib/libc+tcc-mes.o
+ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes.sh lib/crt1
+ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes.sh lib/libc-mini
+ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes.sh lib/libc
+ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes.sh lib/libc+tcc
[ -n "$SEED" ] && exit 0
-MES_ARENA=${MES_ARENA-30000000}
+MES_ARENA=${MES_ARENA-10000000}
sh build-aux/mes-snarf.scm --mes src/gc.c
sh build-aux/mes-snarf.scm --mes src/lib.c
sh build-aux/mes-snarf.scm --mes src/math.c
+++ /dev/null
-#! /bin/sh
-
-# Mes --- Maxwell Equations of Software
-# Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
-#
-# This file is part of Mes.
-#
-# 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.
-#
-# 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 Mes. If not, see <http://www.gnu.org/licenses/>.
-
-set -e
-
-if [ -n "$BUILD_DEBUG" ]; then
- set -x
-fi
-
-export CC32 CPPFLAGS C32FLAGS
-
-CC32=${CC32-$(command -v i686-unknown-linux-gnu-gcc)}
-build-aux/mes-snarf.scm --mes src/gc.c
-build-aux/mes-snarf.scm --mes src/lib.c
-build-aux/mes-snarf.scm --mes src/math.c
-build-aux/mes-snarf.scm --mes src/mes.c
-build-aux/mes-snarf.scm --mes src/posix.c
-build-aux/mes-snarf.scm --mes src/reader.c
-build-aux/mes-snarf.scm --mes src/vector.c
-
-build-aux/mes-snarf.scm src/gc.c
-build-aux/mes-snarf.scm src/lib.c
-build-aux/mes-snarf.scm src/math.c
-build-aux/mes-snarf.scm src/mes.c
-build-aux/mes-snarf.scm src/posix.c
-build-aux/mes-snarf.scm src/reader.c
-build-aux/mes-snarf.scm src/vector.c
-
-CPPFLAGS=${CPPFLAGS-"
--D VERSION=\"$VERSION\"
--D MODULEDIR=\"$MODULEDIR\"
--D PREFIX=\"$PREFIX\"
--I src
--I lib
--I include
-"}
-
-C32FLAGS=${C32FLAGS-"
---std=gnu99
--O0
--fno-stack-protector
--g
--m32
--nostdinc
--nostdlib
-"}
-
-NOLINK=1 sh build-aux/cc-mlibc.sh lib/crt1
-NOLINK=1 sh build-aux/cc-mlibc.sh lib/libc-mini-gcc
-NOLINK=1 sh build-aux/cc-mlibc.sh lib/libc-gcc
-NOLINK=1 sh build-aux/cc-mlibc.sh lib/libc+tcc-gcc
-
-sh build-aux/cc-mlibc.sh scaffold/main
-sh build-aux/cc-mlibc.sh scaffold/hello
-sh build-aux/cc-mlibc.sh scaffold/argv
-sh build-aux/cc-mlibc.sh scaffold/malloc
-sh build-aux/cc-mlibc.sh scaffold/micro-mes
-sh build-aux/cc-mlibc.sh scaffold/tiny-mes
-sh build-aux/cc-mlibc.sh scaffold/mini-mes
-
-sh build-aux/cc-mlibc.sh src/mes
--- /dev/null
+#! /bin/sh
+
+# Mes --- Maxwell Equations of Software
+# Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
+#
+# This file is part of Mes.
+#
+# 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.
+#
+# 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 Mes. If not, see <http://www.gnu.org/licenses/>.
+
+set -e
+
+if [ -n "$BUILD_DEBUG" ]; then
+ set -x
+fi
+
+CPPFLAGS=${CPPFLAGS-"
+-D VERSION=\"$VERSION\"
+-D MODULEDIR=\"$MODULEDIR\"
+-D PREFIX=\"$PREFIX\"
+-I src
+-I lib
+-I include
+"}
+
+C32FLAGS=${C32FLAGS-"
+--std=gnu99
+-O0
+-fno-builtin
+-fno-stack-protector
+-g
+-m32
+-nostdinc
+-nostdlib
+"}
+LIBC=${LIBC-c}
+if [ -n "$LIBC" ]; then
+ CC32LIBS="lib/x86-mes-gcc/lib$LIBC.o"
+fi
+
+c=$1
+
+if [ -z "$ARCHDIR" ]; then
+ o="$c"
+ p="mes-gcc-"
+else
+ b=${c##*/}
+ d=${c%/*}
+ o="$d/x86-mes-gcc/$b"
+ mkdir -p $d/x86-mes-gcc
+fi
+
+$CC32\
+ -c\
+ $CPPFLAGS\
+ $C32FLAGS\
+ -o "$o".${p}o\
+ "$c".c
+
+if [ -z "$NOLINK" ]; then
+ $CC32\
+ $C32FLAGS\
+ -o "$o".${p}out\
+ lib/x86-mes-gcc/crt1.o\
+ "$o".${p}o\
+ $CC32LIBS
+fi
set -e
+if [ -z "$ARCHDIR" ]; then
+ o="$c"
+ p="mes-"
+else
+ b=${c##*/}
+ d=${c%/*}
+ o="$d/x86-mes/$b"
+ mkdir -p $d/x86-mes
+fi
+
if [ -n "$PREPROCESS" ]; then
- sh $MESCC $MESCCFLAGS $CPPFLAGS -E "$c".c
- sh $MESCC $MESCCFLAGS -S "$c".E
- sh $MESCC $MESCCFLAGS -c -o "$c".mes-o "$c".S
+ sh $MESCC $MESCCFLAGS $CPPFLAGS -E -o "$o.E" "$c".c
+ sh $MESCC $MESCCFLAGS -S "$o".E
+ sh $MESCC $MESCCFLAGS -c -o "$o".${p}o "$o".S
if [ -z "$NOLINK" ]; then
- sh $MESCC $MESCCFLAGS -o "$c".mes-out "$c".mes-o $MESCCLIBS
+ sh $MESCC $MESCCFLAGS -o "$o".${p}out "$o".${p}o $MESCCLIBS
fi
elif [ -n "$COMPILE" ]; then
- sh $MESCC $MESCCFLAGS $CPPFLAGS -S "$c".c
- sh $MESCC $MESCCFLAGS -c -o "$c".mes-o "$c".S
+ sh $MESCC $MESCCFLAGS $CPPFLAGS -S -o "$o.S" "$c".c
+ sh $MESCC $MESCCFLAGS -c -o "$o".${p}o "$o".S
if [ -z "$NOLINK" ]; then
- sh $MESCC $MESCCFLAGS -o "$c".mes-out "$c".mes-o $MESCCLIBS
+ sh $MESCC $MESCCFLAGS -o "$o".${p}out "$o".${p}o $MESCCLIBS
fi
elif [ -z "$NOLINK" ]; then
- sh $MESCC $MESCCFLAGS $CPPFLAGS -o "$c".mes-out "$c".c $MESCCLIBS
+ sh $MESCC $MESCCFLAGS $CPPFLAGS -o "$o".${p}out "$c".c $MESCCLIBS
else
- sh $MESCC $MESCCFLAGS $CPPFLAGS -c -o "$c".mes-out "$c".c
+ sh $MESCC $MESCCFLAGS $CPPFLAGS -c -o "$o".${p}out "$c".c
fi
+++ /dev/null
-#! /bin/sh
-
-# Mes --- Maxwell Equations of Software
-# Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
-#
-# This file is part of Mes.
-#
-# 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.
-#
-# 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 Mes. If not, see <http://www.gnu.org/licenses/>.
-
-set -e
-
-if [ -n "$BUILD_DEBUG" ]; then
- set -x
-fi
-
-CPPFLAGS=${CPPFLAGS-"
--D VERSION=\"$VERSION\"
--D MODULEDIR=\"$MODULEDIR\"
--D PREFIX=\"$PREFIX\"
--I src
--I lib
--I include
-"}
-
-C32FLAGS=${C32FLAGS-"
---std=gnu99
--O0
--fno-builtin
--fno-stack-protector
--g
--m32
--nostdinc
--nostdlib
-"}
-LIBC=${LIBC-lib/libc}
-
-c=$1
-
-$CC32\
- -c\
- $CPPFLAGS\
- $C32FLAGS\
- -o "$c".mlibc-o\
- "$c".c
-
-if [ -z "$NOLINK" ]; then
- $CC32\
- $C32FLAGS\
- -o "$c".mlibc-out\
- lib/crt1.mlibc-o\
- "$c".mlibc-o\
- $LIBC-gcc.mlibc-o\
- $CC32LIBS
-fi
c=$1
+if [ -z "$ARCHDIR" ]; then
+ o="$c"
+ p="gcc-"
+else
+ b=${c##*/}
+ d=${c%/*}
+ o="$d/gcc/$b"
+ mkdir -p $d/gcc
+fi
+
$CC\
-c\
$CPPFLAGS\
$CFLAGS\
-D POSIX=1\
- -o "$c".gcc-o\
+ -o "$o".${p}o\
"$c".c
if [ -z "$NOLINK" ]; then
$CC\
$CFLAGS\
- -o "$c".gcc-out\
- "$c".gcc-o\
- lib/libc-gcc.gcc-o
+ -o "$o".${p}out\
+ "$o".${p}o\
+ lib/gcc/libmes.o
fi
export M1FLAGS HEX2FLAGS PREPROCESS
export MES_ARENA MES_PREFIX MES_SEED
export BUILD_DEBUG
-export CC32LIBS MESCCLIBS
+export LIBC CC32LIBS MESCCLIBS
MES=${MES-src/mes}
MESCC=${MESCC-scripts/mescc}
pass=0
fail=0
total=0
-MESCCLIBS=
-LIBC=libc/libc
for t in $tests; do
if [ -z "${t/[012][0-9]-*/}" ]; then
- LIBC="lib/libc-mini"
+ LIBC=c-mini
MESCCLIBS="-l c-mini"
elif [ -z "${t/8[0-9]-*/}" ]; then
- LIBC="lib/libc+tcc"
+ LIBC=c+tcc
MESCCLIBS="-l c+tcc"
else
- LIBC=libc/libc
+ LIBC=c
MESCCLIBS=
fi
sh build-aux/test.sh "scaffold/tests/$t" &> scaffold/tests/"$t".log
42_function_pointer
46_grep
49_bracket_evaluation
+55_lshift_type
"
#22_floating_point ; float
set -e
-rm -f "$t".mlibc-out
+rm -f "$t".mes-gcc-out
if [ -n "$CC32" ]; then
- sh build-aux/cc-mlibc.sh "$t"
+ sh build-aux/cc-mes-gcc.sh "$t"
r=0
[ -f "$t".exit ] && r=$(cat "$t".exit)
set +e
- "$t".mlibc-out > "$t".mlibc-stdout
+ "$t".mes-gcc-out > "$t".mes-gcc-stdout
m=$?
- cat "$t".mlibc-stdout
+ cat "$t".mes-gcc-stdout
set -e
[ $m = $r ]
if [ -f "$t".expect ]; then
- $DIFF -ub "$t".expect "$t".mlibc-stdout;
+ $DIFF -ub "$t".expect "$t".mes-gcc-stdout;
fi
fi
MESCC=${MESCC-$(command -v mescc)}
MES_SEED=${MES_SEED-../mes-seed}
GUILE=${GUILE-$(command -v guile)}
-MES_ARENA=${MES_ARENA-300000000}
+MES_ARENA=${MES_ARENA-100000000}
MES_DEBUG=${MES_DEBUG-1}
PREFIX=${PREFIX-/usr/local}
fi
if [ -n "$CC32" ]; then
- sh build-aux/build-mlibc.sh
- cp src/mes.mlibc-out src/mes
+ sh build-aux/build-mes-gcc.sh
+ cp src/mes.mes-gcc-out src/mes
fi
sh build-aux/build-mes.sh
CC32=${CC32-$(command -v i686-unknown-linux-gnu-gcc)}
GUILE=${GUILE-guile}
MES=${MES-src/mes}
-MES_ARENA=${MES_ARENA-300000000}
+MES_ARENA=${MES_ARENA-100000000}
PREFIX=
if ! command -v $GUILE > /dev/null; then
* along with Mes. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <libmes.h>
+
int test ();
int
cp scripts/mescc $PREFIX/bin/mescc
mkdir -p $MES_PREFIX
-tar -cf- doc guile include lib module scaffold stage0 | tar -xf- -C $MES_PREFIX
+tar -cf- doc guile include lib module scaffold | tar -xf- -C $MES_PREFIX
GUILE_EFFECTIVE_VERSION=${GUILE_EFFECTIVE_VERSION-2.2}
DATADIR=${MODULEDIR-$PREFIX/share/mes}
#include <sys/time.h>
#include <unistd.h>
-#include <libc-gcc.c>
-#include <linux+tcc-gcc.c>
-#include <libc+tcc.c>
-#include <getopt.c>
-#include <m4.c>
-
int errno;
void
#include <sys/time.h>
#include <unistd.h>
-#include <libc-mes.c>
-#include <linux+tcc-mes.c>
-#include <libc+tcc.c>
-#include <getopt.c>
-
int errno;
void
#include <sys/time.h>
#include <unistd.h>
+#include <libc.c>
+
+#if __MESC__
+
+#include <linux+tcc-mes.c>
+#include <libc+tcc-mes.c>
+#include <getopt.c>
+
+#else // !__MESC__
+
+#include <linux+tcc-gcc.c>
+#include <libc+tcc-gcc.c>
+#include <getopt.c>
+#include <m4.c>
+
+#endif // !__MESC__
+
int
dlclose (void *handle)
{
int
fseek (FILE *stream, long offset, int whence)
{
- return lseek ((int)stream, offset, whence);
+ int pos = lseek ((int)stream, offset, whence);
+ if (pos >= 0)
+ return 0;
+ return -1;
}
int
+++ /dev/null
-/* -*-comment-start: "//";comment-end:""-*-
- * Mes --- Maxwell Equations of Software
- * Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
- *
- * This file is part of Mes.
- *
- * 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.
- *
- * 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 Mes. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <libmes.h>
-#include <stdio.h>
-
-#include <libmes.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include <fcntl.h>
-#include <assert.h>
-
-#include <linux-mini-gcc.c>
-#include <libc-mini.c>
-#include <linux-gcc.c>
-#include <libmes.c>
-#include <libc.c>
+++ /dev/null
-/* -*-comment-start: "//";comment-end:""-*-
- * Mes --- Maxwell Equations of Software
- * Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
- *
- * This file is part of Mes.
- *
- * 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.
- *
- * 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 Mes. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <libmes.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-void _env ();
-
-#include <linux-mini-mes.c>
-#include <libc-mini.c>
-#include <linux-mes.c>
-#include <libmes.c>
-#include <libc.c>
+++ /dev/null
-/* -*-comment-start: "//";comment-end:""-*-
- * Mes --- Maxwell Equations of Software
- * Copyright © 2016,2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
- *
- * This file is part of Mes.
- *
- * 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.
- *
- * 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 Mes. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <linux-mini-gcc.c>
-#include <libc-mini.c>
+++ /dev/null
-/* -*-comment-start: "//";comment-end:""-*-
- * Mes --- Maxwell Equations of Software
- * Copyright © 2016,2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
- *
- * This file is part of Mes.
- *
- * 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.
- *
- * 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 Mes. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <linux-mini-mes.c>
-#include <libc-mini.c>
write (1, s, i);
return 0;
}
+
+#if __MESC__
+
+#include <linux-mini-mes.c>
+
+#else // !__MESC__
+
+#include <linux-mini-gcc.c>
+
+#endif // !__MESC__
#include <sys/ioctl.h>
#include <stdarg.h>
#include <stdlib.h>
+#include <libmes.h>
+#include <stdio.h>
+
+#include <libmes.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#if __MESC__
+
+#include <linux-mes.c>
+
+#else // !__MESC__
+
+#include <fcntl.h>
+#include <assert.h>
+
+#include <linux-gcc.c>
+
+#endif // !__MESC__
+
+#include <libc-mini.c>
+#include <libmes.c>
int g_stdin = 0;
void _env ();
int
-eputc (int c)
+getchar ()
+{
+ return fdgetc (g_stdin);
+}
+
+int
+putchar (int c)
{
- return fdputc (c, STDERR);
+ write (STDOUT, (char*)&c, 1);
+ return 0;
}
int
/* Everything else is a read */
fd = open (file_name, 0, 0);
- /* Negative numbers are error codes */
- if (fd > 0)
- return 0;
-
return (FILE*)fd;
}
*/
#include <libmes.h>
+#include <string.h>
+#include <unistd.h>
int
isdigit (int c)
return 0;
}
-int
-putchar (int c)
-{
- write (STDOUT, (char*)&c, 1);
- return 0;
-}
-
int
fdputs (char const* s, int fd)
{
return c;
}
+#if POSIX
+#define STDERR 2
+int
+eputs (char const* s)
+{
+ int i = strlen (s);
+ write (STDERR, s, i);
+ return 0;
+}
+#endif
+
int
-getchar ()
+eputc (int c)
{
- return fdgetc (g_stdin);
+ return fdputc (c, STDERR);
}
--- /dev/null
+### Copyright (C) 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
+### This file is part of stage0.
+###
+### stage0 is free software: you an 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.
+###
+### stage0 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 stage0. If not, see <http://www.gnu.org/licenses/>.
+
+### stage0's hex2 format for x86
+### !<label> 1 byte relative
+### $<label> 2 byte address
+### @<label> 2 byte relative
+### &<label> 4 byte address
+### %<label> 4 byte relative
+### local_<label> function-local
+### string_<index> string #<index>
+
+:ELF_end
--- /dev/null
+### Copyright (C) 2016 Jeremiah Orians
+### Copyright (C) 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
+### This file is part of stage0.
+###
+### stage0 is free software: you an 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.
+###
+### stage0 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 stage0. If not, see <http://www.gnu.org/licenses/>.
+
+### stage0's hex2 format for x86
+### !<label> 1 byte relative
+### $<label> 2 byte address
+### @<label> 2 byte relative
+### &<label> 4 byte address
+### %<label> 4 byte relative
+### local_<label> function-local
+### string_<index> string #<index>
+
+### elf32-header-exit-42.hex2: 32 bit elf header in hex2 for `exit 42'
+
+:ELF_base
+7F 45 4C 46 # e_ident[EI_MAG0-3] ELF's magic number
+
+01 # e_ident[EI_CLASS] Indicating 32 bit
+01 # e_ident[EI_DATA] Indicating little endianness
+01 # e_ident[EI_VERSION] Indicating original elf
+
+00 # e_ident[EI_OSABI] Set at 0 because none cares
+00 # e_ident[EI_ABIVERSION] See above
+
+00 00 00 00 00 00 00 # e_ident[EI_PAD]
+
+02 00 # e_type Indicating Executable
+03 00 # e_machine Indicating AMD64
+01 00 00 00 # e_version Indicating original elf
+
+&ELF_text # e_entry Address of the entry point
+%ELF_program_headers>ELF_base # e_phoff Address of program header table
+00 00 00 00 # e_shoff Address of section header table
+
+00 00 00 00 # e_flags
+
+34 00 # e_ehsize Indicating our 52 Byte header
+
+20 00 # e_phentsize size of a program header table
+01 00 # e_phnum number of entries in program table
+
+00 00 # e_shentsize size of a section header table
+00 00 # e_shnum number of entries in section table
+
+00 00 # e_shstrndx index of the section names
+
+# @34
+00 00 00 00
+00 00 00 00
+00 00 00 00
+
+# @40
+:ELF_program_headers
+:ELF_program_header__text
+01 00 00 00 # ph_type: PT-LOAD = 1
+00 00 00 00 # ph_offset
+&ELF_base # ph_vaddr
+&ELF_base # ph_physaddr
+%ELF_end>ELF_base # ph_filesz
+%ELF_end>ELF_base # ph_memsz
+07 00 00 00 # ph_flags: PF-X|PF-W|PF-R = 7
+01 00 00 00 # ph_align
+
+:ELF_text
--- /dev/null
+### Copyright (C) 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
+### This file is part of stage0.
+###
+### stage0 is free software: you an 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.
+###
+### stage0 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 stage0. If not, see <http://www.gnu.org/licenses/>.
+
+### stage0's hex2 format for x86
+### !<label> 1 byte relative
+### $<label> 2 byte address
+### @<label> 2 byte relative
+### &<label> 4 byte address
+### %<label> 4 byte relative
+### local_<label> function-local
+### string_<index> string #<index>
+
+### elf32-body-exit-42.hex2: 32 bit elf body in hex2 for `exit 42'
+
+# @200
+:ELF_text
+:_start
+# exit(42)
+e8 %main # call +11 <main>
+00 00 00
+00 00 00 00
+00 00 00 00
+
+# @210
+:main
+bb 2a 00 00 00 # mov $42,%ebx
+b8 01 00 00 00 # mov $0x1,%eax
+cd 80 # int $0x80
+
+00 00 00 00
+
+# @220
+:ELF_data
+65 78 69 74 34 32 20 64 61 74 61 20 68 65 72 65 # exit42 data here"
+
--- /dev/null
+### Copyright (C) 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
+### This file is part of stage0.
+###
+### stage0 is free software: you an 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.
+###
+### stage0 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 stage0. If not, see <http://www.gnu.org/licenses/>.
+
+### stage0's hex2 format for x86
+### !<label> 1 byte relative
+### $<label> 2 byte address
+### @<label> 2 byte relative
+### &<label> 4 byte address
+### %<label> 4 byte relative
+### local_<label> function-local
+### string_<index> string #<index>
+
+### elf32-footer-single-main.hex2: 32 bit elf footer in hex2 for single main
+
+# @230
+
+:ELF_str
+00 # 0
+:ELF_str__start
+5f 73 74 61 72 74 00 # _start
+:ELF_str__main
+6d 61 69 6e 00 # main
+
+00 00 00
+
+# @240
+:ELF_sym
+00 00 00 00 # st-name
+00 00 00 00 # st-offset: &_start - BaseAddress
+00 00 00 00 # st-len : &main - _start
+00 # st-info = stt-func= 2
+00 # st-other
+01 00 # st-shndx: 1
+
+# _start
+%ELF_str__start>ELF_str # st-name
+&_start
+10 00 00 00 # st-len : &main - _start
+02 # st-info = stt-func= 2
+00 # st-other
+01 00 # st-shndx: 1
+
+# main
+%ELF_str__main>ELF_str # st-name
+&main
+10 00 00 00 # st-len : &ELF_data - main
+02 # st-info = stt-func= 2
+00 # st-other
+01 00 # st-shndx: 1
+
+:ELF_end
--- /dev/null
+### Copyright (C) 2016 Jeremiah Orians
+### Copyright (C) 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
+### This file is part of stage0.
+###
+### stage0 is free software: you an 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.
+###
+### stage0 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 stage0. If not, see <http://www.gnu.org/licenses/>.
+
+### stage0's hex2 format for x86
+### !<label> 1 byte relative
+### $<label> 2 byte address
+### @<label> 2 byte relative
+### &<label> 4 byte address
+### %<label> 4 byte relative
+### local_<label> function-local
+### string_<index> string #<index>
+
+### elf32-header-exit-42.hex2: 32 bit elf header in hex2 for `exit 42'
+
+:ELF_base
+7F 45 4C 46 # e_ident[EI_MAG0-3] ELF's magic number
+
+01 # e_ident[EI_CLASS] Indicating 32 bit
+01 # e_ident[EI_DATA] Indicating little endianness
+01 # e_ident[EI_VERSION] Indicating original elf
+
+00 # e_ident[EI_OSABI] Set at 0 because none cares
+00 # e_ident[EI_ABIVERSION] See above
+
+00 00 00 00 00 00 00 # e_ident[EI_PAD]
+
+02 00 # e_type Indicating Executable
+03 00 # e_machine Indicating AMD64
+01 00 00 00 # e_version Indicating original elf
+
+&ELF_text # e_entry Address of the entry point
+%ELF_program_headers>ELF_base # e_phoff Address of program header table
+%ELF_section_headers>ELF_base # e_shoff Address of section header table
+
+00 00 00 00 # e_flags
+
+34 00 # e_ehsize Indicating our 52 Byte header
+
+20 00 # e_phentsize size of a program header table
+02 00 # e_phnum number of entries in program table
+
+28 00 # e_shentsize size of a section header table
+07 00 # e_shnum number of entries in section table
+
+04 00 # e_shstrndx index of the section names
+
+# @34
+00 00 00 00
+00 00 00 00
+00 00 00 00
+
+# @40
+:ELF_program_headers
+:ELF_program_header__text
+01 00 00 00 # ph_type: PT-LOAD = 1
+00 00 00 00 # ph_offset
+&ELF_base # ph_vaddr
+&ELF_base # ph_physaddr
+%ELF_end>ELF_base # ph_filesz
+%ELF_end>ELF_base # ph_memsz
+07 00 00 00 # ph_flags: PF-X|PF-W|PF-R = 7
+01 00 00 00 # ph_align
+
+# @60
+:ELF_program_header__data
+01 00 00 00 # ph_type: PT-LOAD = 1
+00 00 00 00 # ph_offset
+&ELF_base # ph_vaddr
+&ELF_base # ph_physaddr
+%ELF_end>ELF_base # ph_filesz
+%ELF_end>ELF_base # ph_memsz
+07 00 00 00 # ph_flags: PF-X|PF-W|PF-R = 7
+01 00 00 00 # ph_align
+
+# @80
+:ELF_comment
+4d 45 53 00 # MES
+00 00 00 00 # align
+00 00 00 00
+00 00 00 00
+
+4d 45 53 00 # MES
+00 00 00 00 # align
+00 00 00 00
+00 00 00 00
+
+# @a0
+:ELF_shstr
+00
+:ELF_shstr__text
+2e 74 65 78 74 00 # .text
+:ELF_shstr__data
+2e 64 61 74 61 00 # .data
+:ELF_shstr__comment
+2e 63 6f 6d 6d 65 6e 74 00 # .comment
+:ELF_shstr__shstr
+2e 73 68 73 74 72 74 61 62 00 # .shstrtab
+:ELF_shstr__sym
+2e 73 79 6d 74 61 62 00 # .symtab
+:ELF_shstr__str
+2e 73 74 72 74 61 62 00 # .strtab
+
+# @d0
+
+:ELF_section_headers
+00 00 00 00 # sh_name
+00 00 00 00 # sh_type
+00 00 00 00 # sh_flags
+00 00 00 00 # sh_addr
+00 00 00 00 # sh_offset
+00 00 00 00 # sh_length
+00 00 00 00 # sh_link
+00 00 00 00 # sh_info
+01 00 00 00 # sh_1?
+00 00 00 00 # sh_entsize
+
+## FIXME: M0 for calculations?
+:ELF_section_header_text
+%ELF_shstr__text>ELF_shstr # sh_name
+01 00 00 00 # sh_type = SHT_PROGBITS = 1
+06 00 00 00 # sh_flags = SHF-ALLOC|SHF-EXEC =2 | 4 = 6
+&ELF_text # sh_addr
+%ELF_text>ELF_base # sh_offset
+%ELF_data>ELF_text # sh_length
+00 00 00 00 # sh_link
+00 00 00 00 # sh_info
+01 00 00 00 # sh_1?
+00 00 00 00 # sh_entsize
+
+:ELF_section_header_data
+%ELF_shstr__data>ELF_shstr # sh_name
+01 00 00 00 # sh_type = SHT_PROGBITS = 1
+03 00 00 00 # sh_flags = SHF-WRITE|SHF-ALLOC = 1 | 2 = 3
+&ELF_data # sh_addr
+%ELF_data>ELF_base # sh_offset
+%ELF_sym>ELF_data # sh_length
+00 00 00 00 # sh_link
+00 00 00 00 # sh_info
+01 00 00 00 # sh_1?
+00 00 00 00 # sh_entsize
+
+:ELF_section_header_comment
+%ELF_shstr__comment>ELF_shstr # sh_name
+01 00 00 00 # sh_type = SHT_PROGBITS = 1
+00 00 00 00 # sh_flags
+&ELF_comment # sh_addr
+%ELF_comment>ELF_base # sh_offset
+%ELF_shstr>ELF_comment # sh_length
+00 00 00 00 # sh_link
+00 00 00 00 # sh_info
+01 00 00 00 # sh_1?
+00 00 00 00 # sh_entsize
+
+:ELF_section_header_shstr
+%ELF_shstr__shstr>ELF_shstr # sh_name
+03 00 00 00 # sh_type: str-sht-strtab
+00 00 00 00 # sh_flags
+&ELF_shstr # sh_addr
+%ELF_shstr>ELF_base # sh_offset
+%ELF_section_headers>ELF_shstr # sh_length
+00 00 00 00 # sh_link
+00 00 00 00 # sh_info
+01 00 00 00 # sh_1?
+00 00 00 00 # sh_entsize
+
+:ELF_section_header_sym
+%ELF_shstr__sym>ELF_shstr # sh_name
+02 00 00 00 # sh_type: str-sht-symtab
+00 00 00 00 # sh_flags
+&ELF_sym # sh_addr
+%ELF_sym>ELF_base # sh_offset
+%ELF_end>ELF_sym # sh_length
+06 00 00 00 # sh_link:6
+00 00 00 00 # sh_info
+01 00 00 00 # sh_1?
+10 00 00 00 # sh_entsize
+
+:ELF_section_header_str
+%ELF_shstr__str>ELF_shstr # sh_name
+03 00 00 00 # sh_type: str-sht-strtab
+00 00 00 00 # sh_flags
+&ELF_str # sh_addr
+%ELF_str>ELF_base # sh_offset
+%ELF_sym>ELF_str # sh_length
+00 00 00 00 # sh_link
+00 00 00 00 # sh_info
+01 00 00 00 # sh_1?
+00 00 00 00 # sh_entsize
+
+# @1e8
+00 00 00 00 # align
+00 00 00 00
+
+# @1f0
+
+00 00 00 00 # align
+00 00 00 00
+00 00 00 00
+00 00 00 00
+
+# @200
+:ELF_text
--- /dev/null
+/* -*-comment-start: "//";comment-end:""-*-
+ * Mes --- Maxwell Equations of Software
+ * Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
+ *
+ * This file is part of Mes.
+ *
+ * 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.
+ *
+ * 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 Mes. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+int
+main (int argc, char *argv[])
+{
+ return 42;
+}
--- /dev/null
+### Mes --- Maxwell Equations of Software
+### Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
+###
+### This file is part of Mes.
+###
+### 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.
+###
+### 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 Mes. If not, see <http://www.gnu.org/licenses/>.
+
+
+DEFINE add____$i32,%eax 05
+DEFINE add____$i32,%ecx 81c1
+DEFINE add____$i32,%edx 81c2
+DEFINE add____$i32,(%eax) 8100
+DEFINE add____$i32,0x32(%eax) 8180
+DEFINE add____$i32,0x32(%ebp) 8185
+DEFINE add____$i8,%eax 83c0
+DEFINE add____$i8,%edx 83c2
+DEFINE add____$i8,%esp 83c4
+DEFINE add____$i8,(%eax) 8300
+DEFINE add____$i8,0x32 8305
+DEFINE add____$i8,0x32(%eax) 8380
+DEFINE add____$i8,0x32(%eax) 8380
+DEFINE add____$i8,0x32(%ebp) 8385
+DEFINE add____$i8,0x8(%eax) 8340
+DEFINE add____$i8,0x8(%ebp) 8345
+DEFINE add____%eax,%eax 01c0
+DEFINE add____%ebp,%eax 01e8
+DEFINE add____%edx,%eax 01d0
+DEFINE add____%edx,%eax 01d0
+DEFINE and____$i32,%eax 25
+DEFINE and____%edx,%eax 21d0
+DEFINE and____(%edx),%eax 2302
+DEFINE call32 e8
+DEFINE call___*%eax ffd0
+DEFINE cmp____$0x32,%eax 3d
+DEFINE cmp____$i32,%eax 3d
+DEFINE cmp____$i32,0x32(%ebp) 81bd
+DEFINE cmp____$i32,0x8(%ebp) 817d
+DEFINE cmp____$i8,%eax 83f8
+DEFINE cmp____$i8,0x32(%ebp) 83bd
+DEFINE cmp____$i8,0x8(%ebp) 837d
+DEFINE cmp____%al,%dl 38c2
+DEFINE cmp____%edx,%eax 39d0
+DEFINE hlt f4
+DEFINE idiv___%ebx f7fb
+DEFINE int cd
+DEFINE int____$0x80 cd80
+DEFINE ja32 0f87
+DEFINE jae32 0f83
+DEFINE jb32 0f82
+DEFINE jbe32 0f86
+DEFINE je32 0f84
+DEFINE je8 74
+DEFINE jg32 0f8f
+DEFINE jge32 0f8d
+DEFINE jl32 0f8c
+DEFINE jle32 0f8e
+DEFINE jmp32 e9
+DEFINE jmp____*%ebx ffe3
+DEFINE jne32 0f85
+DEFINE lahf 9f
+DEFINE lea____0x32(%ebp),%eax 8d85
+DEFINE lea____0x32(%ebp),%edx 8d95
+DEFINE lea____0x8(%ebp),%eax 8d45
+DEFINE lea____0x8(%ebp),%edx 8d55
+DEFINE leave c9
+DEFINE mov____$i32,%eax b8
+DEFINE mov____$i32,%ebx bb
+DEFINE mov____$i32,%ecx b9
+DEFINE mov____$i32,%edx ba
+DEFINE mov____$i32,(%eax) c700
+DEFINE mov____$i32,0x32 c705
+DEFINE mov____$i32,0x8(%eax) c740
+DEFINE mov____$i32,0x8(%ebp) c745
+DEFINE mov____%al,(%edx) 8802
+DEFINE mov____%al,0x8(%edx) 8842
+DEFINE mov____%ax,(%edx) 668902
+DEFINE mov____%ax,0x32(%edx) 668982
+DEFINE mov____%ax,0x8(%edx) 668942
+DEFINE mov____%dl,(%eax) 8810
+DEFINE mov____%dl,0x8(%eax) 8850
+DEFINE mov____%eax,%ebx 89c3
+DEFINE mov____%eax,%edx 89c2
+DEFINE mov____%eax,(%ecx) 8901
+DEFINE mov____%eax,(%edx) 8902
+DEFINE mov____%eax,0x32 a3
+DEFINE mov____%eax,0x32(%ebp) 8985
+DEFINE mov____%eax,0x32(%edx) 8982
+DEFINE mov____%eax,0x8(%ebp) 8945
+DEFINE mov____%eax,0x8(%edx) 8942
+DEFINE mov____%ebp,%eax 89e8
+DEFINE mov____%ebp,%ecx 89e9
+DEFINE mov____%ebp,%edx 89ea
+DEFINE mov____%ebx,0x32 891d
+DEFINE mov____%ebx,0x32(%ebp) 899d
+DEFINE mov____%ebx,0x8(%ebp) 895d
+DEFINE mov____%ebx,0x8(%edx) 895a
+DEFINE mov____%ecx,(%eax) 8908
+DEFINE mov____%ecx,(%edx) 890a
+DEFINE mov____%ecx,0x32(%ebp) 898d
+DEFINE mov____%ecx,0x8(%ebp) 894d
+DEFINE mov____%edx,%eax 89d0
+DEFINE mov____%edx,%ebx 89d3
+DEFINE mov____%edx,%ecx 89d1
+DEFINE mov____%edx,(%eax) 8910
+DEFINE mov____%edx,0x32(%ebp) 8995
+DEFINE mov____%edx,0x8(%ebp) 8955
+DEFINE mov____%esp,%ebp 89e5
+DEFINE mov____(%eax),%eax 8b00
+DEFINE mov____(%eax),%ecx 8b08
+DEFINE mov____(%edx),%eax 8b02
+DEFINE mov____(%edx),%ecx 8b0a
+DEFINE mov____(%edx),%edx 8b12
+DEFINE mov____0x32(%eax),%eax 8b80
+DEFINE mov____0x32(%eax),%ebx 8b98
+DEFINE mov____0x32(%eax),%ecx 8b88
+DEFINE mov____0x32(%ebp),%eax 8b85
+DEFINE mov____0x32(%ebp),%eax 8b85
+DEFINE mov____0x32(%ebp),%ebx 8b9d
+DEFINE mov____0x32(%ebp),%ecx 8b8d
+DEFINE mov____0x32(%ebp),%edx 8b95
+DEFINE mov____0x32(%ebp),%edx 8b95
+DEFINE mov____0x32,%eax a1
+DEFINE mov____0x32,%edx 8b15
+DEFINE mov____0x8(%eax),%eax 8b40
+DEFINE mov____0x8(%eax),%ebx 8b58
+DEFINE mov____0x8(%eax),%ecx 8b48
+DEFINE mov____0x8(%ebp),%eax 8b45
+DEFINE mov____0x8(%ebp),%ebp 8b6d
+DEFINE mov____0x8(%ebp),%ebx 8b5d
+DEFINE mov____0x8(%ebp),%ecx 8b4d
+DEFINE mov____0x8(%ebp),%edx 8b55
+DEFINE mov____0x8(%ebp),%esp 8b65
+DEFINE movsbl_%al,%eax 0fbec0
+DEFINE movswl_%ax,%eax 0fbfc0
+DEFINE movzbl_%al,%eax 0fb6c0
+DEFINE movzbl_%al,%eax 0fb6c0
+DEFINE movzbl_%dl,%edx 0fb6d2
+DEFINE movzbl_(%eax),%eax 0fb600
+DEFINE movzbl_(%eax),%edx 0fb610
+DEFINE movzbl_(%edx),%edx 0fb612
+DEFINE movzbl_0x32(%eax),%eax 0fb680
+DEFINE movzbl_0x8(%eax),%eax 0fb640
+DEFINE movzbl_0x8(%ebp),%eax 0fb645
+DEFINE movzwl_%ax,%eax 0fb7c0
+DEFINE movzwl_(%eax),%eax 0fb700
+DEFINE movzwl_0x32(%eax),%eax 0fb780
+DEFINE movzwl_0x32(%ebp),%eax 0fb785
+DEFINE movzwl_0x8(%eax),%eax 0fb740
+DEFINE mul____%edx f7e2
+DEFINE nop 90
+DEFINE not____%eax f7d0
+DEFINE or_____%edx,%eax 09d0
+DEFINE or_____(%edx),%eax 0b02
+DEFINE pop____%eax 58
+DEFINE pop____%edx 5a
+DEFINE push___$i32 68
+DEFINE push___%eax 50
+DEFINE push___%ebp 55
+DEFINE push___%edx 52
+DEFINE push___(%eax) ff30
+DEFINE push___0x32(%ebp) ffb5
+DEFINE push___0x8(%ebp) ff75
+DEFINE ret c3
+DEFINE sahf 9e
+DEFINE seta___%al 0f97c0
+DEFINE setae__%al 0f93c0
+DEFINE setb___%al 0f92c0
+DEFINE setbe__%al 0f96c0
+DEFINE sete___%al 0f94c0
+DEFINE setg___%al 0f9fc0
+DEFINE setge__%al 0f9dc0
+DEFINE setl___%al 0f9cc0
+DEFINE setle__%al 0f9ec0
+DEFINE setne__%al 0f95c0
+DEFINE shl____$i8,%eax c1e0
+DEFINE shl____%cl,%eax d3e0
+DEFINE shr____%cl,%eax d3e8
+DEFINE sub____%al,%dl 28d0
+DEFINE sub____%dl,%al 28c2
+DEFINE sub____%eax,%edx 29c2
+DEFINE sub____%edx,%eax 29d0
+DEFINE sub____%edx,%eax 29d0
+DEFINE sub____%esp,$i32 81ec
+DEFINE sub____%esp,$i8 83ec
+DEFINE test___%al,%al 84c0
+DEFINE test___%eax,%eax 85c0
+DEFINE xchg___%eax,(%esp) 870424
+DEFINE xor____$i32,%eax 35
+DEFINE xor____$i8,%ah 80f4
+DEFINE xor____%eax,%eax 31c0
+DEFINE xor____%ebx,%ebx 31db
+DEFINE xor____%ecx,%ecx 31c9
+DEFINE xor____%edx,%eax 31d0
+DEFINE xor____%edx,%edx 31d2
+
+# Deprecated. Remove after 0.14 release.
+DEFINE mov____%al,0x32(%ebp) 8885
+DEFINE mov____%al,0x8(%ebp) 8845
+DEFINE mov____%ax,0x32(%ebp) 668985
+DEFINE mov____%ax,0x8(%ebp) 668945
+DEFINE movzbl_0x32(%ebp),%eax 0fb685
+DEFINE movzbl_0x8(%ebp),%edx 0fb655
+DEFINE movzwl_0x8(%ebp),%eax 0fb745
+DEFINE movzwl_0x8(%ebp),%eax 0fb745
+
+DEFINE SYS_exit 01000000
+DEFINE SYS_fork 02000000
+DEFINE SYS_read 03000000
+DEFINE SYS_write 04000000
+DEFINE SYS_open 05000000
+DEFINE SYS_close 06000000
+DEFINE SYS_waitpid 07000000
+DEFINE SYS_unlink 0a000000
+DEFINE SYS_execve 0b000000
+DEFINE SYS_chmod 0f000000
+DEFINE SYS_lseek 13000000
+DEFINE SYS_access 21000000
+DEFINE SYS_brk 2d000000
+DEFINE SYS_ioctl 36000000
+DEFINE SYS_fsync 76000000
+DEFINE SYS_getcwd b7000000
hex2-file-name))
(define (mescc:link options)
- (define (library->hex2 o)
- (prefix-file options (string-append "lib/lib" o "-mes.o")))
(let* ((files (option-ref options '() '("a.c")))
(source-files (filter (disjoin .c? .E?) files))
(S-files (filter .S? files))
(list (infos->hex2 options hex2-file-name infos)))))
(libraries (filter-map (multi-opt 'library) options))
(libraries (if (pair? libraries) libraries '("c")))
- (hex2-libraries (map library->hex2 libraries))
+ (hex2-libraries (map (cut find-library options ".o" <>) libraries))
(hex2-files (append hex2-files hex2-libraries))
- (S-files (append S-files (map (cut replace-suffix <> ".S") hex2-libraries)))
+ (S-files (append S-files (map (cut find-library options ".S" <>) libraries)))
(debug-info? (option-ref options 'debug-info #f))
(S-files (cons (replace-suffix input-file-name ".S") S-files))
(elf-footer (and debug-info?
(command `(,M1
"--LittleEndian"
"--Architecture=1"
- "-f" ,(prefix-file options "stage0/x86.M1")
+ "-f" ,(arch-find options "x86.M1")
,@(append-map (cut list "-f" <>) M1-files)
"-o" ,hex2-file-name)))
(when verbose?
(elf-file-name (cond ((option-ref options 'output #f))
(else (replace-suffix input-file-name ""))))
(verbose? (option-ref options 'verbose #f))
- (elf-footer (or elf-footer (prefix-file options "stage0/elf32-footer-single-main.hex2")))
+ (elf-footer (or elf-footer (arch-find options "elf32-footer-single-main.hex2")))
(hex2 (or (getenv "HEX2") "hex2"))
(command `(,hex2
"--LittleEndian"
"--Architecture=1"
"--BaseAddress=0x1000000"
- "-f" ,(prefix-file options "stage0/elf32-header.hex2")
- "-f" ,(prefix-file options "lib/crt1.o")
+ "-f" ,(arch-find options "elf32-header.hex2")
+ "-f" ,(arch-find options "crt1.o")
,@(append-map (cut list "-f" <>) hex2-files)
"-f" ,elf-footer
"--exec_enable"
"-o" ,elf-file-name)))
(when verbose?
- (stderr "command=~s\n" command)
- (format (current-error-port) "~a\n" (string-join command)))
+ (stderr "~a\n" (string-join command)))
(and (zero? (apply system* command))
elf-file-name)))
(verbose? (option-ref options 'verbose #f))
(blood-elf (or (getenv "BLOOD_ELF") "blood-elf"))
(command `(,blood-elf
- "-f" ,(prefix-file options "stage0/x86.M1")
+ "-f" ,(arch-find options "x86.M1")
,@(append-map (cut list "-f" <>) M1-files)
"-o" ,M1-blood-elf-footer)))
(when verbose?
(base (if (pair? (cdr parts)) (drop-right parts 1))))
(string-append (string-join base ".") suffix)))
+(define (find-library options ext o)
+ (arch-find options (string-append "lib" o ext)))
+
+(define* (arch-find options file-name)
+ (let* ((path (cons (prefix-file options "lib")
+ (filter-map (multi-opt 'library-dir) options)))
+ (arch-file-name (string-append "x86-mes/" file-name))
+ (verbose? (option-ref options 'verbose #f)))
+ (when verbose?
+ (stderr "arch-find=~s\n" arch-file-name)
+ (stderr " path=~s\n" path)
+ (stderr " => ~s\n" (search-path path arch-file-name)))
+ (search-path path arch-file-name)))
+
(define (prefix-file options file-name)
(let ((prefix (option-ref options 'prefix "")))
(define (prefix-file o)
(if (string-null? prefix) o (string-append prefix "/" o)))
(prefix-file file-name)))
+
(define (multi-opt option-name) (lambda (o) (and (eq? (car o) option-name) (cdr o))))
(define (.c? o) (or (string-suffix? ".c" o)
struct foo *hash_ident[10];
-#if !defined (__TINYC__)
-void *
-memset (void *s, int c, size_t n)
-{
- char *p = s;
- while (n--) *p++ = c;
- return s;
-}
-#endif
-
int
test ()
{
#include <stdlib.h>
#include <string.h>
-#if !defined ( __TINYC__)
-unsigned long long
-strtoull (char const *p, char **end, int base)
-{
- *end = p;
- return abtoi (end, base);
-}
-#endif
-
int
test ()
{
if (strcmp (p, "foo\n")) return 2;
p = "2azar\n";
- n = strtoull (p, (char**)&p, 16);
+ n = strtoull (p, (char**)&p, 16);
if (n != 42) return 3;
eputs (p);
if (strcmp (p, "zar\n")) return 4;
-
+
return 0;
}
if [ "$PREFIX" = @PREFIX""@ -o ! -d "$PREFIX" ]
then
MES_PREFIX=${MES_PREFIX-$(cd $(dirname $0)/.. && pwd)}
- export MES_PREFIX
+else
+ MES_PREFIX=${MES_PREFIX-$PREFIX/share/mes}
fi
+export MES_PREFIX
mes_p=$(command -v mes)
if [ '(' -z "$mes_p" -a -z "$MES" ')' -o "$MES" = "guile" -o "$MES" = "mes.guile" ]; then
GODIR=${GODIR-@GODIR@}
#:use-module (mescc mescc)
#:export (main))
-(define %prefix (if (string-prefix? "@PREFIX" "@PREFIX@") (or (getenv "MES_PREFIX") "") "@PREFIX@"))
+(define %prefix (or (getenv "MES_PREFIX")
+ (if (string-prefix? "@PREFIX" "@PREFIX@")
+ ""
+ "@PREFIX@/share/mes")))
(define %version (if (string-prefix? "@VERSION" "@VERSION@") "git"
"@VERSION@"))
(debug-info (single-char #\g))
(help (single-char #\h))
(include (single-char #\I) (value #t))
+ (library-dir (single-char #\L) (value #t))
(library (single-char #\l) (value #t))
(preprocess (single-char #\E))
(output (single-char #\o) (value #t))
-g add debug info [GDB, objdump] TODO: hex2 footer
-h, --help display this help and exit
-I DIR append DIR to include path
+ -L DIR append DIR to library path
-l LIBNAME link with LIBNAME
-o FILE write output to FILE
-S preprocess and compile only; do not assemble or link
#include <libmes.h>
//#define MES_MINI 1
-#if _POSIX_SOURCE
-int ARENA_SIZE = 300000000; // 32b: 4GiB, 64b: 8 GiB
-#else
int ARENA_SIZE = 200000; // 32b: 2MiB, 64b: 4 MiB
-#endif
-int MAX_ARENA_SIZE = 300000000;
+int MAX_ARENA_SIZE = 100000000;
int JAM_SIZE = 20000;
int GC_SAFETY = 2000;
+++ /dev/null
-### Copyright (C) 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
-### This file is part of stage0.
-###
-### stage0 is free software: you an 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.
-###
-### stage0 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 stage0. If not, see <http://www.gnu.org/licenses/>.
-
-### stage0's hex2 format for x86
-### !<label> 1 byte relative
-### $<label> 2 byte address
-### @<label> 2 byte relative
-### &<label> 4 byte address
-### %<label> 4 byte relative
-### local_<label> function-local
-### string_<index> string #<index>
-
-:ELF_end
+++ /dev/null
-### Copyright (C) 2016 Jeremiah Orians
-### Copyright (C) 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
-### This file is part of stage0.
-###
-### stage0 is free software: you an 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.
-###
-### stage0 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 stage0. If not, see <http://www.gnu.org/licenses/>.
-
-### stage0's hex2 format for x86
-### !<label> 1 byte relative
-### $<label> 2 byte address
-### @<label> 2 byte relative
-### &<label> 4 byte address
-### %<label> 4 byte relative
-### local_<label> function-local
-### string_<index> string #<index>
-
-### elf32-header-exit-42.hex2: 32 bit elf header in hex2 for `exit 42'
-
-:ELF_base
-7F 45 4C 46 # e_ident[EI_MAG0-3] ELF's magic number
-
-01 # e_ident[EI_CLASS] Indicating 32 bit
-01 # e_ident[EI_DATA] Indicating little endianness
-01 # e_ident[EI_VERSION] Indicating original elf
-
-00 # e_ident[EI_OSABI] Set at 0 because none cares
-00 # e_ident[EI_ABIVERSION] See above
-
-00 00 00 00 00 00 00 # e_ident[EI_PAD]
-
-02 00 # e_type Indicating Executable
-03 00 # e_machine Indicating AMD64
-01 00 00 00 # e_version Indicating original elf
-
-&ELF_text # e_entry Address of the entry point
-%ELF_program_headers>ELF_base # e_phoff Address of program header table
-00 00 00 00 # e_shoff Address of section header table
-
-00 00 00 00 # e_flags
-
-34 00 # e_ehsize Indicating our 52 Byte header
-
-20 00 # e_phentsize size of a program header table
-01 00 # e_phnum number of entries in program table
-
-00 00 # e_shentsize size of a section header table
-00 00 # e_shnum number of entries in section table
-
-00 00 # e_shstrndx index of the section names
-
-# @34
-00 00 00 00
-00 00 00 00
-00 00 00 00
-
-# @40
-:ELF_program_headers
-:ELF_program_header__text
-01 00 00 00 # ph_type: PT-LOAD = 1
-00 00 00 00 # ph_offset
-&ELF_base # ph_vaddr
-&ELF_base # ph_physaddr
-%ELF_end>ELF_base # ph_filesz
-%ELF_end>ELF_base # ph_memsz
-07 00 00 00 # ph_flags: PF-X|PF-W|PF-R = 7
-01 00 00 00 # ph_align
-
-:ELF_text
+++ /dev/null
-### Copyright (C) 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
-### This file is part of stage0.
-###
-### stage0 is free software: you an 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.
-###
-### stage0 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 stage0. If not, see <http://www.gnu.org/licenses/>.
-
-### stage0's hex2 format for x86
-### !<label> 1 byte relative
-### $<label> 2 byte address
-### @<label> 2 byte relative
-### &<label> 4 byte address
-### %<label> 4 byte relative
-### local_<label> function-local
-### string_<index> string #<index>
-
-### elf32-body-exit-42.hex2: 32 bit elf body in hex2 for `exit 42'
-
-# @200
-:ELF_text
-:_start
-# exit(42)
-e8 %main # call +11 <main>
-00 00 00
-00 00 00 00
-00 00 00 00
-
-# @210
-:main
-bb 2a 00 00 00 # mov $42,%ebx
-b8 01 00 00 00 # mov $0x1,%eax
-cd 80 # int $0x80
-
-00 00 00 00
-
-# @220
-:ELF_data
-65 78 69 74 34 32 20 64 61 74 61 20 68 65 72 65 # exit42 data here"
-
+++ /dev/null
-### Copyright (C) 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
-### This file is part of stage0.
-###
-### stage0 is free software: you an 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.
-###
-### stage0 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 stage0. If not, see <http://www.gnu.org/licenses/>.
-
-### stage0's hex2 format for x86
-### !<label> 1 byte relative
-### $<label> 2 byte address
-### @<label> 2 byte relative
-### &<label> 4 byte address
-### %<label> 4 byte relative
-### local_<label> function-local
-### string_<index> string #<index>
-
-### elf32-footer-single-main.hex2: 32 bit elf footer in hex2 for single main
-
-# @230
-
-:ELF_str
-00 # 0
-:ELF_str__start
-5f 73 74 61 72 74 00 # _start
-:ELF_str__main
-6d 61 69 6e 00 # main
-
-00 00 00
-
-# @240
-:ELF_sym
-00 00 00 00 # st-name
-00 00 00 00 # st-offset: &_start - BaseAddress
-00 00 00 00 # st-len : &main - _start
-00 # st-info = stt-func= 2
-00 # st-other
-01 00 # st-shndx: 1
-
-# _start
-%ELF_str__start>ELF_str # st-name
-&_start
-10 00 00 00 # st-len : &main - _start
-02 # st-info = stt-func= 2
-00 # st-other
-01 00 # st-shndx: 1
-
-# main
-%ELF_str__main>ELF_str # st-name
-&main
-10 00 00 00 # st-len : &ELF_data - main
-02 # st-info = stt-func= 2
-00 # st-other
-01 00 # st-shndx: 1
-
-:ELF_end
+++ /dev/null
-### Copyright (C) 2016 Jeremiah Orians
-### Copyright (C) 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
-### This file is part of stage0.
-###
-### stage0 is free software: you an 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.
-###
-### stage0 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 stage0. If not, see <http://www.gnu.org/licenses/>.
-
-### stage0's hex2 format for x86
-### !<label> 1 byte relative
-### $<label> 2 byte address
-### @<label> 2 byte relative
-### &<label> 4 byte address
-### %<label> 4 byte relative
-### local_<label> function-local
-### string_<index> string #<index>
-
-### elf32-header-exit-42.hex2: 32 bit elf header in hex2 for `exit 42'
-
-:ELF_base
-7F 45 4C 46 # e_ident[EI_MAG0-3] ELF's magic number
-
-01 # e_ident[EI_CLASS] Indicating 32 bit
-01 # e_ident[EI_DATA] Indicating little endianness
-01 # e_ident[EI_VERSION] Indicating original elf
-
-00 # e_ident[EI_OSABI] Set at 0 because none cares
-00 # e_ident[EI_ABIVERSION] See above
-
-00 00 00 00 00 00 00 # e_ident[EI_PAD]
-
-02 00 # e_type Indicating Executable
-03 00 # e_machine Indicating AMD64
-01 00 00 00 # e_version Indicating original elf
-
-&ELF_text # e_entry Address of the entry point
-%ELF_program_headers>ELF_base # e_phoff Address of program header table
-%ELF_section_headers>ELF_base # e_shoff Address of section header table
-
-00 00 00 00 # e_flags
-
-34 00 # e_ehsize Indicating our 52 Byte header
-
-20 00 # e_phentsize size of a program header table
-02 00 # e_phnum number of entries in program table
-
-28 00 # e_shentsize size of a section header table
-07 00 # e_shnum number of entries in section table
-
-04 00 # e_shstrndx index of the section names
-
-# @34
-00 00 00 00
-00 00 00 00
-00 00 00 00
-
-# @40
-:ELF_program_headers
-:ELF_program_header__text
-01 00 00 00 # ph_type: PT-LOAD = 1
-00 00 00 00 # ph_offset
-&ELF_base # ph_vaddr
-&ELF_base # ph_physaddr
-%ELF_end>ELF_base # ph_filesz
-%ELF_end>ELF_base # ph_memsz
-07 00 00 00 # ph_flags: PF-X|PF-W|PF-R = 7
-01 00 00 00 # ph_align
-
-# @60
-:ELF_program_header__data
-01 00 00 00 # ph_type: PT-LOAD = 1
-00 00 00 00 # ph_offset
-&ELF_base # ph_vaddr
-&ELF_base # ph_physaddr
-%ELF_end>ELF_base # ph_filesz
-%ELF_end>ELF_base # ph_memsz
-07 00 00 00 # ph_flags: PF-X|PF-W|PF-R = 7
-01 00 00 00 # ph_align
-
-# @80
-:ELF_comment
-4d 45 53 00 # MES
-00 00 00 00 # align
-00 00 00 00
-00 00 00 00
-
-4d 45 53 00 # MES
-00 00 00 00 # align
-00 00 00 00
-00 00 00 00
-
-# @a0
-:ELF_shstr
-00
-:ELF_shstr__text
-2e 74 65 78 74 00 # .text
-:ELF_shstr__data
-2e 64 61 74 61 00 # .data
-:ELF_shstr__comment
-2e 63 6f 6d 6d 65 6e 74 00 # .comment
-:ELF_shstr__shstr
-2e 73 68 73 74 72 74 61 62 00 # .shstrtab
-:ELF_shstr__sym
-2e 73 79 6d 74 61 62 00 # .symtab
-:ELF_shstr__str
-2e 73 74 72 74 61 62 00 # .strtab
-
-# @d0
-
-:ELF_section_headers
-00 00 00 00 # sh_name
-00 00 00 00 # sh_type
-00 00 00 00 # sh_flags
-00 00 00 00 # sh_addr
-00 00 00 00 # sh_offset
-00 00 00 00 # sh_length
-00 00 00 00 # sh_link
-00 00 00 00 # sh_info
-01 00 00 00 # sh_1?
-00 00 00 00 # sh_entsize
-
-## FIXME: M0 for calculations?
-:ELF_section_header_text
-%ELF_shstr__text>ELF_shstr # sh_name
-01 00 00 00 # sh_type = SHT_PROGBITS = 1
-06 00 00 00 # sh_flags = SHF-ALLOC|SHF-EXEC =2 | 4 = 6
-&ELF_text # sh_addr
-%ELF_text>ELF_base # sh_offset
-%ELF_data>ELF_text # sh_length
-00 00 00 00 # sh_link
-00 00 00 00 # sh_info
-01 00 00 00 # sh_1?
-00 00 00 00 # sh_entsize
-
-:ELF_section_header_data
-%ELF_shstr__data>ELF_shstr # sh_name
-01 00 00 00 # sh_type = SHT_PROGBITS = 1
-03 00 00 00 # sh_flags = SHF-WRITE|SHF-ALLOC = 1 | 2 = 3
-&ELF_data # sh_addr
-%ELF_data>ELF_base # sh_offset
-%ELF_sym>ELF_data # sh_length
-00 00 00 00 # sh_link
-00 00 00 00 # sh_info
-01 00 00 00 # sh_1?
-00 00 00 00 # sh_entsize
-
-:ELF_section_header_comment
-%ELF_shstr__comment>ELF_shstr # sh_name
-01 00 00 00 # sh_type = SHT_PROGBITS = 1
-00 00 00 00 # sh_flags
-&ELF_comment # sh_addr
-%ELF_comment>ELF_base # sh_offset
-%ELF_shstr>ELF_comment # sh_length
-00 00 00 00 # sh_link
-00 00 00 00 # sh_info
-01 00 00 00 # sh_1?
-00 00 00 00 # sh_entsize
-
-:ELF_section_header_shstr
-%ELF_shstr__shstr>ELF_shstr # sh_name
-03 00 00 00 # sh_type: str-sht-strtab
-00 00 00 00 # sh_flags
-&ELF_shstr # sh_addr
-%ELF_shstr>ELF_base # sh_offset
-%ELF_section_headers>ELF_shstr # sh_length
-00 00 00 00 # sh_link
-00 00 00 00 # sh_info
-01 00 00 00 # sh_1?
-00 00 00 00 # sh_entsize
-
-:ELF_section_header_sym
-%ELF_shstr__sym>ELF_shstr # sh_name
-02 00 00 00 # sh_type: str-sht-symtab
-00 00 00 00 # sh_flags
-&ELF_sym # sh_addr
-%ELF_sym>ELF_base # sh_offset
-%ELF_end>ELF_sym # sh_length
-06 00 00 00 # sh_link:6
-00 00 00 00 # sh_info
-01 00 00 00 # sh_1?
-10 00 00 00 # sh_entsize
-
-:ELF_section_header_str
-%ELF_shstr__str>ELF_shstr # sh_name
-03 00 00 00 # sh_type: str-sht-strtab
-00 00 00 00 # sh_flags
-&ELF_str # sh_addr
-%ELF_str>ELF_base # sh_offset
-%ELF_sym>ELF_str # sh_length
-00 00 00 00 # sh_link
-00 00 00 00 # sh_info
-01 00 00 00 # sh_1?
-00 00 00 00 # sh_entsize
-
-# @1e8
-00 00 00 00 # align
-00 00 00 00
-
-# @1f0
-
-00 00 00 00 # align
-00 00 00 00
-00 00 00 00
-00 00 00 00
-
-# @200
-:ELF_text
+++ /dev/null
-;;; -*-scheme-*-
-;;; Copyright (C) 2016 Jeremiah Orians
-;;; Copyright (C) 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
-;;; This file is part of stage0.
-;;;
-;;; stage0 is free software: you an 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.
-;;;
-;;; stage0 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 stage0. If not, see <http://www.gnu.org/licenses/>.
-
-;;; elf32.hex3: 32 bit elf header in hex3
-
-;; ELF Header
-("*elf-header*"
-#X7F #x45 #X4C #x46 ; e_ident[EI_MAG0-3] ELF's magic number
-
-#x01 ; e_ident[EI_CLASS] Indicating 32 bit
-#x01 ; e_ident[EI_DATA] Indicating little endianness
-#x01 ; e_ident[EI_VERSION] Indicating original elf
-
-#x00 ; e_ident[EI_OSABI] Set at 0 because none cares
-#x00 ; e_ident[EI_ABIVERSION] See above
-
-#x00 #x00 #x00 #x00 #x00 #x00 #x00 ; e_ident[EI_PAD]
-#x02 #x00 ; e_type Indicating Executable
-#x03 #x00 ; e_machine Indicating AMD64
-#x01 #x00 #x00 #x00 ; e_version Indicating original elf
-
-#x54 #x80 #x04 #x08 ; e_entry Address of the entry point
-#x34 #x00 #x00 #x00 ; e_phoff Address of program header table
-#x00 #x00 #x00 #x00 ; e_shoff Address of section header table
-
-#x00 #x00 #x00 #x00 ; e_flags
-#x34 #x00 ; e_ehsize Indicating our 52 Byte header
-
-#x20 #x00 ; e_phentsize size of a program header table
-#x01 #x00 ; e_phnum number of entries in program table
-
-#x00 #x00 ; e_shentsize size of a section header table
-#x00 #x00 ; e_shnum number of entries in section table
-
-#x00 #x00 ; e_shstrndx index of the section names
-
-;; Program Header
-#x01 #x00 #x00 #x00 ; p_type
-#x00 #x00 #x00 #x00 ; p_offset
-
-#x00 #x80 #x04 #x08 ; p_vaddr
-#x00 #x80 #x04 #x08 ; p_physaddr
-
-;; FIXME!
-;;#x60 #x00 #x00 #x00 ; p_filesz
-;;#x60 #x00 #x00 #x00 ; p_memsz
-
-;#x65 #x01 #x00 #x00 ; p_filesz
-;#x65 #x01 #x00 #x00 ; p_memsz
-
-#xff #xff #x00 #x00 ; p_filesz
-#xff #xff #x00 #x00 ; p_memsz
-
-
-#x07 #x00 #x00 #x00 ; p_flags
-#x01 #x00 #x00 #x00 ; alignment
-
-;; _start
-; exit (42) -- works!
-;#xbb #x2a #x00 #x00 #x00 ; mov $42,%ebx
-;#xb8 #x01 #x00 #x00 #x00 ; mov $0x1,%eax
-;#xcd #x80 ; int $0x80
-)
-
-("shstr" 0
- #\. #\t #\e #\x #\t 0
- #\. #\d #\a #\t #\a 0
- #\. #\c #\o #\m #\m #\e #\n #\t 0
- #\. #\s #\h #\s #\t #\r #\t #\a #\b 0
- #\. #\s #\y #\m #\t #\a #\b 0
- #\. #\s #\t #\r #\t #\a #\b 0)
+++ /dev/null
-/* -*-comment-start: "//";comment-end:""-*-
- * Mes --- Maxwell Equations of Software
- * Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
- *
- * This file is part of Mes.
- *
- * 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.
- *
- * 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 Mes. If not, see <http://www.gnu.org/licenses/>.
- */
-
-int
-main (int argc, char *argv[])
-{
- return 42;
-}
+++ /dev/null
-### Mes --- Maxwell Equations of Software
-### Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
-###
-### This file is part of Mes.
-###
-### 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.
-###
-### 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 Mes. If not, see <http://www.gnu.org/licenses/>.
-
-
-DEFINE add____$i32,%eax 05
-DEFINE add____$i32,%ecx 81c1
-DEFINE add____$i32,%edx 81c2
-DEFINE add____$i32,(%eax) 8100
-DEFINE add____$i32,0x32(%eax) 8180
-DEFINE add____$i32,0x32(%ebp) 8185
-DEFINE add____$i8,%eax 83c0
-DEFINE add____$i8,%edx 83c2
-DEFINE add____$i8,%esp 83c4
-DEFINE add____$i8,(%eax) 8300
-DEFINE add____$i8,0x32 8305
-DEFINE add____$i8,0x32(%eax) 8380
-DEFINE add____$i8,0x32(%eax) 8380
-DEFINE add____$i8,0x32(%ebp) 8385
-DEFINE add____$i8,0x8(%eax) 8340
-DEFINE add____$i8,0x8(%ebp) 8345
-DEFINE add____%eax,%eax 01c0
-DEFINE add____%ebp,%eax 01e8
-DEFINE add____%edx,%eax 01d0
-DEFINE add____%edx,%eax 01d0
-DEFINE and____$i32,%eax 25
-DEFINE and____%edx,%eax 21d0
-DEFINE and____(%edx),%eax 2302
-DEFINE call32 e8
-DEFINE call___*%eax ffd0
-DEFINE cmp____$0x32,%eax 3d
-DEFINE cmp____$i32,%eax 3d
-DEFINE cmp____$i32,0x32(%ebp) 81bd
-DEFINE cmp____$i32,0x8(%ebp) 817d
-DEFINE cmp____$i8,%eax 83f8
-DEFINE cmp____$i8,0x32(%ebp) 83bd
-DEFINE cmp____$i8,0x8(%ebp) 837d
-DEFINE cmp____%al,%dl 38c2
-DEFINE cmp____%edx,%eax 39d0
-DEFINE hlt f4
-DEFINE idiv___%ebx f7fb
-DEFINE int cd
-DEFINE int____$0x80 cd80
-DEFINE ja32 0f87
-DEFINE jae32 0f83
-DEFINE jb32 0f82
-DEFINE jbe32 0f86
-DEFINE je32 0f84
-DEFINE je8 74
-DEFINE jg32 0f8f
-DEFINE jge32 0f8d
-DEFINE jl32 0f8c
-DEFINE jle32 0f8e
-DEFINE jmp32 e9
-DEFINE jmp____*%ebx ffe3
-DEFINE jne32 0f85
-DEFINE lahf 9f
-DEFINE lea____0x32(%ebp),%eax 8d85
-DEFINE lea____0x32(%ebp),%edx 8d95
-DEFINE lea____0x8(%ebp),%eax 8d45
-DEFINE lea____0x8(%ebp),%edx 8d55
-DEFINE leave c9
-DEFINE mov____$i32,%eax b8
-DEFINE mov____$i32,%ebx bb
-DEFINE mov____$i32,%ecx b9
-DEFINE mov____$i32,%edx ba
-DEFINE mov____$i32,(%eax) c700
-DEFINE mov____$i32,0x32 c705
-DEFINE mov____$i32,0x8(%eax) c740
-DEFINE mov____$i32,0x8(%ebp) c745
-DEFINE mov____%al,(%edx) 8802
-DEFINE mov____%al,0x8(%edx) 8842
-DEFINE mov____%ax,(%edx) 668902
-DEFINE mov____%ax,0x32(%edx) 668982
-DEFINE mov____%ax,0x8(%edx) 668942
-DEFINE mov____%dl,(%eax) 8810
-DEFINE mov____%dl,0x8(%eax) 8850
-DEFINE mov____%eax,%ebx 89c3
-DEFINE mov____%eax,%edx 89c2
-DEFINE mov____%eax,(%ecx) 8901
-DEFINE mov____%eax,(%edx) 8902
-DEFINE mov____%eax,0x32 a3
-DEFINE mov____%eax,0x32(%ebp) 8985
-DEFINE mov____%eax,0x32(%edx) 8982
-DEFINE mov____%eax,0x8(%ebp) 8945
-DEFINE mov____%eax,0x8(%edx) 8942
-DEFINE mov____%ebp,%eax 89e8
-DEFINE mov____%ebp,%ecx 89e9
-DEFINE mov____%ebp,%edx 89ea
-DEFINE mov____%ebx,0x32 891d
-DEFINE mov____%ebx,0x32(%ebp) 899d
-DEFINE mov____%ebx,0x8(%ebp) 895d
-DEFINE mov____%ebx,0x8(%edx) 895a
-DEFINE mov____%ecx,(%eax) 8908
-DEFINE mov____%ecx,(%edx) 890a
-DEFINE mov____%ecx,0x32(%ebp) 898d
-DEFINE mov____%ecx,0x8(%ebp) 894d
-DEFINE mov____%edx,%eax 89d0
-DEFINE mov____%edx,%ebx 89d3
-DEFINE mov____%edx,%ecx 89d1
-DEFINE mov____%edx,(%eax) 8910
-DEFINE mov____%edx,0x32(%ebp) 8995
-DEFINE mov____%edx,0x8(%ebp) 8955
-DEFINE mov____%esp,%ebp 89e5
-DEFINE mov____(%eax),%eax 8b00
-DEFINE mov____(%eax),%ecx 8b08
-DEFINE mov____(%edx),%eax 8b02
-DEFINE mov____(%edx),%ecx 8b0a
-DEFINE mov____(%edx),%edx 8b12
-DEFINE mov____0x32(%eax),%eax 8b80
-DEFINE mov____0x32(%eax),%ebx 8b98
-DEFINE mov____0x32(%eax),%ecx 8b88
-DEFINE mov____0x32(%ebp),%eax 8b85
-DEFINE mov____0x32(%ebp),%eax 8b85
-DEFINE mov____0x32(%ebp),%ebx 8b9d
-DEFINE mov____0x32(%ebp),%ecx 8b8d
-DEFINE mov____0x32(%ebp),%edx 8b95
-DEFINE mov____0x32(%ebp),%edx 8b95
-DEFINE mov____0x32,%eax a1
-DEFINE mov____0x32,%edx 8b15
-DEFINE mov____0x8(%eax),%eax 8b40
-DEFINE mov____0x8(%eax),%ebx 8b58
-DEFINE mov____0x8(%eax),%ecx 8b48
-DEFINE mov____0x8(%ebp),%eax 8b45
-DEFINE mov____0x8(%ebp),%ebp 8b6d
-DEFINE mov____0x8(%ebp),%ebx 8b5d
-DEFINE mov____0x8(%ebp),%ecx 8b4d
-DEFINE mov____0x8(%ebp),%edx 8b55
-DEFINE mov____0x8(%ebp),%esp 8b65
-DEFINE movsbl_%al,%eax 0fbec0
-DEFINE movswl_%ax,%eax 0fbfc0
-DEFINE movzbl_%al,%eax 0fb6c0
-DEFINE movzbl_%al,%eax 0fb6c0
-DEFINE movzbl_%dl,%edx 0fb6d2
-DEFINE movzbl_(%eax),%eax 0fb600
-DEFINE movzbl_(%eax),%edx 0fb610
-DEFINE movzbl_(%edx),%edx 0fb612
-DEFINE movzbl_0x32(%eax),%eax 0fb680
-DEFINE movzbl_0x8(%eax),%eax 0fb640
-DEFINE movzbl_0x8(%ebp),%eax 0fb645
-DEFINE movzwl_%ax,%eax 0fb7c0
-DEFINE movzwl_(%eax),%eax 0fb700
-DEFINE movzwl_0x32(%eax),%eax 0fb780
-DEFINE movzwl_0x32(%ebp),%eax 0fb785
-DEFINE movzwl_0x8(%eax),%eax 0fb740
-DEFINE mul____%edx f7e2
-DEFINE nop 90
-DEFINE not____%eax f7d0
-DEFINE or_____%edx,%eax 09d0
-DEFINE or_____(%edx),%eax 0b02
-DEFINE pop____%eax 58
-DEFINE pop____%edx 5a
-DEFINE push___$i32 68
-DEFINE push___%eax 50
-DEFINE push___%ebp 55
-DEFINE push___%edx 52
-DEFINE push___(%eax) ff30
-DEFINE push___0x32(%ebp) ffb5
-DEFINE push___0x8(%ebp) ff75
-DEFINE ret c3
-DEFINE sahf 9e
-DEFINE seta___%al 0f97c0
-DEFINE setae__%al 0f93c0
-DEFINE setb___%al 0f92c0
-DEFINE setbe__%al 0f96c0
-DEFINE sete___%al 0f94c0
-DEFINE setg___%al 0f9fc0
-DEFINE setge__%al 0f9dc0
-DEFINE setl___%al 0f9cc0
-DEFINE setle__%al 0f9ec0
-DEFINE setne__%al 0f95c0
-DEFINE shl____$i8,%eax c1e0
-DEFINE shl____%cl,%eax d3e0
-DEFINE shr____%cl,%eax d3e8
-DEFINE sub____%al,%dl 28d0
-DEFINE sub____%dl,%al 28c2
-DEFINE sub____%eax,%edx 29c2
-DEFINE sub____%edx,%eax 29d0
-DEFINE sub____%edx,%eax 29d0
-DEFINE sub____%esp,$i32 81ec
-DEFINE sub____%esp,$i8 83ec
-DEFINE test___%al,%al 84c0
-DEFINE test___%eax,%eax 85c0
-DEFINE xchg___%eax,(%esp) 870424
-DEFINE xor____$i32,%eax 35
-DEFINE xor____$i8,%ah 80f4
-DEFINE xor____%eax,%eax 31c0
-DEFINE xor____%ebx,%ebx 31db
-DEFINE xor____%ecx,%ecx 31c9
-DEFINE xor____%edx,%eax 31d0
-DEFINE xor____%edx,%edx 31d2
-
-# Deprecated. Remove after 0.14 release.
-DEFINE mov____%al,0x32(%ebp) 8885
-DEFINE mov____%al,0x8(%ebp) 8845
-DEFINE mov____%ax,0x32(%ebp) 668985
-DEFINE mov____%ax,0x8(%ebp) 668945
-DEFINE movzbl_0x32(%ebp),%eax 0fb685
-DEFINE movzbl_0x8(%ebp),%edx 0fb655
-DEFINE movzwl_0x8(%ebp),%eax 0fb745
-DEFINE movzwl_0x8(%ebp),%eax 0fb745
-
-DEFINE SYS_exit 01000000
-DEFINE SYS_fork 02000000
-DEFINE SYS_read 03000000
-DEFINE SYS_write 04000000
-DEFINE SYS_open 05000000
-DEFINE SYS_close 06000000
-DEFINE SYS_waitpid 07000000
-DEFINE SYS_unlink 0a000000
-DEFINE SYS_execve 0b000000
-DEFINE SYS_chmod 0f000000
-DEFINE SYS_lseek 13000000
-DEFINE SYS_access 21000000
-DEFINE SYS_brk 2d000000
-DEFINE SYS_ioctl 36000000
-DEFINE SYS_fsync 76000000
-DEFINE SYS_getcwd b7000000