13/24 working tests for armv7l

This commit is contained in:
Jeremiah Orians 2019-03-17 22:34:26 -04:00
parent 95107d9fb6
commit 87b1daaaa9
No known key found for this signature in database
GPG Key ID: 5410E91C14959E87
10 changed files with 266 additions and 8 deletions

View File

@ -16,7 +16,7 @@
* Current
** Added
Added 10/24 working tests for armv7l
Added 13/24 working tests for armv7l
** Changed

View File

@ -178,7 +178,7 @@ void function_call(char* s, int bool)
emit_out("\nR0 LOAD32 BP MEMORY\n");
emit_out("'0' R11 BP NO_SHIFT MOVE_ALWAYS\n");
emit_out("{LR} PUSH_ALWAYS\t# Protect the old link register\n");
emit_out("PLACEHOLDER\t# Calling function in R0");
emit_out("'3' R0 CALL_REG_ALWAYS\n");
emit_out("{LR} POP_ALWAYS\t# Prevent overwrite\n");
}
}
@ -277,7 +277,7 @@ void function_load(struct token_list* a)
if(KNIGHT_POSIX == Architecture) emit_out("LOADR R0 4\nJUMP 4\n&FUNCTION_");
else if(X86 == Architecture) emit_out("LOAD_IMMEDIATE_eax &FUNCTION_");
else if(ARMV7L == Architecture) emit_out("PLACEHOLDER\t#function_load\n");
else if(ARMV7L == Architecture) emit_out("!0 R0 LOAD32 R15 MEMORY\n~0 JUMP_ALWAYS\n&FUNCTION_");
emit_out(a->s);
emit_out("\n");
}
@ -339,8 +339,9 @@ void primary_expr_char()
{
if(KNIGHT_POSIX == Architecture) emit_out("LOADI R0 ");
else if(X86 == Architecture) emit_out("LOAD_IMMEDIATE_eax %");
else if(ARMV7L == Architecture) emit_out("PLACEHOLDER\t#primary_expr_char\n");
else if(ARMV7L == Architecture) emit_out("!");
emit_out(numerate_number(escape_lookup(global_token->s + 1)));
if(ARMV7L == Architecture) emit_out(" R0 LOADI8_ALWAYS");
emit_out("\n");
global_token = global_token->next;
}
@ -877,7 +878,7 @@ void collect_local()
{
if(KNIGHT_POSIX == Architecture) a->depth = function->arguments->depth + 8;
else if(X86 == Architecture) a->depth = function->arguments->depth - 8;
else if(ARMV7L == Architecture) a->depth = function->arguments->depth + 4;
else if(ARMV7L == Architecture) a->depth = function->arguments->depth + 8;
}
else
{

View File

@ -103,6 +103,10 @@ test: test00-knight-posix-binary \
test11-armv7l-binary \
test12-armv7l-binary \
test13-armv7l-binary \
test14-armv7l-binary \
test15-armv7l-binary \
test16-armv7l-binary \
test17-armv7l-binary \
test00-x86-binary \
test01-x86-binary \
test02-x86-binary \
@ -255,6 +259,18 @@ test12-armv7l-binary: M2-Planet | results
test13-armv7l-binary: M2-Planet | results
test/test13/hello-armv7l.sh
test14-armv7l-binary: M2-Planet | results
test/test14/hello-armv7l.sh
test15-armv7l-binary: M2-Planet | results
test/test15/hello-armv7l.sh
test16-armv7l-binary: M2-Planet | results
test/test16/hello-armv7l.sh
test17-armv7l-binary: M2-Planet | results
test/test17/hello-armv7l.sh
test00-x86-binary: M2-Planet | results
test/test00/hello-x86.sh

View File

@ -68,10 +68,12 @@ DEFINE JUMP_ALWAYS EA
DEFINE JUMP_EQUAL 0A
DEFINE JUMP_NE 1A
DEFINE CALL_ALWAYS EB
DEFINE CALL_REG_ALWAYS FF2FE1
# Data movement
DEFINE MOVE_ALWAYS A0E1
DEFINE MVN_ALWAYS 0E0E1
DEFINE MVNI8_EQUAL 0E003
DEFINE PUSH_ALWAYS 2DE9
DEFINE POP_ALWAYS bde8

View File

@ -0,0 +1,102 @@
/* 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/>.
*/
// CONSTANT stdin 0
// CONSTANT stdout 1
// CONSTANT stderr 2
// CONSTANT EOF 0xFFFFFFFF
int fgetc(FILE* f)
{
asm("!4 R0 SUB R12 ARITH_ALWAYS"
"!0 R0 LOAD32 R0 MEMORY"
"{R0} PUSH_ALWAYS"
"'0' SP R1 NO_SHIFT MOVE_ALWAYS"
"!1 R2 LOADI8_ALWAYS"
"!3 R7 LOADI8_ALWAYS"
"SYSCALL_ALWAYS"
"!0 CMPI8 R0 IMM_ALWAYS"
"{R0} POP_ALWAYS"
"!0 R0 MVNI8_EQUAL");
}
void fputc(char s, FILE* f)
{
asm("!8 R0 SUB R12 ARITH_ALWAYS"
"!0 R0 LOAD32 R0 MEMORY"
"!4 R1 SUB R12 ARITH_ALWAYS"
"!1 R2 LOADI8_ALWAYS"
"!4 R7 LOADI8_ALWAYS"
"SYSCALL_ALWAYS");
}
/* Important values needed for open
* O_RDONLY => 0
* O_WRONLY => 1
* O_RDWR => 2
* O_CREAT => 64
* O_TRUNC => 512
* S_IRWXU => 00700
* S_IXUSR => 00100
* S_IWUSR => 00200
* S_IRUSR => 00400
*/
FILE* open(char* name, int flag, int mode)
{
asm("!4 R0 SUB R12 ARITH_ALWAYS"
"!0 R0 LOAD32 R0 MEMORY"
"!8 R1 SUB R12 ARITH_ALWAYS"
"!0 R1 LOAD32 R1 MEMORY"
"!12 R2 SUB R12 ARITH_ALWAYS"
"!0 R2 LOAD32 R2 MEMORY"
"!5 R7 LOADI8_ALWAYS"
"SYSCALL_ALWAYS");
}
FILE* fopen(char* filename, char* mode)
{
FILE* f;
if('w' == mode[0])
{ /* 577 is O_WRONLY|O_CREAT|O_TRUNC, 384 is 600 in octal */
f = open(filename, 577 , 384);
}
else
{ /* Everything else is a read */
f = open(filename, 0, 0);
}
/* Negative numbers are error codes */
if(0 > f)
{
return 0;
}
return f;
}
int close(int fd)
{
asm("!4 R0 SUB R12 ARITH_ALWAYS"
"!0 R0 LOAD32 R0 MEMORY"
"!6 R7 LOADI8_ALWAYS"
"SYSCALL_ALWAYS");
}
int fclose(FILE* stream)
{
int error = close(stream);
return error;
}

View File

@ -31,8 +31,8 @@ f1c01feb865c4d552033186d9ce50dd39468a7e8aebf762886c13ad3e03b5011 test/results/t
e5e366ee8119a407b953f1b3c968fbea4b182195c8faeed075e04179af1c1f6e test/results/test10-armv7l-binary
c1b5a2a3cd46c5e95e5540e871c2a916e028684ca80f51c001ef489342e27625 test/results/test10-knight-posix-binary
020e86020819cc4963e6185b22e534fcf8306b6cb116f12643f254a24688ff0a test/results/test10-x86-binary
6221bd208e7cd811cb986438afc106fb8f4fe86e5bd24ebbcd0e105ac7266a8b test/results/test100-knight-posix-binary
33f6ebf5e99395dd737275a83fc3d95f5587a97f1ed27df81ca45f473d466abd test/results/test100-x86-binary
dfd2bf93ca4ff31f8c90cc2df0ab9773849453ea3dc0507c11a7fd32d182b7b7 test/results/test100-knight-posix-binary
3a595d94b1b328eae903d727ce5349aca29997b529434a5be47acd2e938499bc test/results/test100-x86-binary
56a8f3a60aa24cf0b6ff7874c50857a5a4bac9ad85b8eb342b97f6e6fb45107a test/results/test11-armv7l-binary
63fd5fbf389d1b19031026df193ec55e98d923b8568007125b80bc246c094496 test/results/test11-knight-posix-binary
3fd11bad4a426ce1ff8fd9c6d7d2b943effae9f3f5740b7376e426e9b0555851 test/results/test11-x86-binary
@ -42,12 +42,16 @@ f98ab8e4bb35580e0dde96126d7a56aff66bda208d02c8d89390b40d6cff591c test/results/t
d0b387c93e0c09bbb3ffec64b9d6c432df4fe7180ac4897c7c143408611c8edd test/results/test13-armv7l-binary
e50c97ba330823cb5cbe938bb9d1575340b083e60fc42db8edefcfd95851daa2 test/results/test13-knight-posix-binary
5051ffca2615144419f8ec1a5d4999486ae81e7781428f59e47e866af97cef92 test/results/test13-x86-binary
7934f4f8084e9818493977d2c7f1b32f6760035511ff3184e043df407fd73b81 test/results/test14-armv7l-binary
156fa1e6b5814da94a542dfe742f77e155d52724b34f75f3513b9e8f6f2503dd test/results/test14-knight-posix-binary
a8218958b628066e2fda63d3933f1bf607c358d7bdfe84fc02596393698ea5f6 test/results/test14-x86-binary
d1991eae9201b8b8da83f62752faf1fc48e248bfb70edbe43b3e8f989289ec0d test/results/test15-armv7l-binary
9f7c81e278248a3160d80a3f5ca0c39a5505ca9b45adc002e9b527db3e5f084a test/results/test15-knight-posix-binary
3adb4a5f3995583ba711151361728a26c3fbf0140864d13b4b042978ca45d683 test/results/test15-x86-binary
1d55f30cb7b7126c6e05aedd32d68d4d593bd82eec9e465affaf8e397b8bd58e test/results/test16-armv7l-binary
84f5472ce5711b9cad28fcd4c177eea673047c2561ea010ccb6bf5f50d89c713 test/results/test16-knight-posix-binary
d70e072f4f1f077d10ff65e9216ca8b423b996e35d68d208025db7a78b062f50 test/results/test16-x86-binary
9d37f83f4d4ffb63ac3d746f76594a28bf8a98a775d56093e3123e2b175df374 test/results/test17-armv7l-binary
0323ae8fa9e79cae9a58eec89a80b2c354db276d76c6f50b3bf50840327d4950 test/results/test17-knight-posix-binary
9b4ba350b07cc1cf4e12dc77d0d960ded1511f13b887363b0eb33421e2f626de test/results/test17-x86-binary
d0f0b1428c8db70806d6e2e5b81aca4b6752c4a581a3fa83da064317ceb605b0 test/results/test18-knight-posix-binary

View File

@ -1 +1 @@
ba11e8d2eba93ac348c0e4fd3aa572a17e11e19c6a3073ecd4376edc665440bb test/test100/proof
d78a6dc92d4f337488eba47daba7c9f0b432b83db78ed5b69fdd2c0e85d8806d test/test100/proof

44
test/test15/hello-armv7l.sh Executable file
View File

@ -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 armv7l -f test/common_armv7l/functions/file.c \
-f test/common_armv7l/functions/putchar.c \
-f test/test15/file_read.c \
-o test/test15/file_read.M1 || exit 1
# Macro assemble with libc written in M1-Macro
M1 -f test/common_armv7l/armv7l_defs.M1 \
-f test/common_armv7l/libc-core.M1 \
-f test/test15/file_read.M1 \
--LittleEndian \
--architecture armv7l \
-o test/test15/file_read.hex2 || exit 2
# Resolve all linkages
hex2 -f test/common_armv7l/ELF-armv7l.hex2 -f test/test15/file_read.hex2 --LittleEndian --architecture armv7l --BaseAddress 0x10000 -o test/results/test15-armv7l-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test
if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "armv7l" ]
then
# Verify that the resulting file works
./test/results/test15-armv7l-binary test/test15/file_read.c >| test/test15/proof || exit 4
out=$(sha256sum -c test/test15/proof.answer)
[ "$out" = "test/test15/proof: OK" ] || exit 5
fi
exit 0

44
test/test16/hello-armv7l.sh Executable file
View File

@ -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 armv7l -f test/common_armv7l/functions/file.c \
-f test/common_armv7l/functions/putchar.c \
-f test/test16/file_write.c \
-o test/test16/file_write.M1 || exit 1
# Macro assemble with libc written in M1-Macro
M1 -f test/common_armv7l/armv7l_defs.M1 \
-f test/common_armv7l/libc-core.M1 \
-f test/test16/file_write.M1 \
--LittleEndian \
--architecture armv7l \
-o test/test16/file_write.hex2 || exit 2
# Resolve all linkages
hex2 -f test/common_armv7l/ELF-armv7l.hex2 -f test/test16/file_write.hex2 --LittleEndian --architecture armv7l --BaseAddress 0x10000 -o test/results/test16-armv7l-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test
if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "armv7l" ]
then
# Verify that the resulting file works
./test/results/test16-armv7l-binary test/test16/proof || exit 4
out=$(sha256sum -c test/test16/proof.answer)
[ "$out" = "test/test16/proof: OK" ] || exit 5
fi
exit 0

45
test/test17/hello-armv7l.sh Executable file
View File

@ -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 -ex
# Build the test
bin/M2-Planet --architecture armv7l -f test/common_armv7l/functions/malloc.c \
-f functions/calloc.c \
-f test/common_armv7l/functions/putchar.c \
-f test/test17/memset.c \
-o test/test17/memset.M1 || exit 1
# Macro assemble with libc written in M1-Macro
M1 -f test/common_armv7l/armv7l_defs.M1 \
-f test/common_armv7l/libc-core.M1 \
-f test/test17/memset.M1 \
--LittleEndian \
--architecture armv7l \
-o test/test17/memset.hex2 || exit 2
# Resolve all linkages
hex2 -f test/common_armv7l/ELF-armv7l.hex2 -f test/test17/memset.hex2 --LittleEndian --architecture armv7l --BaseAddress 0x10000 -o test/results/test17-armv7l-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test
if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "armv7l" ]
then
# Verify that the resulting file works
./test/results/test17-armv7l-binary >| test/test17/proof || exit 4
out=$(sha256sum -c test/test17/proof.answer)
[ "$out" = "test/test17/proof: OK" ] || exit 5
fi
exit 0