First working test for ARMv7l
This commit is contained in:
parent
d5d64bb254
commit
d1036c60c8
|
@ -16,6 +16,16 @@
|
|||
|
||||
* Current
|
||||
** Added
|
||||
Added 1/24 working tests for armv7l
|
||||
|
||||
** Changed
|
||||
|
||||
** Fixed
|
||||
|
||||
** Removed
|
||||
|
||||
* 1.1 - 2019-03-09
|
||||
** Added
|
||||
Added support for \f, \v and \e
|
||||
Added refresh to bootstrap.sh to build seed from cc_x86.s
|
||||
Added missing license headers
|
||||
|
|
|
@ -104,4 +104,4 @@ hex2 -f test/common_x86/ELF-i386-debug.hex2 \
|
|||
--exec_enable || exit 2
|
||||
|
||||
# self-host
|
||||
./test/test100/hello-x86.sh
|
||||
./test/test100/hello.sh
|
||||
|
|
2
cc.c
2
cc.c
|
@ -110,7 +110,7 @@ int main(int argc, char** argv)
|
|||
}
|
||||
|
||||
/* Temp solution to aborting when an architecture isn't supported yet but is expected to be fully supported */
|
||||
if(!in_set(Architecture, "\x01\x02"))
|
||||
if(!in_set(Architecture, "\x01\x02\x04"))
|
||||
{
|
||||
file_print("ALL IS FIRE\n\n", stderr);
|
||||
exit(EXIT_FAILURE);
|
||||
|
|
105
cc_core.c
105
cc_core.c
|
@ -126,12 +126,18 @@ void function_call(char* s, int bool)
|
|||
emit_out("PUSH_ebp\t# Protect the old base pointer\n");
|
||||
emit_out("COPY_esp_to_edi\t# Copy new base pointer\n");
|
||||
}
|
||||
else if(ARMV7L == Architecture)
|
||||
{
|
||||
emit_out("'0' R14 PUSH_ALWAYS\t# Protect the old link register\n");
|
||||
emit_out("'0' R12 PUSH_ALWAYS\t# Protect the old base pointer\n");
|
||||
}
|
||||
|
||||
if(global_token->s[0] != ')')
|
||||
{
|
||||
expression();
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("PUSHR R0 R15\t#_process_expression1\n");
|
||||
else if(X86 == Architecture) emit_out("PUSH_eax\t#_process_expression1\n");
|
||||
else if(ARMV7L == Architecture) emit_out("REG R0 PUSH_ALWAYS\t#_process_expression1\n");
|
||||
passed = 1;
|
||||
|
||||
while(global_token->s[0] == ',')
|
||||
|
@ -140,6 +146,7 @@ void function_call(char* s, int bool)
|
|||
expression();
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("PUSHR R0 R15\t#_process_expression2\n");
|
||||
else if(X86 == Architecture) emit_out("PUSH_eax\t#_process_expression2\n");
|
||||
else if(ARMV7L == Architecture) emit_out("REG R0 PUSH_ALWAYS\t#_process_expression2\n");
|
||||
passed = passed + 1;
|
||||
}
|
||||
}
|
||||
|
@ -163,6 +170,13 @@ void function_call(char* s, int bool)
|
|||
emit_out("COPY_edi_to_ebp\n");
|
||||
emit_out("CALL_eax\n");
|
||||
}
|
||||
else if(ARMV7L == Architecture)
|
||||
{
|
||||
emit_out("!");
|
||||
emit_out(s);
|
||||
emit_out("\nR0 LOAD32 R12\n");
|
||||
emit_out("'0' R12 R13 MOVE_ALWAYS\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -180,12 +194,20 @@ void function_call(char* s, int bool)
|
|||
emit_out(s);
|
||||
emit_out("\n");
|
||||
}
|
||||
else if(ARMV7L == Architecture)
|
||||
{
|
||||
emit_out("'0' R12 R13 MOVE_ALWAYS\n");
|
||||
emit_out("^~FUNCTION_");
|
||||
emit_out(s);
|
||||
emit_out(" CALL_ALWAYS\n");
|
||||
}
|
||||
}
|
||||
|
||||
for(; passed > 0; passed = passed - 1)
|
||||
{
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("POPR R1 R15\t# _process_expression_locals\n");
|
||||
else if(X86 == Architecture) emit_out("POP_ebx\t# _process_expression_locals\n");
|
||||
else if(ARMV7L == Architecture) emit_out("'0' R1 POP_ALWAYS\t# _process_expression_locals\n");
|
||||
}
|
||||
|
||||
if(KNIGHT_POSIX == Architecture)
|
||||
|
@ -198,12 +220,18 @@ void function_call(char* s, int bool)
|
|||
emit_out("POP_ebp\t# Restore old base pointer\n");
|
||||
emit_out("POP_edi\t# Prevent overwrite\n");
|
||||
}
|
||||
else if(ARMV7L == Architecture)
|
||||
{
|
||||
emit_out("'0' R12 POP_ALWAYS\t# Restore old base pointer\n");
|
||||
emit_out("'0' R14 POP_ALWAYS\t# Prevent overwrite\n");
|
||||
}
|
||||
}
|
||||
|
||||
void constant_load(struct token_list* a)
|
||||
{
|
||||
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#constant_load\n");
|
||||
emit_out(a->arguments->s);
|
||||
emit_out("\n");
|
||||
}
|
||||
|
@ -219,6 +247,7 @@ void variable_load(struct token_list* a)
|
|||
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("ADDI R0 R14 ");
|
||||
else if(X86 == Architecture) emit_out("LOAD_BASE_ADDRESS_eax %");
|
||||
else if(ARMV7L == Architecture) emit_out("PLACEHOLDER\t#variable_load\n");
|
||||
|
||||
emit_out(numerate_number(a->depth));
|
||||
emit_out("\n");
|
||||
|
@ -227,6 +256,7 @@ void variable_load(struct token_list* a)
|
|||
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("LOAD R0 R0 0\n");
|
||||
else if(X86 == Architecture) emit_out("LOAD_INTEGER\n");
|
||||
else if(ARMV7L == Architecture) emit_out("PLACEHOLDER\t#variable_load\n");
|
||||
}
|
||||
|
||||
void function_load(struct token_list* a)
|
||||
|
@ -239,6 +269,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");
|
||||
emit_out(a->s);
|
||||
emit_out("\n");
|
||||
}
|
||||
|
@ -248,12 +279,14 @@ void global_load(struct token_list* a)
|
|||
current_target = a->type;
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("LOADR R0 4\nJUMP 4\n&GLOBAL_");
|
||||
else if(X86 == Architecture) emit_out("LOAD_IMMEDIATE_eax &GLOBAL_");
|
||||
else if(ARMV7L == Architecture) emit_out("PLACEHOLDER\t#global_load\n");
|
||||
emit_out(a->s);
|
||||
emit_out("\n");
|
||||
if(!match("=", global_token->s))
|
||||
{
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("LOAD R0 R0 0\n");
|
||||
else if(X86 == Architecture) emit_out("LOAD_INTEGER\n");
|
||||
else if(ARMV7L == Architecture) emit_out("PLACEHOLDER\t#global_load\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -282,6 +315,7 @@ void primary_expr_string()
|
|||
current_count = current_count + 1;
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("LOADR R0 4\nJUMP 4\n&STRING_");
|
||||
else if(X86 == Architecture) emit_out("LOAD_IMMEDIATE_eax &STRING_");
|
||||
else if(ARMV7L == Architecture) emit_out("PLACEHOLDER\t#primary_expr_string\n");
|
||||
uniqueID_out(function->s, number_string);
|
||||
|
||||
/* The target */
|
||||
|
@ -297,6 +331,7 @@ 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");
|
||||
emit_out(numerate_number(escape_lookup(global_token->s + 1)));
|
||||
emit_out("\n");
|
||||
global_token = global_token->next;
|
||||
|
@ -326,6 +361,12 @@ void primary_expr_number()
|
|||
emit_out(global_token->s);
|
||||
emit_out("\n");
|
||||
}
|
||||
else if(ARMV7L == Architecture)
|
||||
{
|
||||
emit_out("!0 R0 LOAD32 R15 MEMORY\n~0 JUMP\n%");
|
||||
emit_out(global_token->s);
|
||||
emit_out("\n");
|
||||
}
|
||||
global_token = global_token->next;
|
||||
}
|
||||
|
||||
|
@ -404,12 +445,14 @@ void common_recursion(FUNCTION f)
|
|||
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("PUSHR R0 R15\t#_common_recursion\n");
|
||||
else if(X86 == Architecture) emit_out("PUSH_eax\t#_common_recursion\n");
|
||||
else if(ARMV7L == Architecture) emit_out("PLACEHOLDER\t#common_recursion\n");
|
||||
|
||||
f();
|
||||
current_target = promote_type(current_target, last_type);
|
||||
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("POPR R1 R15\t# _common_recursion\n");
|
||||
else if(X86 == Architecture) emit_out("POP_ebx\t# _common_recursion\n");
|
||||
else if(ARMV7L == Architecture) emit_out("PLACEHOLDER\t#common_recursion\n");
|
||||
}
|
||||
|
||||
void general_recursion( FUNCTION f, char* s, char* name, FUNCTION iterate)
|
||||
|
@ -471,12 +514,14 @@ void postfix_expr_arrow()
|
|||
emit_out(numerate_number(i->offset));
|
||||
emit_out("\nADD_ebx_to_eax\n");
|
||||
}
|
||||
else if(ARMV7L == Architecture) emit_out("PLACEHOLDER\t#postfix_expr_arrow\n");
|
||||
}
|
||||
|
||||
if((!match("=", global_token->s) && (4 >= i->size)))
|
||||
{
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("LOAD R0 R0 0\n");
|
||||
else if(X86 == Architecture) emit_out("LOAD_INTEGER\n");
|
||||
else if(ARMV7L == Architecture) emit_out("PLACEHOLDER\t#postfix_expr_arrow\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -488,17 +533,20 @@ void postfix_expr_array()
|
|||
char* assign;
|
||||
if(KNIGHT_POSIX == Architecture) assign = "LOAD R0 R0 0\n";
|
||||
else if(X86 == Architecture) assign = "LOAD_INTEGER\n";
|
||||
else if(ARMV7L == Architecture) emit_out("PLACEHOLDER\t#postfix_expr_array\n");
|
||||
|
||||
/* Add support for Ints */
|
||||
if(match("char*", current_target->name))
|
||||
{
|
||||
if(KNIGHT_POSIX == Architecture) assign = "LOAD8 R0 R0 0\n";
|
||||
else if(X86 == Architecture) assign = "LOAD_BYTE\n";
|
||||
else if(ARMV7L == Architecture) emit_out("PLACEHOLDER\t#postfix_expr_array\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("SALI R0 ");
|
||||
else if(X86 == Architecture) emit_out("SAL_eax_Immediate8 !");
|
||||
else if(ARMV7L == Architecture) emit_out("PLACEHOLDER\t#postfix_expr_array\n");
|
||||
|
||||
emit_out(numerate_number(ceil_log2(current_target->indirect->size)));
|
||||
emit_out("\n");
|
||||
|
@ -506,6 +554,7 @@ void postfix_expr_array()
|
|||
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("ADD R0 R0 R1\n");
|
||||
else if(X86 == Architecture) emit_out("ADD_ebx_to_eax\n");
|
||||
else if(ARMV7L == Architecture) emit_out("PLACEHOLDER\t#postfix_expr_array\n");
|
||||
|
||||
require_match("ERROR in postfix_expr\nMissing ]\n", "]");
|
||||
|
||||
|
@ -534,6 +583,7 @@ void unary_expr_sizeof()
|
|||
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("LOADUI R0 ");
|
||||
else if(X86 == Architecture) emit_out("LOAD_IMMEDIATE_eax %");
|
||||
else if(ARMV7L == Architecture) emit_out("PLACEHOLDER\t#unary_expr_sizeof\n");
|
||||
emit_out(numerate_number(a->size));
|
||||
emit_out("\n");
|
||||
}
|
||||
|
@ -592,6 +642,16 @@ void additive_expr_stub()
|
|||
general_recursion(postfix_expr, "COPY_eax_to_ecx\nCOPY_ebx_to_eax\nSAL_eax_cl\n", "<<", additive_expr_stub);
|
||||
general_recursion(postfix_expr, "COPY_eax_to_ecx\nCOPY_ebx_to_eax\nSAR_eax_cl\n", ">>", additive_expr_stub);
|
||||
}
|
||||
else if(ARMV7L == Architecture)
|
||||
{
|
||||
general_recursion(postfix_expr, "PLACEHOLDER\t#additive_expr_stub\n", "+", additive_expr_stub);
|
||||
general_recursion(postfix_expr, "PLACEHOLDER\t#additive_expr_stub\n", "-", additive_expr_stub);
|
||||
general_recursion(postfix_expr, "PLACEHOLDER\t#additive_expr_stub\n", "*", additive_expr_stub);
|
||||
general_recursion(postfix_expr, "PLACEHOLDER\t#additive_expr_stub\n", "/", additive_expr_stub);
|
||||
general_recursion(postfix_expr, "PLACEHOLDER\t#additive_expr_stub\n", "%", additive_expr_stub);
|
||||
general_recursion(postfix_expr, "PLACEHOLDER\t#additive_expr_stub\n", "<<", additive_expr_stub);
|
||||
general_recursion(postfix_expr, "PLACEHOLDER\t#additive_expr_stub\n", ">>", additive_expr_stub);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -631,6 +691,15 @@ void relational_expr_stub()
|
|||
general_recursion(additive_expr, "CMP\nSETE\nMOVEZBL\n", "==", relational_expr_stub);
|
||||
general_recursion(additive_expr, "CMP\nSETNE\nMOVEZBL\n", "!=", relational_expr_stub);
|
||||
}
|
||||
else if(ARMV7L == Architecture)
|
||||
{
|
||||
general_recursion(additive_expr, "PLACEHOLDER\t#relational_expr_stub\n", "<", relational_expr_stub);
|
||||
general_recursion(additive_expr, "PLACEHOLDER\t#relational_expr_stub\n", "<=", relational_expr_stub);
|
||||
general_recursion(additive_expr, "PLACEHOLDER\t#relational_expr_stub\n", ">=", relational_expr_stub);
|
||||
general_recursion(additive_expr, "PLACEHOLDER\t#relational_expr_stub\n", ">", relational_expr_stub);
|
||||
general_recursion(additive_expr, "PLACEHOLDER\t#relational_expr_stub\n", "==", relational_expr_stub);
|
||||
general_recursion(additive_expr, "PLACEHOLDER\t#relational_expr_stub\n", "!=", relational_expr_stub);
|
||||
}
|
||||
}
|
||||
|
||||
void relational_expr()
|
||||
|
@ -666,6 +735,14 @@ void bitwise_expr_stub()
|
|||
general_recursion(relational_expr, "OR_eax_ebx\n", "||", bitwise_expr_stub);
|
||||
general_recursion(relational_expr, "XOR_ebx_eax_into_eax\n", "^", bitwise_expr_stub);
|
||||
}
|
||||
else if(ARMV7L == Architecture)
|
||||
{
|
||||
general_recursion(relational_expr, "PLACEHOLDER\t#bitwise_expr_stub\n", "&", bitwise_expr_stub);
|
||||
general_recursion(relational_expr, "PLACEHOLDER\t#bitwise_expr_stub\n", "&&", bitwise_expr_stub);
|
||||
general_recursion(relational_expr, "PLACEHOLDER\t#bitwise_expr_stub\n", "|", bitwise_expr_stub);
|
||||
general_recursion(relational_expr, "PLACEHOLDER\t#bitwise_expr_stub\n", "||", bitwise_expr_stub);
|
||||
general_recursion(relational_expr, "PLACEHOLDER\t#bitwise_expr_stub\n", "^", bitwise_expr_stub);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -697,20 +774,24 @@ void primary_expr()
|
|||
else if('-' == global_token->s[0])
|
||||
{
|
||||
if(X86 == Architecture) emit_out("LOAD_IMMEDIATE_eax %0\n");
|
||||
else if(ARMV7L == Architecture) emit_out("PLACEHOLDER\t#primary_expr\n");
|
||||
|
||||
common_recursion(primary_expr);
|
||||
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("NEG R0 R0\n");
|
||||
else if(X86 == Architecture) emit_out("SUBTRACT_eax_from_ebx_into_ebx\nMOVE_ebx_to_eax\n");
|
||||
else if(ARMV7L == Architecture) emit_out("PLACEHOLDER\t#primary_expr\n");
|
||||
}
|
||||
else if('!' == global_token->s[0])
|
||||
{
|
||||
if(X86 == Architecture) emit_out("LOAD_IMMEDIATE_eax %1\n");
|
||||
else if(ARMV7L == Architecture) emit_out("PLACEHOLDER\t#primary_expr\n");
|
||||
|
||||
common_recursion(postfix_expr);
|
||||
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("XORI R0 R0 1\n");
|
||||
else if(X86 == Architecture) emit_out("XOR_ebx_eax_into_eax\n");
|
||||
else if(ARMV7L == Architecture) emit_out("PLACEHOLDER\t#primary_expr\n");
|
||||
}
|
||||
else if('~' == global_token->s[0])
|
||||
{
|
||||
|
@ -718,6 +799,7 @@ void primary_expr()
|
|||
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("NOT R0 R0\n");
|
||||
else if(X86 == Architecture) emit_out("NOT_eax\n");
|
||||
else if(ARMV7L == Architecture) emit_out("PLACEHOLDER\t#primary_expr\n");
|
||||
}
|
||||
else if(global_token->s[0] == '(')
|
||||
{
|
||||
|
@ -742,11 +824,13 @@ void expression()
|
|||
{
|
||||
if(KNIGHT_POSIX == Architecture) store = "STORE R0 R1 0\n";
|
||||
else if(X86 == Architecture) store = "STORE_INTEGER\n";
|
||||
else if(ARMV7L == Architecture) emit_out("!0 R0 STORE32 R1 MEMORY\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
if(KNIGHT_POSIX == Architecture) store = "STORE8 R0 R1 0\n";
|
||||
else if(X86 == Architecture) store = "STORE_CHAR\n";
|
||||
else if(ARMV7L == Architecture) emit_out("!0 R0 STORE8 R1 MEMORY\n");
|
||||
}
|
||||
|
||||
common_recursion(expression);
|
||||
|
@ -800,6 +884,7 @@ void collect_local()
|
|||
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("PUSHR R0 R15\t#");
|
||||
else if(X86 == Architecture) emit_out("PUSH_eax\t#");
|
||||
else if(ARMV7L == Architecture) emit_out("'0' R0 PUSH_ALWAYS\t#");
|
||||
emit_out(a->s);
|
||||
emit_out("\n");
|
||||
}
|
||||
|
@ -821,6 +906,7 @@ void process_if()
|
|||
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("JUMP.Z R0 @ELSE_");
|
||||
else if(X86 == Architecture) emit_out("TEST\nJUMP_EQ %ELSE_");
|
||||
else if(ARMV7L == Architecture) emit_out("PLACEHOLDER\t#process_if\n");
|
||||
|
||||
uniqueID_out(function->s, number_string);
|
||||
|
||||
|
@ -829,6 +915,7 @@ void process_if()
|
|||
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("JUMP @_END_IF_");
|
||||
else if(X86 == Architecture) emit_out("JUMP %_END_IF_");
|
||||
else if(ARMV7L == Architecture) emit_out("PLACEHOLDER\t#process_if\n");
|
||||
|
||||
uniqueID_out(function->s, number_string);
|
||||
emit_out(":ELSE_");
|
||||
|
@ -877,9 +964,11 @@ void process_for()
|
|||
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("JUMP.Z R0 @FOR_END_");
|
||||
else if(X86 == Architecture) emit_out("TEST\nJUMP_EQ %FOR_END_");
|
||||
else if(ARMV7L == Architecture) emit_out("PLACEHOLDER\t#process_if\n");
|
||||
uniqueID_out(function->s, number_string);
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("JUMP @FOR_THEN_");
|
||||
else if(X86 == Architecture) emit_out("JUMP %FOR_THEN_");
|
||||
else if(ARMV7L == Architecture) emit_out("PLACEHOLDER\t#process_if\n");
|
||||
uniqueID_out(function->s, number_string);
|
||||
emit_out(":FOR_ITER_");
|
||||
uniqueID_out(function->s, number_string);
|
||||
|
@ -889,6 +978,7 @@ void process_for()
|
|||
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("JUMP @FOR_");
|
||||
else if(X86 == Architecture) emit_out("JUMP %FOR_");
|
||||
else if(ARMV7L == Architecture) emit_out("PLACEHOLDER\t#process_if\n");
|
||||
uniqueID_out(function->s, number_string);
|
||||
emit_out(":FOR_THEN_");
|
||||
uniqueID_out(function->s, number_string);
|
||||
|
@ -898,6 +988,7 @@ void process_for()
|
|||
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("JUMP @FOR_ITER_");
|
||||
else if(X86 == Architecture) emit_out("JUMP %FOR_ITER_");
|
||||
else if(ARMV7L == Architecture) emit_out("PLACEHOLDER\t#process_if\n");
|
||||
uniqueID_out(function->s, number_string);
|
||||
emit_out(":FOR_END_");
|
||||
uniqueID_out(function->s, number_string);
|
||||
|
@ -953,6 +1044,7 @@ void process_do()
|
|||
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("JUMP.NZ R0 @DO_");
|
||||
else if(X86 == Architecture) emit_out("TEST\nJUMP_NE %DO_");
|
||||
else if(ARMV7L == Architecture) emit_out("PLACEHOLDER\t#process_if\n");
|
||||
uniqueID_out(function->s, number_string);
|
||||
emit_out(":DO_END_");
|
||||
uniqueID_out(function->s, number_string);
|
||||
|
@ -989,6 +1081,7 @@ void process_while()
|
|||
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("JUMP.Z R0 @END_WHILE_");
|
||||
else if(X86 == Architecture) emit_out("TEST\nJUMP_EQ %END_WHILE_");
|
||||
else if(ARMV7L == Architecture) emit_out("PLACEHOLDER\t#process_while\n");
|
||||
uniqueID_out(function->s, number_string);
|
||||
emit_out("# THEN_while_");
|
||||
uniqueID_out(function->s, number_string);
|
||||
|
@ -998,6 +1091,7 @@ void process_while()
|
|||
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("JUMP @WHILE_");
|
||||
else if(X86 == Architecture) emit_out("JUMP %WHILE_");
|
||||
else if(ARMV7L == Architecture) emit_out("PLACEHOLDER\t#process_while\n");
|
||||
uniqueID_out(function->s, number_string);
|
||||
emit_out(":END_WHILE_");
|
||||
uniqueID_out(function->s, number_string);
|
||||
|
@ -1021,10 +1115,12 @@ void return_result()
|
|||
{
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("POPR R1 R15\t# _return_result_locals\n");
|
||||
else if(X86 == Architecture) emit_out("POP_ebx\t# _return_result_locals\n");
|
||||
else if(ARMV7L == Architecture) emit_out("'0' R1 POP_ALWAYS\t# _return_result_locals\n");
|
||||
}
|
||||
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("RET R15\n");
|
||||
else if(X86 == Architecture) emit_out("RETURN\n");
|
||||
else if(ARMV7L == Architecture) emit_out("'0' R14 R15 MOVE_ALWAYS\n");
|
||||
}
|
||||
|
||||
void process_break()
|
||||
|
@ -1041,12 +1137,14 @@ void process_break()
|
|||
if(NULL == i) break;
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("POPR R1 R15\t# break_cleanup_locals\n");
|
||||
else if(X86 == Architecture) emit_out("POP_ebx\t# break_cleanup_locals\n");
|
||||
else if(ARMV7L == Architecture) emit_out("'0' R1 POP_ALWAYS\t# break_cleanup_locals\n");
|
||||
i = i->next;
|
||||
}
|
||||
global_token = global_token->next;
|
||||
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("JUMP @");
|
||||
else if(X86 == Architecture) emit_out("JUMP %");
|
||||
else if(ARMV7L == Architecture) emit_out("PLACEHOLDER\t#process_break\n");
|
||||
|
||||
emit_out(break_target_head);
|
||||
emit_out(break_target_func);
|
||||
|
@ -1069,13 +1167,16 @@ void recursive_statement()
|
|||
|
||||
/* Clean up any locals added */
|
||||
|
||||
if(((X86 == Architecture) && !match("RETURN\n", out->s)) || ((KNIGHT_POSIX == Architecture) && !match("RET R15\n", out->s)))
|
||||
if(((X86 == Architecture) && !match("RETURN\n", out->s)) ||
|
||||
((KNIGHT_POSIX == Architecture) && !match("RET R15\n", out->s)) ||
|
||||
(ARMV7L == Architecture))
|
||||
{
|
||||
struct token_list* i;
|
||||
for(i = function->locals; frame != i; i = i->next)
|
||||
{
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("POPR R1 R15\t# _recursive_statement_locals\n");
|
||||
else if(X86 == Architecture) emit_out( "POP_ebx\t# _recursive_statement_locals\n");
|
||||
else if(ARMV7L == Architecture) emit_out("'0' R1 POP_ALWAYS\t# _recursive_statement_locals\n");
|
||||
}
|
||||
}
|
||||
function->locals = frame;
|
||||
|
@ -1142,6 +1243,7 @@ void statement()
|
|||
global_token = global_token->next;
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("JUMP @");
|
||||
else if(X86 == Architecture) emit_out("JUMP %");
|
||||
else if(ARMV7L == Architecture) emit_out("PLACEHOLDER\t#\n");
|
||||
emit_out(global_token->s);
|
||||
emit_out("\n");
|
||||
global_token = global_token->next;
|
||||
|
@ -1230,6 +1332,7 @@ void declare_function()
|
|||
/* Prevent duplicate RETURNS */
|
||||
if((KNIGHT_POSIX == Architecture) && !match("RET R15\n", out->s)) emit_out("RET R15\n");
|
||||
else if((X86 == Architecture) && !match("RETURN\n", out->s)) emit_out("RETURN\n");
|
||||
else if(ARMV7L == Architecture) emit_out("'0' R14 R15 MOVE_ALWAYS\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
6
makefile
6
makefile
|
@ -20,7 +20,7 @@ VPATH = bin:test:test/results
|
|||
all: M2-Planet
|
||||
|
||||
M2-Planet: bin results
|
||||
./test/test100/hello-x86.sh
|
||||
./test/test100/hello.sh
|
||||
|
||||
# Clean up after ourselves
|
||||
.PHONY: clean
|
||||
|
@ -89,6 +89,7 @@ test: test00-knight-posix-binary \
|
|||
test24-knight-posix-binary \
|
||||
test99-knight-posix-binary \
|
||||
test100-knight-posix-binary \
|
||||
test00-armv7l-binary \
|
||||
test00-x86-binary \
|
||||
test01-x86-binary \
|
||||
test02-x86-binary \
|
||||
|
@ -199,6 +200,9 @@ test99-knight-posix-binary: M2-Planet | results
|
|||
test100-knight-posix-binary: M2-Planet | results
|
||||
test/test100/hello-knight-posix.sh
|
||||
|
||||
test00-armv7l-binary: M2-Planet | results
|
||||
test/test00/hello-armv7l.sh
|
||||
|
||||
test00-x86-binary: M2-Planet | results
|
||||
test/test00/hello-x86.sh
|
||||
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
### Copyright (C) 2016 Jeremiah Orians
|
||||
### Copyright (C) 2017 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
### This file is part of stage0.
|
||||
###
|
||||
### stage0 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.
|
||||
###
|
||||
### 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
|
||||
### !<label> 1 byte relative
|
||||
### $<label> 2 byte address
|
||||
### @<label> 2 byte relative
|
||||
### &<label> 4 byte address
|
||||
### %<label> 4 byte relative
|
||||
|
||||
### elf32.hex2: 32 bit elf header in hex2
|
||||
### if you wish to use this header, you need to add :ELF_end to the end of your
|
||||
### M1 or hex2 files.
|
||||
|
||||
## ELF Header
|
||||
: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
|
||||
28 00 # e_machine Indicating 32bit ARM
|
||||
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 02 00 05 # 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
|
||||
|
||||
## Program Header
|
||||
: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
|
||||
|
||||
05 00 00 00 # p_flags
|
||||
00 00 01 00 # alignment
|
||||
|
||||
:ELF_text
|
|
@ -0,0 +1,54 @@
|
|||
## Copyright (C) 2016 Jeremiah Orians
|
||||
## This file is part of stage0.
|
||||
##
|
||||
## stage0 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.
|
||||
##
|
||||
## 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/>.
|
||||
|
||||
#Registers
|
||||
DEFINE R0 0
|
||||
DEFINE R1 1
|
||||
DEFINE R2 2
|
||||
DEFINE R3 3
|
||||
DEFINE R4 4
|
||||
DEFINE R5 5
|
||||
DEFINE R6 6
|
||||
DEFINE R7 7
|
||||
DEFINE R8 8
|
||||
DEFINE R9 9
|
||||
DEFINE R10 A
|
||||
DEFINE R11 B
|
||||
DEFINE R12 C
|
||||
DEFINE R13 D
|
||||
DEFINE SP D
|
||||
DEFINE R14 E
|
||||
DEFINE LR E
|
||||
DEFINE R15 F
|
||||
DEFINE PC F
|
||||
|
||||
# LOAD/STORE
|
||||
DEFINE MEMORY E5
|
||||
DEFINE STORE32 08
|
||||
DEFINE STORE8 0C
|
||||
DEFINE LOAD32 09
|
||||
DEFINE LOAD8 0D
|
||||
DEFINE LOADI8_ALWAYS 0A0E3
|
||||
|
||||
# JUMP/BRANCH
|
||||
DEFINE JUMP EA
|
||||
DEFINE BL_ALWAYS EB
|
||||
|
||||
# Data movement
|
||||
DEFINE MOVE_ALWAYS 0A0E1
|
||||
|
||||
# SYSCALL
|
||||
DEFINE SYSCALL_ALWAYS 000000EF
|
|
@ -0,0 +1,20 @@
|
|||
## 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/>.
|
||||
|
||||
:_start
|
||||
^~FUNCTION_main BL_ALWAYS
|
||||
!1 R7 LOADI8_ALWAYS
|
||||
SYSCALL_ALWAYS
|
|
@ -1,3 +1,4 @@
|
|||
9bb7fc192780009edb1f890eaa2ffb614f9461e7826bfb2beadc0f13ffe4b495 test/results/test00-armv7l-binary
|
||||
64879eebceb475f21e54cb1f2e872996ca80e8c1fbb8b5895fb5fb6bac0c4384 test/results/test00-knight-posix-binary
|
||||
c52562bd0aabb86ce8ca177f22f8d0455769b444df2d4d62894faab63b7151d8 test/results/test00-x86-binary
|
||||
486ee05ccea796a9cfa9bfb23189b8e014b7ce8d14fea03b27d679d410fe17dd test/results/test01-knight-posix-binary
|
||||
|
@ -20,8 +21,8 @@ f1c01feb865c4d552033186d9ce50dd39468a7e8aebf762886c13ad3e03b5011 test/results/t
|
|||
3b39e72f3de90ed690adfaf6145af46157cef2ec5e72867ac577fa27a0229894 test/results/test09-x86-binary
|
||||
c1b5a2a3cd46c5e95e5540e871c2a916e028684ca80f51c001ef489342e27625 test/results/test10-knight-posix-binary
|
||||
020e86020819cc4963e6185b22e534fcf8306b6cb116f12643f254a24688ff0a test/results/test10-x86-binary
|
||||
36cff3352e2261db8d60ae939080c58407f86fea53e981e3dca786f129d25c27 test/results/test100-knight-posix-binary
|
||||
81ac81971a4ad4bcc3c6e469c03472e5dca9d4cef8b110d76ca13cf7576a6ec1 test/results/test100-x86-binary
|
||||
99b751c78142ff919f0b12c28313e612ff4e3b48e9e3ca5aa7add4ca5efa35d2 test/results/test100-knight-posix-binary
|
||||
f244c5339b3a8f53484a1dc27ef582afa00b6df923b8c42ad843c3812d86441a test/results/test100-x86-binary
|
||||
63fd5fbf389d1b19031026df193ec55e98d923b8568007125b80bc246c094496 test/results/test11-knight-posix-binary
|
||||
3fd11bad4a426ce1ff8fd9c6d7d2b943effae9f3f5740b7376e426e9b0555851 test/results/test11-x86-binary
|
||||
313536f9209d29d4c3b40f6ada898f81c1fb3b650ca1a84754f90b1db3b9e001 test/results/test12-knight-posix-binary
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
#! /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/test00/return.c \
|
||||
-o test/test00/return.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/test00/return.M1 \
|
||||
--LittleEndian \
|
||||
--architecture armv7l \
|
||||
-o test/test00/return.hex2 || exit 2
|
||||
|
||||
# Resolve all linkages
|
||||
hex2 -f test/common_armv7l/ELF-armv7l.hex2 -f test/test00/return.hex2 --LittleEndian --architecture armv7l --BaseAddress 0x10000 -o test/results/test00-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
|
||||
./test/results/test00-armv7l-binary
|
||||
[ 42 = $? ] || exit 3
|
||||
fi
|
||||
exit 0
|
|
@ -17,8 +17,6 @@
|
|||
|
||||
set -ex
|
||||
# Build the test
|
||||
if [ -f bin/M2-Planet ]
|
||||
then
|
||||
./bin/M2-Planet --architecture knight-posix \
|
||||
-f test/common_knight/functions/file.c \
|
||||
-f test/common_knight/functions/malloc.c \
|
||||
|
@ -38,67 +36,6 @@ then
|
|||
-f cc.c \
|
||||
--debug \
|
||||
-o test/test100/cc.M1 || exit 1
|
||||
elif [ -f bin/M2-Planet-seed ]
|
||||
then
|
||||
[ ! -f test/results ] && mkdir -p test/results
|
||||
./bin/M2-Planet-seed -f test/common_knight/functions/file.c \
|
||||
-f test/common_knight/functions/malloc.c \
|
||||
-f functions/calloc.c \
|
||||
-f test/common_knight/functions/exit.c \
|
||||
-f functions/match.c \
|
||||
-f functions/in_set.c \
|
||||
-f functions/numerate_number.c \
|
||||
-f functions/file_print.c \
|
||||
-f functions/number_pack.c \
|
||||
-f functions/string.c \
|
||||
-f cc.h \
|
||||
-f cc_reader.c \
|
||||
-f cc_strings.c \
|
||||
-f cc_types.c \
|
||||
-f cc_core.c \
|
||||
-f cc.c \
|
||||
--debug \
|
||||
-o test/test100/cc.M1 || exit 1
|
||||
else
|
||||
[ -z "${CC+x}" ] && export CC=gcc
|
||||
[ -z "${CFLAGS+x}" ] && export CFLAGS=" -D_GNU_SOURCE -O0 -std=c99 -ggdb"
|
||||
|
||||
${CC} ${CFLAGS} \
|
||||
functions/match.c \
|
||||
functions/in_set.c \
|
||||
functions/numerate_number.c \
|
||||
functions/file_print.c \
|
||||
functions/number_pack.c \
|
||||
functions/string.c \
|
||||
cc_reader.c \
|
||||
cc_strings.c \
|
||||
cc_types.c \
|
||||
cc_core.c \
|
||||
cc.c \
|
||||
cc.h \
|
||||
gcc_req.h \
|
||||
-o bin/M2-Planet-gcc
|
||||
|
||||
./bin/M2-Planet-gcc --architecture knight-posix \
|
||||
-f test/common_knight/functions/file.c \
|
||||
-f test/common_knight/functions/malloc.c \
|
||||
-f functions/calloc.c \
|
||||
-f test/common_knight/functions/exit.c \
|
||||
-f functions/match.c \
|
||||
-f functions/in_set.c \
|
||||
-f functions/numerate_number.c \
|
||||
-f functions/file_print.c \
|
||||
-f functions/number_pack.c \
|
||||
-f functions/string.c \
|
||||
-f cc.h \
|
||||
-f cc_reader.c \
|
||||
-f cc_strings.c \
|
||||
-f cc_types.c \
|
||||
-f cc_core.c \
|
||||
-f cc.c \
|
||||
--debug \
|
||||
-o test/test100/cc.M1 || exit 1
|
||||
fi
|
||||
|
||||
# Macro assemble with libc written in M1-Macro
|
||||
M1 -f test/common_knight/knight_defs.M1 \
|
||||
|
@ -106,7 +43,7 @@ M1 -f test/common_knight/knight_defs.M1 \
|
|||
-f test/test100/cc.M1 \
|
||||
--BigEndian \
|
||||
--architecture knight-posix \
|
||||
-o test/test100/cc.hex2 || exit 3
|
||||
-o test/test100/cc.hex2 || exit 2
|
||||
|
||||
# Resolve all linkages
|
||||
hex2 -f test/common_knight/ELF-knight.hex2 \
|
||||
|
@ -114,7 +51,7 @@ hex2 -f test/common_knight/ELF-knight.hex2 \
|
|||
--BigEndian \
|
||||
--architecture knight-posix \
|
||||
--BaseAddress 0x00 \
|
||||
-o test/results/test100-knight-posix-binary --exec_enable || exit 4
|
||||
-o test/results/test100-knight-posix-binary --exec_enable || exit 3
|
||||
|
||||
# Ensure binary works if host machine supports test
|
||||
if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "knight*" ]
|
||||
|
@ -137,15 +74,10 @@ then
|
|||
-f cc_types.c \
|
||||
-f cc_core.c \
|
||||
-f cc.c \
|
||||
-o test/test100/proof || exit 5
|
||||
-o test/test100/proof || exit 4
|
||||
|
||||
out=$(sha256sum -c test/test100/proof.answer)
|
||||
[ "$out" = "test/test100/proof: OK" ] || exit 6
|
||||
[ "$out" = "test/test100/proof: OK" ] || exit 5
|
||||
[ ! -e bin/M2-Planet ] && mv test/results/test100-knight-posix-binary bin/M2-Planet
|
||||
else
|
||||
[ -e bin/M2-Planet-gcc ] && cp bin/M2-Planet-gcc bin/M2-Planet
|
||||
|
||||
# Seeds only exist if you can build natively
|
||||
[ -e bin/M2-Planet-seed ] && cp test/results/test100-knight-posix-binary bin/M2-Planet
|
||||
fi
|
||||
exit 0
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
|
||||
set -ex
|
||||
# Build the test
|
||||
if [ -f bin/M2-Planet ]
|
||||
then
|
||||
./bin/M2-Planet --architecture x86 \
|
||||
-f test/common_x86/functions/file.c \
|
||||
-f test/common_x86/functions/malloc.c \
|
||||
|
@ -38,67 +36,6 @@ then
|
|||
-f cc.c \
|
||||
--debug \
|
||||
-o test/test100/cc.M1 || exit 1
|
||||
elif [ -f bin/M2-Planet-seed ]
|
||||
then
|
||||
[ ! -f test/results ] && mkdir -p test/results
|
||||
./bin/M2-Planet-seed -f test/common_x86/functions/file.c \
|
||||
-f test/common_x86/functions/malloc.c \
|
||||
-f functions/calloc.c \
|
||||
-f test/common_x86/functions/exit.c \
|
||||
-f functions/match.c \
|
||||
-f functions/in_set.c \
|
||||
-f functions/numerate_number.c \
|
||||
-f functions/file_print.c \
|
||||
-f functions/number_pack.c \
|
||||
-f functions/string.c \
|
||||
-f cc.h \
|
||||
-f cc_reader.c \
|
||||
-f cc_strings.c \
|
||||
-f cc_types.c \
|
||||
-f cc_core.c \
|
||||
-f cc.c \
|
||||
--debug \
|
||||
-o test/test100/cc.M1 || exit 1
|
||||
else
|
||||
[ -z "${CC+x}" ] && export CC=gcc
|
||||
[ -z "${CFLAGS+x}" ] && export CFLAGS=" -D_GNU_SOURCE -O0 -std=c99 -ggdb"
|
||||
|
||||
${CC} ${CFLAGS} \
|
||||
functions/match.c \
|
||||
functions/in_set.c \
|
||||
functions/numerate_number.c \
|
||||
functions/file_print.c \
|
||||
functions/number_pack.c \
|
||||
functions/string.c \
|
||||
cc_reader.c \
|
||||
cc_strings.c \
|
||||
cc_types.c \
|
||||
cc_core.c \
|
||||
cc.c \
|
||||
cc.h \
|
||||
gcc_req.h \
|
||||
-o bin/M2-Planet-gcc
|
||||
|
||||
./bin/M2-Planet-gcc --architecture x86 \
|
||||
-f test/common_x86/functions/file.c \
|
||||
-f test/common_x86/functions/malloc.c \
|
||||
-f functions/calloc.c \
|
||||
-f test/common_x86/functions/exit.c \
|
||||
-f functions/match.c \
|
||||
-f functions/in_set.c \
|
||||
-f functions/numerate_number.c \
|
||||
-f functions/file_print.c \
|
||||
-f functions/number_pack.c \
|
||||
-f functions/string.c \
|
||||
-f cc.h \
|
||||
-f cc_reader.c \
|
||||
-f cc_strings.c \
|
||||
-f cc_types.c \
|
||||
-f cc_core.c \
|
||||
-f cc.c \
|
||||
--debug \
|
||||
-o test/test100/cc.M1 || exit 1
|
||||
fi
|
||||
|
||||
# Build debug footer
|
||||
blood-elf -f test/test100/cc.M1 \
|
||||
|
@ -147,10 +84,5 @@ then
|
|||
out=$(sha256sum -c test/test100/proof.answer)
|
||||
[ "$out" = "test/test100/proof: OK" ] || exit 6
|
||||
[ ! -e bin/M2-Planet ] && mv test/results/test100-x86-binary bin/M2-Planet
|
||||
else
|
||||
[ -e bin/M2-Planet-gcc ] && cp bin/M2-Planet-gcc bin/M2-Planet
|
||||
|
||||
# Seeds only exist if you can build natively
|
||||
[ -e bin/M2-Planet-seed ] && cp test/results/test100-x86-binary bin/M2-Planet
|
||||
fi
|
||||
exit 0
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
#! /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 using seed if possible
|
||||
if [ -f bin/M2-Planet-seed ]
|
||||
then
|
||||
[ ! -f test/results ] && mkdir -p test/results
|
||||
./bin/M2-Planet-seed -f test/common_x86/functions/file.c \
|
||||
-f test/common_x86/functions/malloc.c \
|
||||
-f functions/calloc.c \
|
||||
-f test/common_x86/functions/exit.c \
|
||||
-f functions/match.c \
|
||||
-f functions/in_set.c \
|
||||
-f functions/numerate_number.c \
|
||||
-f functions/file_print.c \
|
||||
-f functions/number_pack.c \
|
||||
-f functions/string.c \
|
||||
-f cc.h \
|
||||
-f cc_reader.c \
|
||||
-f cc_strings.c \
|
||||
-f cc_types.c \
|
||||
-f cc_core.c \
|
||||
-f cc.c \
|
||||
--debug \
|
||||
-o test/test100/cc.M1 || exit 1
|
||||
|
||||
# Build debug footer
|
||||
blood-elf -f test/test100/cc.M1 \
|
||||
-o test/test100/cc-footer.M1 || exit 2
|
||||
|
||||
# Macro assemble with libc written in M1-Macro
|
||||
M1 -f test/common_x86/x86_defs.M1 \
|
||||
-f test/common_x86/libc-core.M1 \
|
||||
-f test/test100/cc.M1 \
|
||||
-f test/test100/cc-footer.M1 \
|
||||
--LittleEndian \
|
||||
--architecture x86 \
|
||||
-o test/test100/cc.hex2 || exit 3
|
||||
|
||||
# Resolve all linkages
|
||||
hex2 -f test/common_x86/ELF-i386-debug.hex2 \
|
||||
-f test/test100/cc.hex2 \
|
||||
--LittleEndian \
|
||||
--architecture x86 \
|
||||
--BaseAddress 0x8048000 \
|
||||
-o test/results/test100-x86-binary --exec_enable || exit 4
|
||||
|
||||
else
|
||||
[ -z "${CC+x}" ] && export CC=gcc
|
||||
[ -z "${CFLAGS+x}" ] && export CFLAGS=" -D_GNU_SOURCE -O0 -std=c99 -ggdb"
|
||||
|
||||
${CC} ${CFLAGS} \
|
||||
functions/match.c \
|
||||
functions/in_set.c \
|
||||
functions/numerate_number.c \
|
||||
functions/file_print.c \
|
||||
functions/number_pack.c \
|
||||
functions/string.c \
|
||||
cc_reader.c \
|
||||
cc_strings.c \
|
||||
cc_types.c \
|
||||
cc_core.c \
|
||||
cc.c \
|
||||
cc.h \
|
||||
gcc_req.h \
|
||||
-o bin/M2-Planet || exit 5
|
||||
fi
|
||||
|
||||
exit 0
|
|
@ -1 +1 @@
|
|||
6f141cc0c20068f7d88215201e3c8ae77eb547ecf84ee62f65586a55eac3b9f5 test/test100/proof
|
||||
2ebd53349f203e0dd41ad294c3cd725693b3abd4500ac30e793ad02ddea57eaf test/test100/proof
|
||||
|
|
Loading…
Reference in New Issue