15/24 working tests for armv7l

This commit is contained in:
Jeremiah Orians 2019-03-23 18:29:19 -04:00
parent 87b1daaaa9
commit c3ad31d66a
No known key found for this signature in database
GPG Key ID: 5410E91C14959E87
10 changed files with 255 additions and 24 deletions

View File

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

View File

@ -175,7 +175,8 @@ void function_call(char* s, int bool)
{
emit_out("!");
emit_out(s);
emit_out("\nR0 LOAD32 BP MEMORY\n");
emit_out(" R0 SUB BP ARITH_ALWAYS\n");
emit_out("!0 R0 LOAD32 R0 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("'3' R0 CALL_REG_ALWAYS\n");

View File

@ -107,6 +107,8 @@ test: test00-knight-posix-binary \
test15-armv7l-binary \
test16-armv7l-binary \
test17-armv7l-binary \
test18-armv7l-binary \
test19-armv7l-binary \
test00-x86-binary \
test01-x86-binary \
test02-x86-binary \
@ -271,6 +273,12 @@ test16-armv7l-binary: M2-Planet | results
test17-armv7l-binary: M2-Planet | results
test/test17/hello-armv7l.sh
test18-armv7l-binary: M2-Planet | results
test/test18/hello-armv7l.sh
test19-armv7l-binary: M2-Planet | results
test/test19/hello-armv7l.sh
test00-x86-binary: M2-Planet | results
test/test00/hello-x86.sh

View File

@ -39,6 +39,9 @@ DEFINE PC F
# Register masks for push/pop16
DEFINE {R0} 0100
DEFINE {R1} 0200
DEFINE {R2} 0400
DEFINE {R3} 0800
DEFINE {R4} 1000
DEFINE {R11} 0008
DEFINE {BP} 0010
DEFINE {LR} 0040
@ -73,16 +76,23 @@ DEFINE CALL_REG_ALWAYS FF2FE1
# Data movement
DEFINE MOVE_ALWAYS A0E1
DEFINE MVN_ALWAYS 0E0E1
DEFINE MVN_LT 0E0B1
DEFINE MVNI8_EQUAL 0E003
DEFINE PUSH_ALWAYS 2DE9
DEFINE POP_ALWAYS bde8
DEFINE POP_ALWAYS BDE8
# Arithmetic/logic
DEFINE AUX_ALWAYS E1
DEFINE IMM_ALWAYS E3
DEFINE ARITH_ALWAYS E2
DEFINE ARITH_GE A2
DEFINE ARITH_LT B2
DEFINE ARITH_NE 12
DEFINE ARITH2_ALWAYS E0
DEFINE ARITH2_GE A0
DEFINE ADCS 0B
DEFINE ADD 08
DEFINE ADDS 09
DEFINE AND 00
DEFINE CMP 005
DEFINE CMPI8 005
@ -90,6 +100,7 @@ DEFINE MUL 0
DEFINE OR 08
DEFINE SHIFT A0
DEFINE SUB 04
DEFINE RSUB 06
DEFINE XOR 02
# SYSCALL

View File

@ -38,8 +38,78 @@
# Stub that simply returns
:divide
{R4} PUSH_ALWAYS ; Protect R4
{R3} PUSH_ALWAYS ; Protect R3
{R2} PUSH_ALWAYS ; Protect R2
'0' R0 R3 NO_SHIFT MOVE_ALWAYS ; MOV R3,R0
'0' R1 R2 NO_SHIFT MOVE_ALWAYS ; MOV R2,R1
!0 R0 LOADI8_ALWAYS ; MOV R0,#0
!0 CMPI8 R2 IMM_ALWAYS ; CMP R2,#0
!0 R2 RSUB R2 ARITH_LT ; RSBLT R2,R2,#0
!1 R0 SUB R0 ARITH_LT ; SUBLT R0,R0,#1
!0 CMPI8 R3 IMM_ALWAYS ; CMP R3,#0
!0 R3 RSUB R3 ARITH_LT ; RSBLT R3,R3,#0
'0' R0 R0 MVN_LT ; MVNLT R0,R0
'0' R0 R4 NO_SHIFT MOVE_ALWAYS ; MOV R4,R0
!32 R0 LOADI8_ALWAYS ; MOV R0,#32.
!0 R1 LOADI8_ALWAYS ; MOV R1,#0
:divide_loop
'0' R2 R2 ADDS R2 ARITH2_ALWAYS ; ADDS R2,R2,R2
'0' R1 R1 ADCS R1 ARITH2_ALWAYS ; ADCS R1,R1,R1
'0' R3 CMP R1 AUX_ALWAYS ; CMP R1,R3
'0' R3 R1 SUB R1 ARITH2_GE ; SUBGE R1,R1,R3
!1 R2 ADD R2 ARITH_GE ; ADDGE R2,R2,#1
!1 R0 SUB R0 ARITH_ALWAYS ; SUB R0,R0,#1
!0 CMPI8 R0 IMM_ALWAYS ; CMP R0,#0
^~divide_loop JUMP_NE ; BNE loop
!0 CMPI8 R4 IMM_ALWAYS ; CMP R4,#0
!0 R2 RSUB R2 ARITH_NE ; RSBNE R2,R2,#0
'0' R2 R0 NO_SHIFT MOVE_ALWAYS ; MOV R0,R2
{R2} POP_ALWAYS ; Restore R2
{R3} POP_ALWAYS ; Restore R3
{R4} POP_ALWAYS ; Restore R4
'0' R14 R15 NO_SHIFT MOVE_ALWAYS
# Stub that simply returns
:modulus
{R4} PUSH_ALWAYS ; Protect R4
{R3} PUSH_ALWAYS ; Protect R3
{R2} PUSH_ALWAYS ; Protect R2
'0' R0 R3 NO_SHIFT MOVE_ALWAYS ; MOV R3,R0
'0' R1 R2 NO_SHIFT MOVE_ALWAYS ; MOV R2,R1
!0 R0 LOADI8_ALWAYS ; MOV R0,#0
!0 CMPI8 R2 IMM_ALWAYS ; CMP R2,#0
!0 R2 RSUB R2 ARITH_LT ; RSBLT R2,R2,#0
!1 R0 SUB R0 ARITH_LT ; SUBLT R0,R0,#1
!0 CMPI8 R3 IMM_ALWAYS ; CMP R3,#0
!0 R3 RSUB R3 ARITH_LT ; RSBLT R3,R3,#0
'0' R0 R0 MVN_LT ; MVNLT R0,R0
'0' R0 R4 NO_SHIFT MOVE_ALWAYS ; MOV R4,R0
!32 R0 LOADI8_ALWAYS ; MOV R0,#32.
!0 R1 LOADI8_ALWAYS ; MOV R1,#0
:modulus_loop
'0' R2 R2 ADDS R2 ARITH2_ALWAYS ; ADDS R2,R2,R2
'0' R1 R1 ADCS R1 ARITH2_ALWAYS ; ADCS R1,R1,R1
'0' R3 CMP R1 AUX_ALWAYS ; CMP R1,R3
'0' R3 R1 SUB R1 ARITH2_GE ; SUBGE R1,R1,R3
!1 R2 ADD R2 ARITH_GE ; ADDGE R2,R2,#1
!1 R0 SUB R0 ARITH_ALWAYS ; SUB R0,R0,#1
!0 CMPI8 R0 IMM_ALWAYS ; CMP R0,#0
^~modulus_loop JUMP_NE ; BNE loop
!0 CMPI8 R4 IMM_ALWAYS ; CMP R4,#0
!0 R1 RSUB R2 ARITH_NE ; RSBNE R2,R2,#0
'0' R1 R0 NO_SHIFT MOVE_ALWAYS ; MOV R0,R2
{R2} POP_ALWAYS ; Restore R2
{R3} POP_ALWAYS ; Restore R3
{R4} POP_ALWAYS ; Restore R4
'0' R14 R15 NO_SHIFT MOVE_ALWAYS

View File

@ -1,61 +1,63 @@
30f3b6ec29b446709c14eeeb9f2f3943c078329ef25fe04adffa8ecc14a567ad test/results/test00-armv7l-binary
d61b0f0acc0c23f7b0b7778449f83539ad92a8969bcde9fe503ad50966a09672 test/results/test00-armv7l-binary
64879eebceb475f21e54cb1f2e872996ca80e8c1fbb8b5895fb5fb6bac0c4384 test/results/test00-knight-posix-binary
c52562bd0aabb86ce8ca177f22f8d0455769b444df2d4d62894faab63b7151d8 test/results/test00-x86-binary
c531011fc5f54e90558cd8ed965c08af299f6e3b578cf32752fbca3374d4e411 test/results/test01-armv7l-binary
ba2f63bcefdab8648955b181a6028938cc1409dd88938e2bd5f51e85f8e79fd8 test/results/test01-armv7l-binary
486ee05ccea796a9cfa9bfb23189b8e014b7ce8d14fea03b27d679d410fe17dd test/results/test01-knight-posix-binary
eae96857f2b6d8e8ba86ac06e72345ea572622b358b23978bb5f2db1baadf41c test/results/test01-x86-binary
7ab0660ca3f7cc3812b27200da5638c3ec1843dc7e94b0d33ecfccf298704ff8 test/results/test02-armv7l-binary
eca3b8f019cd343a5433d5fffa5b3b5fd9653b967b7df3a1772f29864a91be7d test/results/test02-armv7l-binary
e6493845b9e94a617649638252f23502f9212de583fd00cba6cc07fffd296e32 test/results/test02-knight-posix-binary
8ead336d2f3f72d5874230492e0472edec61d355905e8636e3dfb2731695037c test/results/test02-x86-binary
0c0542e4bd78c68d78b92d340c751129b51596eaa1bc21652c2c24b1a6362139 test/results/test03-armv7l-binary
c39545274d6b677fc4aa7915b89b50700ffc83260d9e0f073924bd474952105c test/results/test03-armv7l-binary
96849d5a9294799a9648c24db21b2dab1555dd5ba69d172d77df800622347226 test/results/test03-knight-posix-binary
2313cb3f1a2b9eb6bf15f8d43418e15d6c16f7f1b5c22700fdfc2b38beb59192 test/results/test03-x86-binary
12af27e9925b88ea6e135246e920847c1b3a7a316db9f28b54881942faf32b4f test/results/test04-armv7l-binary
4463231ba4218eeecc9a37a98519ac8d39396e21cfb9263372b40abbd88b50d2 test/results/test04-armv7l-binary
df9ba08dfa69ac6cbb4483146dbbe079ef575d7de8318e2e52283151ebf24bd3 test/results/test04-knight-posix-binary
b7ddb37063c541c6a315809c4438aa235d6702f54bb64f4ffc88dbe78617de81 test/results/test04-x86-binary
18632e614634a1124aee22e5a39665f485a18e6486ba19a0b2c4ed3200b61202 test/results/test05-armv7l-binary
692aff5e76d70b47d6ece4cdf2678c5db1fd7f327934fd5995c5a8ec5eb1ee3e test/results/test05-armv7l-binary
5db3a2fbd84150dae41e1c778f2822d053a0539cbdf59bba56e5514222f46674 test/results/test05-knight-posix-binary
b5b76320ccda887a30b0bbefc2a5c302c8f2aa3c398d92ef3a79526690b25d6f test/results/test05-x86-binary
4e8bb78009a1a2986e46ec564d98996accfbe948723a11c9857b7aa39740dbdd test/results/test06-armv7l-binary
443c8c5d8c0f324bc547c195c49067d4ced532298034ca0690cd06009f41e054 test/results/test06-armv7l-binary
b177d769ae44c3509d9a08d0ee631ec69654dc5d723408bf0decdc67c42aae27 test/results/test06-knight-posix-binary
663fc6eefe965f237b6bf5a211398c8ae1210f97ff39b59603677e92462c68c7 test/results/test06-x86-binary
3a15eeae94c7db6f77e9647b20d09f96ed32290282eb3cfba6d3c9d83937c8f1 test/results/test07-armv7l-binary
522e359ef287493f6f0bd33b9f786a7b28452f2abac44d32cf2ab8afaf69d882 test/results/test07-armv7l-binary
9159c4ba8196b24ec78bc9ebfbc7066d510ddbf03461736e7795a48634134dc5 test/results/test07-knight-posix-binary
a9a3e332d13ded5f80d7431f8717f26527b3722b33ea57760a9a5723dffc099c test/results/test07-x86-binary
f9b926f945ed1d89b0115f5902892eac3bc443d2371e7cd211ac78e650669ae7 test/results/test08-armv7l-binary
8f48e296e2cda43fd3991b5d5e5161a1e17b5c9549d808cfffa9a9fa6a0d71a2 test/results/test08-armv7l-binary
b824859fd0e39f1417742a1b9a1cec18ade78afdd80ce2c64cb54cdf7683f53a test/results/test08-knight-posix-binary
f1c01feb865c4d552033186d9ce50dd39468a7e8aebf762886c13ad3e03b5011 test/results/test08-x86-binary
3f7fcdb09da02dadae1e1591ff2ddbebd2ac7d9b08bc277bd49fc7277c84eeba test/results/test09-armv7l-binary
e51082e94a5e1db490e69aaf21ddbcf5d7c40c736e7d60dc0ea6c09f8d67ea7f test/results/test09-armv7l-binary
0feaacc13ad24c2b513fd9d46a58c38b1af57e77275c9a148cafb4a0d3cc7b7a test/results/test09-knight-posix-binary
3b39e72f3de90ed690adfaf6145af46157cef2ec5e72867ac577fa27a0229894 test/results/test09-x86-binary
e5e366ee8119a407b953f1b3c968fbea4b182195c8faeed075e04179af1c1f6e test/results/test10-armv7l-binary
7c677be4b211bff23ef44dad9baebdf3ba8b80f66308b765253e190264454561 test/results/test10-armv7l-binary
c1b5a2a3cd46c5e95e5540e871c2a916e028684ca80f51c001ef489342e27625 test/results/test10-knight-posix-binary
020e86020819cc4963e6185b22e534fcf8306b6cb116f12643f254a24688ff0a test/results/test10-x86-binary
dfd2bf93ca4ff31f8c90cc2df0ab9773849453ea3dc0507c11a7fd32d182b7b7 test/results/test100-knight-posix-binary
3a595d94b1b328eae903d727ce5349aca29997b529434a5be47acd2e938499bc test/results/test100-x86-binary
56a8f3a60aa24cf0b6ff7874c50857a5a4bac9ad85b8eb342b97f6e6fb45107a test/results/test11-armv7l-binary
ff78d3b3fd12b22209fbe1ec00e5951dfff5ee0f1fd17f76895c9d158737b813 test/results/test100-knight-posix-binary
27dae5fb2488e7cb5f2232f43d3107177aff476308c3ce078ce68745254836e3 test/results/test100-x86-binary
ee1f6f1dfebc705f9fa8e02185b9d698b40dee3c58e03846fc84b90ea9665bc0 test/results/test11-armv7l-binary
63fd5fbf389d1b19031026df193ec55e98d923b8568007125b80bc246c094496 test/results/test11-knight-posix-binary
3fd11bad4a426ce1ff8fd9c6d7d2b943effae9f3f5740b7376e426e9b0555851 test/results/test11-x86-binary
4617e974d1a4d9ba96b06d1f344f6ded437bfe9d4845c61f7423bfb352756527 test/results/test12-armv7l-binary
cb6851568754a78da8d451df3b7ad7cd08894dcd7d85d55b42b86fae27289063 test/results/test12-armv7l-binary
313536f9209d29d4c3b40f6ada898f81c1fb3b650ca1a84754f90b1db3b9e001 test/results/test12-knight-posix-binary
f98ab8e4bb35580e0dde96126d7a56aff66bda208d02c8d89390b40d6cff591c test/results/test12-x86-binary
d0b387c93e0c09bbb3ffec64b9d6c432df4fe7180ac4897c7c143408611c8edd test/results/test13-armv7l-binary
dd3a885a0d9ec82be2fabc9c5681333e5082e9f277ff1a71ba0f72d112187a94 test/results/test13-armv7l-binary
e50c97ba330823cb5cbe938bb9d1575340b083e60fc42db8edefcfd95851daa2 test/results/test13-knight-posix-binary
5051ffca2615144419f8ec1a5d4999486ae81e7781428f59e47e866af97cef92 test/results/test13-x86-binary
7934f4f8084e9818493977d2c7f1b32f6760035511ff3184e043df407fd73b81 test/results/test14-armv7l-binary
0f77dcc7236dfdd135ccd4bafba2692fae890b0cf20de7e70c6fb0fa03eb8ee9 test/results/test14-armv7l-binary
156fa1e6b5814da94a542dfe742f77e155d52724b34f75f3513b9e8f6f2503dd test/results/test14-knight-posix-binary
a8218958b628066e2fda63d3933f1bf607c358d7bdfe84fc02596393698ea5f6 test/results/test14-x86-binary
d1991eae9201b8b8da83f62752faf1fc48e248bfb70edbe43b3e8f989289ec0d test/results/test15-armv7l-binary
e0d83fe73686c09db16a0f9fa65d4611b297da0c435a77b9cd51a89df7d2c16d test/results/test15-armv7l-binary
9f7c81e278248a3160d80a3f5ca0c39a5505ca9b45adc002e9b527db3e5f084a test/results/test15-knight-posix-binary
3adb4a5f3995583ba711151361728a26c3fbf0140864d13b4b042978ca45d683 test/results/test15-x86-binary
1d55f30cb7b7126c6e05aedd32d68d4d593bd82eec9e465affaf8e397b8bd58e test/results/test16-armv7l-binary
2a07f8aa3ef9e733c67318558220ce7c96987156903f6d4feb8b8a92caf4f036 test/results/test16-armv7l-binary
84f5472ce5711b9cad28fcd4c177eea673047c2561ea010ccb6bf5f50d89c713 test/results/test16-knight-posix-binary
d70e072f4f1f077d10ff65e9216ca8b423b996e35d68d208025db7a78b062f50 test/results/test16-x86-binary
9d37f83f4d4ffb63ac3d746f76594a28bf8a98a775d56093e3123e2b175df374 test/results/test17-armv7l-binary
b4090b8fa5bd67ad00c6ef62e8647fe28462d824807d348ec3be5304409f8bd8 test/results/test17-armv7l-binary
0323ae8fa9e79cae9a58eec89a80b2c354db276d76c6f50b3bf50840327d4950 test/results/test17-knight-posix-binary
9b4ba350b07cc1cf4e12dc77d0d960ded1511f13b887363b0eb33421e2f626de test/results/test17-x86-binary
dd62c0e2d2bdac340d22a5cd7ba38b0dde1792620c24024bcff3a5c2b6ad74bd test/results/test18-armv7l-binary
d0f0b1428c8db70806d6e2e5b81aca4b6752c4a581a3fa83da064317ceb605b0 test/results/test18-knight-posix-binary
8de7384c4633b1d5c60bbbb298d7f4b738e52fbc266ef4ef9a48b3cb995e3176 test/results/test18-x86-binary
952e0e9d4ae098c73b6152422a5ed9eb29ac2fc3b853c8246433ea8832766598 test/results/test19-armv7l-binary
32ba6ae74a8756fe4b95c65a643513bdd785778f98a878b3ea5459b5aaccaa38 test/results/test19-knight-posix-binary
cefc5a53513abdb9069dc8bdb7b4529307420d5dd412a10112c3253bdcd29c46 test/results/test19-x86-binary
6a59795dbb4397d0efaf1ad613d646ec435eec62db30eb758bcf2499d651520e test/results/test20-knight-posix-binary

View File

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

45
test/test18/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/file.c \
-f test/common_armv7l/functions/malloc.c \
-f functions/calloc.c \
-f test/test18/math.c \
-o test/test18/math.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/test18/math.M1 \
--LittleEndian \
--architecture armv7l \
-o test/test18/math.hex2 || exit 2
# Resolve all linkages
hex2 -f test/common_armv7l/ELF-armv7l.hex2 -f test/test18/math.hex2 --LittleEndian --architecture armv7l --BaseAddress 0x10000 -o test/results/test18-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/test18-armv7l-binary >| test/test18/proof || exit 4
out=$(sha256sum -c test/test18/proof.answer)
[ "$out" = "test/test18/proof: OK" ] || exit 5
fi
exit 0

49
test/test19/hello-armv7l.sh Executable file
View File

@ -0,0 +1,49 @@
#! /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/malloc.c \
-f functions/calloc.c \
-f test/common_armv7l/functions/exit.c \
-f functions/match.c \
-f functions/in_set.c \
-f functions/numerate_number.c \
-f test/test19/getopt.c \
-o test/test19/getopt.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/test19/getopt.M1 \
--LittleEndian \
--architecture armv7l \
-o test/test19/getopt.hex2 || exit 2
# Resolve all linkages
hex2 -f test/common_armv7l/ELF-armv7l.hex2 -f test/test19/getopt.hex2 --LittleEndian --architecture armv7l --BaseAddress 0x10000 -o test/results/test19-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/test19-armv7l-binary -f test/test19/input -o test/test19/proof || exit 4
out=$(sha256sum -c test/test19/proof.answer)
[ "$out" = "test/test19/proof: OK" ] || exit 5
fi
exit 0

45
test/test20/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 -x
# Build the test
bin/M2-Planet --architecture armv7l -f test/common_armv7l/functions/putchar.c \
-f test/common_armv7l/functions/exit.c \
-f test/common_armv7l/functions/malloc.c \
-f test/test20/struct.c \
-o test/test20/struct.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/test20/struct.M1 \
--LittleEndian \
--architecture armv7l \
-o test/test20/struct.hex2 || exit 2
# Resolve all linkages
hex2 -f test/common_armv7l/ELF-armv7l.hex2 -f test/test20/struct.hex2 --LittleEndian --architecture armv7l --BaseAddress 0x10000 -o test/results/test20-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 compiled program returns the correct result
out=$(./test/results/test20-armv7l-binary 2>&1 )
[ 20 = $? ] || exit 4
[ "$out" = "35419896642975313541989657891634" ] || exit 5
fi
exit 0