Added working HEAP to knight-posix
This commit is contained in:
parent
c6ac46292f
commit
69c319ef6c
|
@ -31,6 +31,9 @@ Added second knight-posix test
|
||||||
Added third knight-posix test
|
Added third knight-posix test
|
||||||
Added fourth knight-posix test
|
Added fourth knight-posix test
|
||||||
Added fifth knight-posix test
|
Added fifth knight-posix test
|
||||||
|
Added sixth knight-posix test
|
||||||
|
Added seventh knight-posix test
|
||||||
|
Added working HEAP/malloc to knight-posix
|
||||||
|
|
||||||
** Changed
|
** Changed
|
||||||
Converted M2-Planet to use GNU style error message
|
Converted M2-Planet to use GNU style error message
|
||||||
|
|
31
cc_core.c
31
cc_core.c
|
@ -43,7 +43,8 @@ int Address_of;
|
||||||
char* parse_string(char* string);
|
char* parse_string(char* string);
|
||||||
int escape_lookup(char* c);
|
int escape_lookup(char* c);
|
||||||
char* numerate_number(int a);
|
char* numerate_number(int a);
|
||||||
|
int numerate_string(char *a);
|
||||||
|
char* number_to_hex(int a, int bytes);
|
||||||
|
|
||||||
struct token_list* emit(char *s, struct token_list* head)
|
struct token_list* emit(char *s, struct token_list* head)
|
||||||
{
|
{
|
||||||
|
@ -303,10 +304,28 @@ void primary_expr_char()
|
||||||
|
|
||||||
void primary_expr_number()
|
void primary_expr_number()
|
||||||
{
|
{
|
||||||
if(1 == Architecture) emit_out("LOADI R0 ");
|
if(1 == Architecture)
|
||||||
else if(2 == Architecture) emit_out("LOAD_IMMEDIATE_eax %");
|
{
|
||||||
emit_out(global_token->s);
|
int size = numerate_string(global_token->s);
|
||||||
emit_out("\n");
|
if((32768 > size) && (size > -32768))
|
||||||
|
{
|
||||||
|
emit_out("LOADI R0 ");
|
||||||
|
emit_out(global_token->s);
|
||||||
|
emit_out("\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
emit_out("LOADR R0 4\nJUMP 4\n'");
|
||||||
|
emit_out(number_to_hex(size, 4));
|
||||||
|
emit_out("'\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(2 == Architecture)
|
||||||
|
{
|
||||||
|
emit_out("LOAD_IMMEDIATE_eax %");
|
||||||
|
emit_out(global_token->s);
|
||||||
|
emit_out("\n");
|
||||||
|
}
|
||||||
global_token = global_token->next;
|
global_token = global_token->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1055,7 +1074,7 @@ void recursive_statement()
|
||||||
struct token_list* i;
|
struct token_list* i;
|
||||||
for(i = function->locals; frame != i; i = i->next)
|
for(i = function->locals; frame != i; i = i->next)
|
||||||
{
|
{
|
||||||
if(1 == Architecture) emit_out("POPR R1 R15\t@ _recursive_statement_locals\n");
|
if(1 == Architecture) emit_out("POPR R1 R15\t# _recursive_statement_locals\n");
|
||||||
else if(2 == Architecture) emit_out( "POP_ebx\t# _recursive_statement_locals\n");
|
else if(2 == Architecture) emit_out( "POP_ebx\t# _recursive_statement_locals\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
/* Copyright (C) 2016 Jeremiah Orians
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include<stdlib.h>
|
||||||
|
#include<string.h>
|
||||||
|
#include<stdio.h>
|
||||||
|
// void* calloc(int count, int size);
|
||||||
|
void file_print(char* s, FILE* f);
|
||||||
|
int hex2char(int c);
|
||||||
|
|
||||||
|
char* number_to_hex(int a, int bytes)
|
||||||
|
{
|
||||||
|
char* result = calloc(1 + (bytes << 1), sizeof(char));
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
int divisor = (bytes << 3);
|
||||||
|
|
||||||
|
/* Simply collect numbers until divisor is gone */
|
||||||
|
while(0 != divisor)
|
||||||
|
{
|
||||||
|
divisor = divisor - 4;
|
||||||
|
result[i] = hex2char((a >> divisor) & 0xF);
|
||||||
|
i = i + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
30
makefile
30
makefile
|
@ -68,15 +68,18 @@ test: test00-knight-posix-binary \
|
||||||
test03-knight-posix-binary \
|
test03-knight-posix-binary \
|
||||||
test04-knight-posix-binary \
|
test04-knight-posix-binary \
|
||||||
test05-knight-posix-binary \
|
test05-knight-posix-binary \
|
||||||
|
test06-knight-posix-binary \
|
||||||
|
test07-knight-posix-binary \
|
||||||
|
test08-knight-posix-binary \
|
||||||
test00-x86-binary \
|
test00-x86-binary \
|
||||||
test01-x86-binary \
|
test01-x86-binary \
|
||||||
test02-x86-binary \
|
test02-x86-binary \
|
||||||
test03-x86-binary \
|
test03-x86-binary \
|
||||||
test04-x86-binary \
|
test04-x86-binary \
|
||||||
test05-x86-binary \
|
test05-x86-binary \
|
||||||
test06-binary \
|
test06-x86-binary \
|
||||||
test07-binary \
|
test07-x86-binary \
|
||||||
test08-binary \
|
test08-x86-binary \
|
||||||
test09-binary \
|
test09-binary \
|
||||||
test10-binary \
|
test10-binary \
|
||||||
test11-binary \
|
test11-binary \
|
||||||
|
@ -115,6 +118,15 @@ test04-knight-posix-binary: M2-Planet | results
|
||||||
test05-knight-posix-binary: M2-Planet | results
|
test05-knight-posix-binary: M2-Planet | results
|
||||||
test/test05/hello-knight-posix.sh
|
test/test05/hello-knight-posix.sh
|
||||||
|
|
||||||
|
test06-knight-posix-binary: M2-Planet | results
|
||||||
|
test/test06/hello-knight-posix.sh
|
||||||
|
|
||||||
|
test07-knight-posix-binary: M2-Planet | results
|
||||||
|
test/test07/hello-knight-posix.sh
|
||||||
|
|
||||||
|
test08-knight-posix-binary: M2-Planet | results
|
||||||
|
test/test08/hello-knight-posix.sh
|
||||||
|
|
||||||
test00-x86-binary: M2-Planet | results
|
test00-x86-binary: M2-Planet | results
|
||||||
test/test00/hello-x86.sh
|
test/test00/hello-x86.sh
|
||||||
|
|
||||||
|
@ -133,14 +145,14 @@ test04-x86-binary: M2-Planet | results
|
||||||
test05-x86-binary: M2-Planet | results
|
test05-x86-binary: M2-Planet | results
|
||||||
test/test05/hello-x86.sh
|
test/test05/hello-x86.sh
|
||||||
|
|
||||||
test06-binary: M2-Planet | results
|
test06-x86-binary: M2-Planet | results
|
||||||
test/test06/hello.sh
|
test/test06/hello-x86.sh
|
||||||
|
|
||||||
test07-binary: M2-Planet | results
|
test07-x86-binary: M2-Planet | results
|
||||||
test/test07/hello.sh
|
test/test07/hello-x86.sh
|
||||||
|
|
||||||
test08-binary: M2-Planet | results
|
test08-x86-binary: M2-Planet | results
|
||||||
test/test08/hello.sh
|
test/test08/hello-x86.sh
|
||||||
|
|
||||||
test09-binary: M2-Planet | results
|
test09-binary: M2-Planet | results
|
||||||
test/test09/hello.sh
|
test/test09/hello.sh
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
/* Copyright (C) 2016 Jeremiah Orians
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void* malloc(int size)
|
||||||
|
{
|
||||||
|
asm("LOAD R0 R14 0"
|
||||||
|
"ADDU R0 R12 R0"
|
||||||
|
"SWAP R0 R12");
|
||||||
|
}
|
|
@ -15,7 +15,7 @@
|
||||||
## along with M2-Planet. If not, see <http://www.gnu.org/licenses/>.
|
## along with M2-Planet. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
:_start
|
:_start
|
||||||
|
LOADR32 R12 @HEAP ; Setup HEAP pointer
|
||||||
LOADUI R15 $ELF_end ; Setup Stack pointer
|
LOADUI R15 $ELF_end ; Setup Stack pointer
|
||||||
COPY R14 R15 ; Protect esp
|
COPY R14 R15 ; Protect esp
|
||||||
|
|
||||||
|
@ -26,4 +26,5 @@
|
||||||
HALT ; Simply halt for now
|
HALT ; Simply halt for now
|
||||||
|
|
||||||
;; Our default heap pointer
|
;; Our default heap pointer
|
||||||
|
:HEAP
|
||||||
'00080000'
|
'00080000'
|
|
@ -1,21 +1,24 @@
|
||||||
96dcb1cde9bc98c736fb33146982215f4509ae8539475e513e9cef326c78cbda test/results/test00-knight-posix-binary
|
9386b893f5d31a130103618131b4bf89c40d8c8aa99d216bd30cc7dc62deeb47 test/results/test00-knight-posix-binary
|
||||||
c52562bd0aabb86ce8ca177f22f8d0455769b444df2d4d62894faab63b7151d8 test/results/test00-x86-binary
|
c52562bd0aabb86ce8ca177f22f8d0455769b444df2d4d62894faab63b7151d8 test/results/test00-x86-binary
|
||||||
fab674644b9519e8ec39e254e6b13fe5eccb9f861f7d9e7d2f736d40875b7546 test/results/test01-knight-posix-binary
|
97d784284844e01d28beb37c0d04a97b3f1b2835c7b7e0b169e1a6e78d6c6c9a test/results/test01-knight-posix-binary
|
||||||
eae96857f2b6d8e8ba86ac06e72345ea572622b358b23978bb5f2db1baadf41c test/results/test01-x86-binary
|
eae96857f2b6d8e8ba86ac06e72345ea572622b358b23978bb5f2db1baadf41c test/results/test01-x86-binary
|
||||||
d1788ab10ad9d16488eac547664f59b1a0d4684da90240eecc1de3dceac7de78 test/results/test02-knight-posix-binary
|
0add4a5a2e1a2a1e3806f72523f682364c7c65f5c1efbdf1f11af916b6afc5a0 test/results/test02-knight-posix-binary
|
||||||
8ead336d2f3f72d5874230492e0472edec61d355905e8636e3dfb2731695037c test/results/test02-x86-binary
|
8ead336d2f3f72d5874230492e0472edec61d355905e8636e3dfb2731695037c test/results/test02-x86-binary
|
||||||
e7e27666bbac654863302365ace7696b220bbb4f989eb3ee76966e09076d5fdd test/results/test03-knight-posix-binary
|
d29f0a2580efa4c47b47a7ff24d5295920ac0d410cd9480639072b6635c585e9 test/results/test03-knight-posix-binary
|
||||||
2313cb3f1a2b9eb6bf15f8d43418e15d6c16f7f1b5c22700fdfc2b38beb59192 test/results/test03-x86-binary
|
2313cb3f1a2b9eb6bf15f8d43418e15d6c16f7f1b5c22700fdfc2b38beb59192 test/results/test03-x86-binary
|
||||||
f46d7e681d9022be3e2df0063826302b708f35f682942f16fb247e22dee70137 test/results/test04-knight-posix-binary
|
2831709595712268889e1737ec7728cf29385567b736a3dcc35fb7b97773b79f test/results/test04-knight-posix-binary
|
||||||
b7ddb37063c541c6a315809c4438aa235d6702f54bb64f4ffc88dbe78617de81 test/results/test04-x86-binary
|
b7ddb37063c541c6a315809c4438aa235d6702f54bb64f4ffc88dbe78617de81 test/results/test04-x86-binary
|
||||||
5efe707d92f6bea63be31605f38ac9caff6509b10f4461c3df9e34332dc550f7 test/results/test05-knight-posix-binary
|
78921a43d41d6c62cab2552d3f13f353a9fd5beee5be702417e47a15d95e169d test/results/test05-knight-posix-binary
|
||||||
b5b76320ccda887a30b0bbefc2a5c302c8f2aa3c398d92ef3a79526690b25d6f test/results/test05-x86-binary
|
b5b76320ccda887a30b0bbefc2a5c302c8f2aa3c398d92ef3a79526690b25d6f test/results/test05-x86-binary
|
||||||
663fc6eefe965f237b6bf5a211398c8ae1210f97ff39b59603677e92462c68c7 test/results/test06-binary
|
3f415979cca69519a8298535380ec707f9cbdc2f2635df1e3abc8bc492b6203d test/results/test06-knight-posix-binary
|
||||||
a9a3e332d13ded5f80d7431f8717f26527b3722b33ea57760a9a5723dffc099c test/results/test07-binary
|
663fc6eefe965f237b6bf5a211398c8ae1210f97ff39b59603677e92462c68c7 test/results/test06-x86-binary
|
||||||
f1c01feb865c4d552033186d9ce50dd39468a7e8aebf762886c13ad3e03b5011 test/results/test08-binary
|
3befa4e52965fb52186379c36fc6f6d897902dd4427e7f6ba2cc4e99cc969c49 test/results/test07-knight-posix-binary
|
||||||
|
a9a3e332d13ded5f80d7431f8717f26527b3722b33ea57760a9a5723dffc099c test/results/test07-x86-binary
|
||||||
|
08bc1fb86c1df73b21e0b68e76572a33477f8943abdd16433d00ef231195bd22 test/results/test08-knight-posix-binary
|
||||||
|
f1c01feb865c4d552033186d9ce50dd39468a7e8aebf762886c13ad3e03b5011 test/results/test08-x86-binary
|
||||||
3b39e72f3de90ed690adfaf6145af46157cef2ec5e72867ac577fa27a0229894 test/results/test09-binary
|
3b39e72f3de90ed690adfaf6145af46157cef2ec5e72867ac577fa27a0229894 test/results/test09-binary
|
||||||
020e86020819cc4963e6185b22e534fcf8306b6cb116f12643f254a24688ff0a test/results/test10-binary
|
020e86020819cc4963e6185b22e534fcf8306b6cb116f12643f254a24688ff0a test/results/test10-binary
|
||||||
70429b4c78f8a712c5bf2de9d7cbfac06fafedc0635b58f0b6319906f3549ab0 test/results/test100-binary
|
9a0edc49d1078ffc7ed2578e50198e9e7695c2f26151a3d6e76bab7f2db6872c test/results/test100-binary
|
||||||
3fd11bad4a426ce1ff8fd9c6d7d2b943effae9f3f5740b7376e426e9b0555851 test/results/test11-binary
|
3fd11bad4a426ce1ff8fd9c6d7d2b943effae9f3f5740b7376e426e9b0555851 test/results/test11-binary
|
||||||
f98ab8e4bb35580e0dde96126d7a56aff66bda208d02c8d89390b40d6cff591c test/results/test12-binary
|
f98ab8e4bb35580e0dde96126d7a56aff66bda208d02c8d89390b40d6cff591c test/results/test12-binary
|
||||||
5051ffca2615144419f8ec1a5d4999486ae81e7781428f59e47e866af97cef92 test/results/test13-binary
|
5051ffca2615144419f8ec1a5d4999486ae81e7781428f59e47e866af97cef92 test/results/test13-binary
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
#! /bin/sh
|
||||||
|
## Copyright (C) 2017 Jeremiah Orians
|
||||||
|
## 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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
# Build the test
|
||||||
|
bin/M2-Planet --architecture knight-posix -f test/common_knight/functions/putchar.c \
|
||||||
|
-f test/test06/for.c \
|
||||||
|
-o test/test06/for.M1 || exit 1
|
||||||
|
|
||||||
|
# Macro assemble with libc written in M1-Macro
|
||||||
|
M1 -f test/common_knight/knight_defs.M1 \
|
||||||
|
-f test/common_knight/libc-core.M1 \
|
||||||
|
-f test/test06/for.M1 \
|
||||||
|
--BigEndian \
|
||||||
|
--architecture knight-posix \
|
||||||
|
-o test/test06/for.hex2 || exit 2
|
||||||
|
|
||||||
|
# Resolve all linkages
|
||||||
|
hex2 -f test/common_knight/ELF-knight.hex2 -f test/test06/for.hex2 --BigEndian --architecture knight-posix --BaseAddress 0x00 -o test/results/test06-knight-posix-binary --exec_enable || exit 3
|
||||||
|
|
||||||
|
# Ensure binary works if host machine supports test
|
||||||
|
if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "knight" ]
|
||||||
|
then
|
||||||
|
# Verify that the resulting file works
|
||||||
|
./test/results/test06-knight-posix-binary >| test/test06/proof || exit 4
|
||||||
|
out=$(sha256sum -c test/test06/proof.answer)
|
||||||
|
[ "$out" = "test/test06/proof: OK" ] || exit 5
|
||||||
|
fi
|
||||||
|
exit 0
|
|
@ -30,13 +30,13 @@ M1 -f test/common_x86/x86_defs.M1 \
|
||||||
-o test/test06/for.hex2 || exit 2
|
-o test/test06/for.hex2 || exit 2
|
||||||
|
|
||||||
# Resolve all linkages
|
# Resolve all linkages
|
||||||
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test06/for.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test06-binary --exec_enable || exit 3
|
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test06/for.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test06-x86-binary --exec_enable || exit 3
|
||||||
|
|
||||||
# Ensure binary works if host machine supports test
|
# Ensure binary works if host machine supports test
|
||||||
if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "x86" ]
|
if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "x86" ]
|
||||||
then
|
then
|
||||||
# Verify that the resulting file works
|
# Verify that the resulting file works
|
||||||
./test/results/test06-binary >| test/test06/proof || exit 4
|
./test/results/test06-x86-binary >| test/test06/proof || exit 4
|
||||||
out=$(sha256sum -c test/test06/proof.answer)
|
out=$(sha256sum -c test/test06/proof.answer)
|
||||||
[ "$out" = "test/test06/proof: OK" ] || exit 5
|
[ "$out" = "test/test06/proof: OK" ] || exit 5
|
||||||
fi
|
fi
|
|
@ -0,0 +1,44 @@
|
||||||
|
#! /bin/sh
|
||||||
|
## Copyright (C) 2017 Jeremiah Orians
|
||||||
|
## 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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
# Build the test
|
||||||
|
bin/M2-Planet --architecture knight-posix -f test/common_knight/functions/putchar.c \
|
||||||
|
-f test/common_knight/functions/exit.c \
|
||||||
|
-f test/test07/do.c \
|
||||||
|
-o test/test07/do.M1 || exit 1
|
||||||
|
|
||||||
|
# Macro assemble with libc written in M1-Macro
|
||||||
|
M1 -f test/common_knight/knight_defs.M1 \
|
||||||
|
-f test/common_knight/libc-core.M1 \
|
||||||
|
-f test/test07/do.M1 \
|
||||||
|
--BigEndian \
|
||||||
|
--architecture knight-posix \
|
||||||
|
-o test/test07/do.hex2 || exit 2
|
||||||
|
|
||||||
|
# Resolve all linkages
|
||||||
|
hex2 -f test/common_knight/ELF-knight.hex2 -f test/test07/do.hex2 --BigEndian --architecture knight-posix --BaseAddress 0x00 -o test/results/test07-knight-posix-binary --exec_enable || exit 3
|
||||||
|
|
||||||
|
# Ensure binary works if host machine supports test
|
||||||
|
if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "knight" ]
|
||||||
|
then
|
||||||
|
# Verify that the resulting file works
|
||||||
|
./test/results/test07-knight-posix-binary >| test/test07/proof || exit 4
|
||||||
|
out=$(sha256sum -c test/test07/proof.answer)
|
||||||
|
[ "$out" = "test/test07/proof: OK" ] || exit 5
|
||||||
|
fi
|
||||||
|
exit 0
|
|
@ -31,13 +31,13 @@ M1 -f test/common_x86/x86_defs.M1 \
|
||||||
-o test/test07/do.hex2 || exit 2
|
-o test/test07/do.hex2 || exit 2
|
||||||
|
|
||||||
# Resolve all linkages
|
# Resolve all linkages
|
||||||
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test07/do.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test07-binary --exec_enable || exit 3
|
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test07/do.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test07-x86-binary --exec_enable || exit 3
|
||||||
|
|
||||||
# Ensure binary works if host machine supports test
|
# Ensure binary works if host machine supports test
|
||||||
if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "x86" ]
|
if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "x86" ]
|
||||||
then
|
then
|
||||||
# Verify that the resulting file works
|
# Verify that the resulting file works
|
||||||
./test/results/test07-binary >| test/test07/proof || exit 4
|
./test/results/test07-x86-binary >| test/test07/proof || exit 4
|
||||||
out=$(sha256sum -c test/test07/proof.answer)
|
out=$(sha256sum -c test/test07/proof.answer)
|
||||||
[ "$out" = "test/test07/proof: OK" ] || exit 5
|
[ "$out" = "test/test07/proof: OK" ] || exit 5
|
||||||
fi
|
fi
|
|
@ -0,0 +1,45 @@
|
||||||
|
#! /bin/sh
|
||||||
|
## Copyright (C) 2017 Jeremiah Orians
|
||||||
|
## 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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
set -x
|
||||||
|
# Build the test
|
||||||
|
bin/M2-Planet --architecture knight-posix -f test/common_knight/functions/putchar.c \
|
||||||
|
-f test/common_knight/functions/exit.c \
|
||||||
|
-f test/common_knight/functions/malloc.c \
|
||||||
|
-f test/test08/struct.c \
|
||||||
|
-o test/test08/struct.M1 || exit 1
|
||||||
|
|
||||||
|
# Macro assemble with libc written in M1-Macro
|
||||||
|
M1 -f test/common_knight/knight_defs.M1 \
|
||||||
|
-f test/common_knight/libc-core.M1 \
|
||||||
|
-f test/test08/struct.M1 \
|
||||||
|
--BigEndian \
|
||||||
|
--architecture knight-posix \
|
||||||
|
-o test/test08/struct.hex2 || exit 2
|
||||||
|
|
||||||
|
# Resolve all linkages
|
||||||
|
hex2 -f test/common_knight/ELF-knight.hex2 -f test/test08/struct.hex2 --BigEndian --architecture knight-posix --BaseAddress 0x00 -o test/results/test08-knight-posix-binary --exec_enable || exit 3
|
||||||
|
|
||||||
|
# Ensure binary works if host machine supports test
|
||||||
|
if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "knight*" ]
|
||||||
|
then
|
||||||
|
# Verify that the compiled program returns the correct result
|
||||||
|
out=$(./test/results/test08-knight-posix-binary 2>&1 )
|
||||||
|
[ 16 = $? ] || exit 4
|
||||||
|
[ "$out" = "35419896642975313541989657891634" ] || exit 5
|
||||||
|
fi
|
||||||
|
exit 0
|
|
@ -19,7 +19,7 @@ set -x
|
||||||
# Build the test
|
# Build the test
|
||||||
bin/M2-Planet --architecture x86 -f test/common_x86/functions/putchar.c \
|
bin/M2-Planet --architecture x86 -f test/common_x86/functions/putchar.c \
|
||||||
-f test/common_x86/functions/exit.c \
|
-f test/common_x86/functions/exit.c \
|
||||||
-f functions/malloc.c \
|
-f test/common_x86/functions/malloc.c \
|
||||||
-f test/test08/struct.c \
|
-f test/test08/struct.c \
|
||||||
-o test/test08/struct.M1 || exit 1
|
-o test/test08/struct.M1 || exit 1
|
||||||
|
|
||||||
|
@ -32,13 +32,13 @@ M1 -f test/common_x86/x86_defs.M1 \
|
||||||
-o test/test08/struct.hex2 || exit 2
|
-o test/test08/struct.hex2 || exit 2
|
||||||
|
|
||||||
# Resolve all linkages
|
# Resolve all linkages
|
||||||
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test08/struct.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test08-binary --exec_enable || exit 3
|
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test08/struct.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test08-x86-binary --exec_enable || exit 3
|
||||||
|
|
||||||
# Ensure binary works if host machine supports test
|
# Ensure binary works if host machine supports test
|
||||||
if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "x86" ]
|
if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "x86" ]
|
||||||
then
|
then
|
||||||
# Verify that the compiled program returns the correct result
|
# Verify that the compiled program returns the correct result
|
||||||
out=$(./test/results/test08-binary 2>&1 )
|
out=$(./test/results/test08-x86-binary 2>&1 )
|
||||||
[ 16 = $? ] || exit 4
|
[ 16 = $? ] || exit 4
|
||||||
[ "$out" = "35419896642975313541989657891634" ] || exit 5
|
[ "$out" = "35419896642975313541989657891634" ] || exit 5
|
||||||
fi
|
fi
|
|
@ -19,7 +19,7 @@ set -x
|
||||||
# Build the test
|
# Build the test
|
||||||
bin/M2-Planet --architecture x86 -f test/common_x86/functions/putchar.c \
|
bin/M2-Planet --architecture x86 -f test/common_x86/functions/putchar.c \
|
||||||
-f test/common_x86/functions/exit.c \
|
-f test/common_x86/functions/exit.c \
|
||||||
-f functions/malloc.c \
|
-f test/common_x86/functions/malloc.c \
|
||||||
-f test/test10/nested_struct.c \
|
-f test/test10/nested_struct.c \
|
||||||
-o test/test10/nested_struct.M1 || exit 1
|
-o test/test10/nested_struct.M1 || exit 1
|
||||||
|
|
||||||
|
|
|
@ -20,13 +20,14 @@ set -ex
|
||||||
if [ -f bin/M2-Planet ]
|
if [ -f bin/M2-Planet ]
|
||||||
then
|
then
|
||||||
./bin/M2-Planet --architecture x86 -f functions/file.c \
|
./bin/M2-Planet --architecture x86 -f functions/file.c \
|
||||||
-f functions/malloc.c \
|
-f test/common_x86/functions/malloc.c \
|
||||||
-f functions/calloc.c \
|
-f functions/calloc.c \
|
||||||
-f test/common_x86/functions/exit.c \
|
-f test/common_x86/functions/exit.c \
|
||||||
-f functions/match.c \
|
-f functions/match.c \
|
||||||
-f functions/in_set.c \
|
-f functions/in_set.c \
|
||||||
-f functions/numerate_number.c \
|
-f functions/numerate_number.c \
|
||||||
-f functions/file_print.c \
|
-f functions/file_print.c \
|
||||||
|
-f functions/number_pack.c \
|
||||||
-f functions/string.c \
|
-f functions/string.c \
|
||||||
-f cc.h \
|
-f cc.h \
|
||||||
-f cc_reader.c \
|
-f cc_reader.c \
|
||||||
|
@ -40,13 +41,14 @@ elif [ -f bin/M2-Planet-seed ]
|
||||||
then
|
then
|
||||||
[ ! -f test/results ] && mkdir test/results
|
[ ! -f test/results ] && mkdir test/results
|
||||||
./bin/M2-Planet-seed --architecture x86 -f functions/file.c \
|
./bin/M2-Planet-seed --architecture x86 -f functions/file.c \
|
||||||
-f functions/malloc.c \
|
-f test/common_x86/functions/malloc.c \
|
||||||
-f functions/calloc.c \
|
-f functions/calloc.c \
|
||||||
-f test/common_x86/functions/exit.c \
|
-f test/common_x86/functions/exit.c \
|
||||||
-f functions/match.c \
|
-f functions/match.c \
|
||||||
-f functions/in_set.c \
|
-f functions/in_set.c \
|
||||||
-f functions/numerate_number.c \
|
-f functions/numerate_number.c \
|
||||||
-f functions/file_print.c \
|
-f functions/file_print.c \
|
||||||
|
-f functions/number_pack.c \
|
||||||
-f functions/string.c \
|
-f functions/string.c \
|
||||||
-f cc.h \
|
-f cc.h \
|
||||||
-f cc_reader.c \
|
-f cc_reader.c \
|
||||||
|
@ -65,6 +67,7 @@ ${CC} ${CFLAGS} \
|
||||||
functions/in_set.c \
|
functions/in_set.c \
|
||||||
functions/numerate_number.c \
|
functions/numerate_number.c \
|
||||||
functions/file_print.c \
|
functions/file_print.c \
|
||||||
|
functions/number_pack.c \
|
||||||
functions/string.c \
|
functions/string.c \
|
||||||
cc_reader.c \
|
cc_reader.c \
|
||||||
cc_strings.c \
|
cc_strings.c \
|
||||||
|
@ -76,13 +79,14 @@ ${CC} ${CFLAGS} \
|
||||||
-o bin/M2-Planet-gcc
|
-o bin/M2-Planet-gcc
|
||||||
|
|
||||||
./bin/M2-Planet-gcc --architecture x86 -f functions/file.c \
|
./bin/M2-Planet-gcc --architecture x86 -f functions/file.c \
|
||||||
-f functions/malloc.c \
|
-f test/common_x86/functions/malloc.c \
|
||||||
-f functions/calloc.c \
|
-f functions/calloc.c \
|
||||||
-f test/common_x86/functions/exit.c \
|
-f test/common_x86/functions/exit.c \
|
||||||
-f functions/match.c \
|
-f functions/match.c \
|
||||||
-f functions/in_set.c \
|
-f functions/in_set.c \
|
||||||
-f functions/numerate_number.c \
|
-f functions/numerate_number.c \
|
||||||
-f functions/file_print.c \
|
-f functions/file_print.c \
|
||||||
|
-f functions/number_pack.c \
|
||||||
-f functions/string.c \
|
-f functions/string.c \
|
||||||
-f cc.h \
|
-f cc.h \
|
||||||
-f cc_reader.c \
|
-f cc_reader.c \
|
||||||
|
@ -120,13 +124,14 @@ if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "x86" ]
|
||||||
then
|
then
|
||||||
# Verify that the resulting file works
|
# Verify that the resulting file works
|
||||||
./test/results/test100-binary --architecture x86 -f functions/file.c \
|
./test/results/test100-binary --architecture x86 -f functions/file.c \
|
||||||
-f functions/malloc.c \
|
-f test/common_x86/functions/malloc.c \
|
||||||
-f functions/calloc.c \
|
-f functions/calloc.c \
|
||||||
-f test/common_x86/functions/exit.c \
|
-f test/common_x86/functions/exit.c \
|
||||||
-f functions/match.c \
|
-f functions/match.c \
|
||||||
-f functions/in_set.c \
|
-f functions/in_set.c \
|
||||||
-f functions/numerate_number.c \
|
-f functions/numerate_number.c \
|
||||||
-f functions/file_print.c \
|
-f functions/file_print.c \
|
||||||
|
-f functions/number_pack.c \
|
||||||
-f functions/string.c \
|
-f functions/string.c \
|
||||||
-f cc.h \
|
-f cc.h \
|
||||||
-f cc_reader.c \
|
-f cc_reader.c \
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
6fdd455d135bb0d3ba048db2d9b41c469a5a8b695cf739f0916c8ec8e95dd637 test/test100/proof
|
956e610f595e53333bd961775a8f10fc9529e8a1dfb330886014a77c90914555 test/test100/proof
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
set -ex
|
set -ex
|
||||||
# Build the test
|
# Build the test
|
||||||
bin/M2-Planet --architecture x86 -f functions/malloc.c \
|
bin/M2-Planet --architecture x86 -f test/common_x86/functions/malloc.c \
|
||||||
-f functions/calloc.c \
|
-f functions/calloc.c \
|
||||||
-f test/common_x86/functions/putchar.c \
|
-f test/common_x86/functions/putchar.c \
|
||||||
-f test/test17/memset.c \
|
-f test/test17/memset.c \
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
set -ex
|
set -ex
|
||||||
# Build the test
|
# Build the test
|
||||||
bin/M2-Planet --architecture x86 -f functions/file.c \
|
bin/M2-Planet --architecture x86 -f functions/file.c \
|
||||||
-f functions/malloc.c \
|
-f test/common_x86/functions/malloc.c \
|
||||||
-f functions/calloc.c \
|
-f functions/calloc.c \
|
||||||
-f test/test18/math.c \
|
-f test/test18/math.c \
|
||||||
-o test/test18/math.M1 || exit 1
|
-o test/test18/math.M1 || exit 1
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
set -ex
|
set -ex
|
||||||
# Build the test
|
# Build the test
|
||||||
bin/M2-Planet --architecture x86 -f functions/file.c \
|
bin/M2-Planet --architecture x86 -f functions/file.c \
|
||||||
-f functions/malloc.c \
|
-f test/common_x86/functions/malloc.c \
|
||||||
-f functions/calloc.c \
|
-f functions/calloc.c \
|
||||||
-f test/common_x86/functions/exit.c \
|
-f test/common_x86/functions/exit.c \
|
||||||
-f functions/match.c \
|
-f functions/match.c \
|
||||||
|
|
|
@ -19,7 +19,7 @@ set -x
|
||||||
# Build the test
|
# Build the test
|
||||||
bin/M2-Planet --architecture x86 -f test/common_x86/functions/putchar.c \
|
bin/M2-Planet --architecture x86 -f test/common_x86/functions/putchar.c \
|
||||||
-f test/common_x86/functions/exit.c \
|
-f test/common_x86/functions/exit.c \
|
||||||
-f functions/malloc.c \
|
-f test/common_x86/functions/malloc.c \
|
||||||
-f test/test20/struct.c \
|
-f test/test20/struct.c \
|
||||||
-o test/test20/struct.M1 || exit 1
|
-o test/test20/struct.M1 || exit 1
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ set -x
|
||||||
./bin/M2-Planet --architecture x86 -f test/common_x86/functions/exit.c \
|
./bin/M2-Planet --architecture x86 -f test/common_x86/functions/exit.c \
|
||||||
-f functions/file.c \
|
-f functions/file.c \
|
||||||
-f functions/file_print.c \
|
-f functions/file_print.c \
|
||||||
-f functions/malloc.c \
|
-f test/common_x86/functions/malloc.c \
|
||||||
-f functions/calloc.c \
|
-f functions/calloc.c \
|
||||||
-f functions/match.c \
|
-f functions/match.c \
|
||||||
-f test/test21/blood-elf.c \
|
-f test/test21/blood-elf.c \
|
||||||
|
|
|
@ -20,7 +20,7 @@ set -x
|
||||||
./bin/M2-Planet --architecture x86 -f test/common_x86/functions/exit.c \
|
./bin/M2-Planet --architecture x86 -f test/common_x86/functions/exit.c \
|
||||||
-f functions/file.c \
|
-f functions/file.c \
|
||||||
-f functions/file_print.c \
|
-f functions/file_print.c \
|
||||||
-f functions/malloc.c \
|
-f test/common_x86/functions/malloc.c \
|
||||||
-f functions/calloc.c \
|
-f functions/calloc.c \
|
||||||
-f functions/match.c \
|
-f functions/match.c \
|
||||||
-f functions/in_set.c \
|
-f functions/in_set.c \
|
||||||
|
|
|
@ -20,7 +20,7 @@ set -x
|
||||||
./bin/M2-Planet --architecture x86 -f test/common_x86/functions/exit.c \
|
./bin/M2-Planet --architecture x86 -f test/common_x86/functions/exit.c \
|
||||||
-f functions/file.c \
|
-f functions/file.c \
|
||||||
-f functions/file_print.c \
|
-f functions/file_print.c \
|
||||||
-f functions/malloc.c \
|
-f test/common_x86/functions/malloc.c \
|
||||||
-f functions/calloc.c \
|
-f functions/calloc.c \
|
||||||
-f functions/match.c \
|
-f functions/match.c \
|
||||||
-f functions/in_set.c \
|
-f functions/in_set.c \
|
||||||
|
|
|
@ -20,7 +20,7 @@ set -x
|
||||||
./bin/M2-Planet --architecture x86 -f test/common_x86/functions/exit.c \
|
./bin/M2-Planet --architecture x86 -f test/common_x86/functions/exit.c \
|
||||||
-f functions/file.c \
|
-f functions/file.c \
|
||||||
-f functions/file_print.c \
|
-f functions/file_print.c \
|
||||||
-f functions/malloc.c \
|
-f test/common_x86/functions/malloc.c \
|
||||||
-f functions/calloc.c \
|
-f functions/calloc.c \
|
||||||
-f functions/uname.c \
|
-f functions/uname.c \
|
||||||
-f functions/match.c \
|
-f functions/match.c \
|
||||||
|
|
|
@ -20,7 +20,7 @@ set -x
|
||||||
./bin/M2-Planet --architecture x86 -f test/common_x86/functions/exit.c \
|
./bin/M2-Planet --architecture x86 -f test/common_x86/functions/exit.c \
|
||||||
-f functions/file.c \
|
-f functions/file.c \
|
||||||
-f functions/file_print.c \
|
-f functions/file_print.c \
|
||||||
-f functions/malloc.c \
|
-f test/common_x86/functions/malloc.c \
|
||||||
-f functions/calloc.c \
|
-f functions/calloc.c \
|
||||||
-f functions/match.c \
|
-f functions/match.c \
|
||||||
-f functions/in_set.c \
|
-f functions/in_set.c \
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
set -x
|
set -x
|
||||||
# Build the test
|
# Build the test
|
||||||
./bin/M2-Planet --architecture x86 -f test/test26/lisp.h \
|
./bin/M2-Planet --architecture x86 -f test/test26/lisp.h \
|
||||||
-f functions/malloc.c \
|
-f test/common_x86/functions/malloc.c \
|
||||||
-f functions/calloc.c \
|
-f functions/calloc.c \
|
||||||
-f functions/in_set.c \
|
-f functions/in_set.c \
|
||||||
-f functions/numerate_number.c \
|
-f functions/numerate_number.c \
|
||||||
|
|
|
@ -20,7 +20,7 @@ set -ex
|
||||||
bin/M2-Planet --architecture x86 -f test/common_x86/functions/putchar.c \
|
bin/M2-Planet --architecture x86 -f test/common_x86/functions/putchar.c \
|
||||||
-f functions/getchar.c \
|
-f functions/getchar.c \
|
||||||
-f test/common_x86/functions/exit.c \
|
-f test/common_x86/functions/exit.c \
|
||||||
-f functions/malloc.c \
|
-f test/common_x86/functions/malloc.c \
|
||||||
-f test/test99/cc500.c \
|
-f test/test99/cc500.c \
|
||||||
-o test/test99/cc0.M1 || exit 1
|
-o test/test99/cc0.M1 || exit 1
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue