1/24 working tests for AMD64 Port
This commit is contained in:
parent
0889a1d340
commit
420f8b62b9
|
@ -16,6 +16,8 @@
|
|||
|
||||
* Current
|
||||
** Added
|
||||
Added port to Knight-Native
|
||||
Ported 1/24 working tests for AMD64
|
||||
|
||||
** Changed
|
||||
|
||||
|
|
16
cc.c
16
cc.c
|
@ -35,7 +35,7 @@ int main(int argc, char** argv)
|
|||
int DEBUG = FALSE;
|
||||
FILE* in = stdin;
|
||||
FILE* destination_file = stdout;
|
||||
Architecture = 0; /* Assume Knight-native */
|
||||
Architecture = KNIGHT_NATIVE; /* Assume Knight-native */
|
||||
char* arch;
|
||||
|
||||
int i = 1;
|
||||
|
@ -84,6 +84,7 @@ int main(int argc, char** argv)
|
|||
file_print("Unknown architecture: ", stderr);
|
||||
file_print(arch, stderr);
|
||||
file_print(" know values are: knight-native, knight-posix, x86, amd64 and armv7l", stderr);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
i = i + 2;
|
||||
}
|
||||
|
@ -109,13 +110,6 @@ 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\x04"))
|
||||
{
|
||||
file_print("ALL IS FIRE\n\n", stderr);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Deal with special case of wanting to read from standard input */
|
||||
if(stdin == in)
|
||||
{
|
||||
|
@ -136,11 +130,13 @@ int main(int argc, char** argv)
|
|||
/* Output the program we have compiled */
|
||||
file_print("\n# Core program\n", destination_file);
|
||||
recursive_output(output_list, destination_file);
|
||||
if(DEBUG) file_print("\n:ELF_data\n", destination_file);
|
||||
if(KNIGHT_NATIVE == Architecture) file_print("\n", destination_file);
|
||||
else if(DEBUG) file_print("\n:ELF_data\n", destination_file);
|
||||
file_print("\n# Program global variables\n", destination_file);
|
||||
recursive_output(globals_list, destination_file);
|
||||
file_print("\n# Program strings\n", destination_file);
|
||||
recursive_output(strings_list, destination_file);
|
||||
if(!DEBUG) file_print("\n:ELF_end\n", destination_file);
|
||||
if(KNIGHT_NATIVE == Architecture) file_print("\n:STACK\n", destination_file);
|
||||
else if(!DEBUG) file_print("\n:ELF_end\n", destination_file);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
212
cc_core.c
212
cc_core.c
|
@ -114,7 +114,7 @@ void function_call(char* s, int bool)
|
|||
require_match("ERROR in process_expression_list\nNo ( was found\n", "(");
|
||||
int passed = 0;
|
||||
|
||||
if(KNIGHT_POSIX == Architecture)
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture))
|
||||
{
|
||||
emit_out("PUSHR R13 R15\t# Prevent overwriting in recursion\n");
|
||||
emit_out("PUSHR R14 R15\t# Protect the old base pointer\n");
|
||||
|
@ -126,6 +126,12 @@ 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(AMD64 == Architecture)
|
||||
{
|
||||
emit_out("PUSH_RDI\t# Prevent overwriting in recursion\n");
|
||||
emit_out("PUSH_RBP\t# Protect the old base pointer\n");
|
||||
emit_out("COPY_RSP_to_RDI\t# Copy new base pointer\n");
|
||||
}
|
||||
else if(ARMV7L == Architecture)
|
||||
{
|
||||
emit_out("{R11} PUSH_ALWAYS\t# Prevent overwriting in recursion\n");
|
||||
|
@ -136,8 +142,9 @@ void function_call(char* s, int bool)
|
|||
if(global_token->s[0] != ')')
|
||||
{
|
||||
expression();
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("PUSHR R0 R15\t#_process_expression1\n");
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture)) emit_out("PUSHR R0 R15\t#_process_expression1\n");
|
||||
else if(X86 == Architecture) emit_out("PUSH_eax\t#_process_expression1\n");
|
||||
else if(AMD64 == Architecture) emit_out("PUSH_RAX\t#_process_expression1\n");
|
||||
else if(ARMV7L == Architecture) emit_out("{R0} PUSH_ALWAYS\t#_process_expression1\n");
|
||||
passed = 1;
|
||||
|
||||
|
@ -145,8 +152,9 @@ void function_call(char* s, int bool)
|
|||
{
|
||||
global_token = global_token->next;
|
||||
expression();
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("PUSHR R0 R15\t#_process_expression2\n");
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture)) emit_out("PUSHR R0 R15\t#_process_expression2\n");
|
||||
else if(X86 == Architecture) emit_out("PUSH_eax\t#_process_expression2\n");
|
||||
else if(AMD64 == Architecture) emit_out("PUSH_RAX\t#_process_expression2\n");
|
||||
else if(ARMV7L == Architecture) emit_out("{R0} PUSH_ALWAYS\t#_process_expression2\n");
|
||||
passed = passed + 1;
|
||||
}
|
||||
|
@ -156,7 +164,7 @@ void function_call(char* s, int bool)
|
|||
|
||||
if(TRUE == bool)
|
||||
{
|
||||
if(KNIGHT_POSIX == Architecture)
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture))
|
||||
{
|
||||
emit_out("LOAD R0 R14 ");
|
||||
emit_out(s);
|
||||
|
@ -171,6 +179,14 @@ void function_call(char* s, int bool)
|
|||
emit_out("COPY_edi_to_ebp\n");
|
||||
emit_out("CALL_eax\n");
|
||||
}
|
||||
else if(AMD64 == Architecture)
|
||||
{
|
||||
emit_out("LOAD_BASE_ADDRESS_rax %");
|
||||
emit_out(s);
|
||||
emit_out("\nLOAD_INTEGER\n");
|
||||
emit_out("COPY_rdi_to_rbp\n");
|
||||
emit_out("CALL_rax\n");
|
||||
}
|
||||
else if(ARMV7L == Architecture)
|
||||
{
|
||||
emit_out("!");
|
||||
|
@ -185,7 +201,14 @@ void function_call(char* s, int bool)
|
|||
}
|
||||
else
|
||||
{
|
||||
if(KNIGHT_POSIX == Architecture)
|
||||
if(KNIGHT_NATIVE == Architecture)
|
||||
{
|
||||
emit_out("MOVE R14 R13\n");
|
||||
emit_out("CALLI R15 @FUNCTION_");
|
||||
emit_out(s);
|
||||
emit_out("\n");
|
||||
}
|
||||
else if(KNIGHT_POSIX == Architecture)
|
||||
{
|
||||
emit_out("MOVE R14 R13\n");
|
||||
emit_out("LOADR R0 4\nJUMP 4\n&FUNCTION_");
|
||||
|
@ -199,6 +222,13 @@ void function_call(char* s, int bool)
|
|||
emit_out(s);
|
||||
emit_out("\n");
|
||||
}
|
||||
else if(AMD64 == Architecture)
|
||||
{
|
||||
emit_out("COPY_rdi_to_rbp\n");
|
||||
emit_out("CALL_IMMEDIATE %FUNCTION_");
|
||||
emit_out(s);
|
||||
emit_out("\n");
|
||||
}
|
||||
else if(ARMV7L == Architecture)
|
||||
{
|
||||
emit_out("{LR} PUSH_ALWAYS\t# Protect the old link register\n");
|
||||
|
@ -212,12 +242,13 @@ void function_call(char* s, int bool)
|
|||
|
||||
for(; passed > 0; passed = passed - 1)
|
||||
{
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("POPR R1 R15\t# _process_expression_locals\n");
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == 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(AMD64 == Architecture) emit_out("POP_RBX\t# _process_expression_locals\n");
|
||||
else if(ARMV7L == Architecture) emit_out("{R1} POP_ALWAYS\t# _process_expression_locals\n");
|
||||
}
|
||||
|
||||
if(KNIGHT_POSIX == Architecture)
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture))
|
||||
{
|
||||
emit_out("POPR R14 R15\t# Restore old base pointer\n");
|
||||
emit_out("POPR R13 R15\t# Prevent overwrite\n");
|
||||
|
@ -227,6 +258,11 @@ 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(AMD64 == Architecture)
|
||||
{
|
||||
emit_out("POP_RBP\t# Restore old base pointer\n");
|
||||
emit_out("POP_RDI\t# Prevent overwrite\n");
|
||||
}
|
||||
else if(ARMV7L == Architecture)
|
||||
{
|
||||
emit_out("{BP} POP_ALWAYS\t# Restore old base pointer\n");
|
||||
|
@ -236,8 +272,9 @@ void function_call(char* s, int bool)
|
|||
|
||||
void constant_load(struct token_list* a)
|
||||
{
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("LOADI R0 ");
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture)) emit_out("LOADI R0 ");
|
||||
else if(X86 == Architecture) emit_out("LOAD_IMMEDIATE_eax %");
|
||||
else if(AMD64 == Architecture) emit_out("LOAD_IMMEDIATE_rax %");
|
||||
else if(ARMV7L == Architecture) emit_out("!0 R0 LOAD32 R15 MEMORY\n~0 JUMP_ALWAYS\n%");
|
||||
emit_out(a->arguments->s);
|
||||
emit_out("\n");
|
||||
|
@ -252,8 +289,9 @@ void variable_load(struct token_list* a)
|
|||
}
|
||||
current_target = a->type;
|
||||
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("ADDI R0 R14 ");
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture)) emit_out("ADDI R0 R14 ");
|
||||
else if(X86 == Architecture) emit_out("LOAD_BASE_ADDRESS_eax %");
|
||||
else if(AMD64 == Architecture) emit_out("LOAD_BASE_ADDRESS_rax %");
|
||||
else if(ARMV7L == Architecture) emit_out("!");
|
||||
|
||||
emit_out(numerate_number(a->depth));
|
||||
|
@ -263,8 +301,9 @@ void variable_load(struct token_list* a)
|
|||
if(TRUE == Address_of) return;
|
||||
if(match("=", global_token->s)) return;
|
||||
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("LOAD R0 R0 0\n");
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture)) emit_out("LOAD R0 R0 0\n");
|
||||
else if(X86 == Architecture) emit_out("LOAD_INTEGER\n");
|
||||
else if(AMD64 == Architecture) emit_out("LOAD_INTEGER\n");
|
||||
else if(ARMV7L == Architecture) emit_out("!0 R0 LOAD32 R0 MEMORY\n");
|
||||
}
|
||||
|
||||
|
@ -276,8 +315,10 @@ void function_load(struct token_list* a)
|
|||
return;
|
||||
}
|
||||
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("LOADR R0 4\nJUMP 4\n&FUNCTION_");
|
||||
if (KNIGHT_NATIVE == Architecture) emit_out("LOADUI R0 $FUNCTION_");
|
||||
else 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(AMD64 == Architecture) emit_out("LOAD_IMMEDIATE_rax &FUNCTION_");
|
||||
else if(ARMV7L == Architecture) emit_out("!0 R0 LOAD32 R15 MEMORY\n~0 JUMP_ALWAYS\n&FUNCTION_");
|
||||
emit_out(a->s);
|
||||
emit_out("\n");
|
||||
|
@ -286,15 +327,18 @@ void function_load(struct token_list* a)
|
|||
void global_load(struct token_list* a)
|
||||
{
|
||||
current_target = a->type;
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("LOADR R0 4\nJUMP 4\n&GLOBAL_");
|
||||
if(KNIGHT_NATIVE == Architecture) emit_out("LOADUI R0 $GLOBAL_");
|
||||
else 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(AMD64 == Architecture) emit_out("LOAD_IMMEDIATE_rax &GLOBAL_");
|
||||
else if(ARMV7L == Architecture) emit_out("!0 R0 LOAD32 R15 MEMORY\n~0 JUMP_ALWAYS\n&GLOBAL_");
|
||||
emit_out(a->s);
|
||||
emit_out("\n");
|
||||
if(!match("=", global_token->s))
|
||||
{
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("LOAD R0 R0 0\n");
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture)) emit_out("LOAD R0 R0 0\n");
|
||||
else if(X86 == Architecture) emit_out("LOAD_INTEGER\n");
|
||||
else if(AMD64 == Architecture) emit_out("LOAD_INTEGER\n");
|
||||
else if(ARMV7L == Architecture) emit_out("!0 R0 LOAD32 R0 MEMORY\n");
|
||||
}
|
||||
}
|
||||
|
@ -322,8 +366,10 @@ void primary_expr_string()
|
|||
{
|
||||
char* number_string = numerate_number(current_count);
|
||||
current_count = current_count + 1;
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("LOADR R0 4\nJUMP 4\n&STRING_");
|
||||
if (KNIGHT_NATIVE == Architecture) emit_out("LOADUI R0 $STRING_");
|
||||
else 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(AMD64 == Architecture) emit_out("LOAD_IMMEDIATE_rax &STRING_");
|
||||
else if(ARMV7L == Architecture) emit_out("!0 R0 LOAD32 R15 MEMORY\n~0 JUMP_ALWAYS\n&STRING_");
|
||||
uniqueID_out(function->s, number_string);
|
||||
|
||||
|
@ -338,8 +384,9 @@ void primary_expr_string()
|
|||
|
||||
void primary_expr_char()
|
||||
{
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("LOADI R0 ");
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture)) emit_out("LOADI R0 ");
|
||||
else if(X86 == Architecture) emit_out("LOAD_IMMEDIATE_eax %");
|
||||
else if(AMD64 == Architecture) emit_out("LOAD_IMMEDIATE_rax %");
|
||||
else if(ARMV7L == Architecture) emit_out("!");
|
||||
emit_out(numerate_number(escape_lookup(global_token->s + 1)));
|
||||
if(ARMV7L == Architecture) emit_out(" R0 LOADI8_ALWAYS");
|
||||
|
@ -349,34 +396,37 @@ void primary_expr_char()
|
|||
|
||||
void primary_expr_number()
|
||||
{
|
||||
if(KNIGHT_POSIX == Architecture)
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture))
|
||||
{
|
||||
int size = numerate_string(global_token->s);
|
||||
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");
|
||||
emit_out("'");
|
||||
}
|
||||
}
|
||||
else if(X86 == Architecture)
|
||||
{
|
||||
emit_out("LOAD_IMMEDIATE_eax %");
|
||||
emit_out(global_token->s);
|
||||
emit_out("\n");
|
||||
}
|
||||
else if(AMD64 == Architecture)
|
||||
{
|
||||
emit_out("LOAD_IMMEDIATE_rax %");
|
||||
emit_out(global_token->s);
|
||||
}
|
||||
else if(ARMV7L == Architecture)
|
||||
{
|
||||
emit_out("!0 R0 LOAD32 R15 MEMORY\n~0 JUMP_ALWAYS\n%");
|
||||
emit_out(global_token->s);
|
||||
emit_out("\n");
|
||||
}
|
||||
emit_out("\n");
|
||||
global_token = global_token->next;
|
||||
}
|
||||
|
||||
|
@ -453,15 +503,17 @@ void common_recursion(FUNCTION f)
|
|||
last_type = current_target;
|
||||
global_token = global_token->next;
|
||||
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("PUSHR R0 R15\t#_common_recursion\n");
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture)) emit_out("PUSHR R0 R15\t#_common_recursion\n");
|
||||
else if(X86 == Architecture) emit_out("PUSH_eax\t#_common_recursion\n");
|
||||
else if(AMD64 == Architecture) emit_out("PUSH_RAX\t#_common_recursion\n");
|
||||
else if(ARMV7L == Architecture) emit_out("{R0} PUSH_ALWAYS\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");
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture)) emit_out("POPR R1 R15\t# _common_recursion\n");
|
||||
else if(X86 == Architecture) emit_out("POP_ebx\t# _common_recursion\n");
|
||||
else if(AMD64 == Architecture) emit_out("POP_RBX\t# _common_recursion\n");
|
||||
else if(ARMV7L == Architecture) emit_out("{R1} POP_ALWAYS\t# _common_recursion\n");
|
||||
}
|
||||
|
||||
|
@ -513,7 +565,7 @@ void postfix_expr_arrow()
|
|||
if(0 != i->offset)
|
||||
{
|
||||
emit_out("# -> offset calculation\n");
|
||||
if(KNIGHT_POSIX == Architecture)
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture))
|
||||
{
|
||||
emit_out("ADDUI R0 R0 ");
|
||||
emit_out(numerate_number(i->offset));
|
||||
|
@ -525,6 +577,12 @@ void postfix_expr_arrow()
|
|||
emit_out(numerate_number(i->offset));
|
||||
emit_out("\nADD_ebx_to_eax\n");
|
||||
}
|
||||
else if(AMD64 == Architecture)
|
||||
{
|
||||
emit_out("LOAD_IMMEDIATE_rbx %");
|
||||
emit_out(numerate_number(i->offset));
|
||||
emit_out("\nADD_rbx_to_rax\n");
|
||||
}
|
||||
else if(ARMV7L == Architecture)
|
||||
{
|
||||
emit_out("!0 R1 LOAD32 R15 MEMORY\n~0 JUMP_ALWAYS\n%");
|
||||
|
@ -535,8 +593,9 @@ void postfix_expr_arrow()
|
|||
|
||||
if((!match("=", global_token->s) && (4 >= i->size)))
|
||||
{
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("LOAD R0 R0 0\n");
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture)) emit_out("LOAD R0 R0 0\n");
|
||||
else if(X86 == Architecture) emit_out("LOAD_INTEGER\n");
|
||||
else if(AMD64 == Architecture) emit_out("LOAD_INTEGER\n");
|
||||
else if(ARMV7L == Architecture) emit_out("!0 R0 LOAD32 R0 MEMORY\n");
|
||||
}
|
||||
}
|
||||
|
@ -547,21 +606,24 @@ void postfix_expr_array()
|
|||
common_recursion(expression);
|
||||
current_target = array;
|
||||
char* assign;
|
||||
if(KNIGHT_POSIX == Architecture) assign = "LOAD R0 R0 0\n";
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture)) assign = "LOAD R0 R0 0\n";
|
||||
else if(X86 == Architecture) assign = "LOAD_INTEGER\n";
|
||||
else if(AMD64 == Architecture) assign = "LOAD_INTEGER\n";
|
||||
else if(ARMV7L == Architecture) assign = "!0 R0 LOAD32 R0 MEMORY\n";
|
||||
|
||||
/* Add support for Ints */
|
||||
if(match("char*", current_target->name))
|
||||
{
|
||||
if(KNIGHT_POSIX == Architecture) assign = "LOAD8 R0 R0 0\n";
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture)) assign = "LOAD8 R0 R0 0\n";
|
||||
else if(X86 == Architecture) assign = "LOAD_BYTE\n";
|
||||
else if(AMD64 == Architecture) assign = "LOAD_BYTE\n";
|
||||
else if(ARMV7L == Architecture) assign = "!0 R0 LOAD8 R0 MEMORY\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("SALI R0 ");
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture)) emit_out("SALI R0 ");
|
||||
else if(X86 == Architecture) emit_out("SAL_eax_Immediate8 !");
|
||||
else if(AMD64 == Architecture) emit_out("SAL_rax_Immediate8 !");
|
||||
else if(ARMV7L == Architecture) emit_out("'0' R0 R0 '");
|
||||
|
||||
emit_out(numerate_number(ceil_log2(current_target->indirect->size)));
|
||||
|
@ -569,8 +631,9 @@ void postfix_expr_array()
|
|||
emit_out("\n");
|
||||
}
|
||||
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("ADD R0 R0 R1\n");
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture)) emit_out("ADD R0 R0 R1\n");
|
||||
else if(X86 == Architecture) emit_out("ADD_ebx_to_eax\n");
|
||||
else if(AMD64 == Architecture) emit_out("ADD_rbx_to_rax\n");
|
||||
else if(ARMV7L == Architecture) emit_out("'0' R0 R0 ADD R1 ARITH2_ALWAYS\n");
|
||||
|
||||
require_match("ERROR in postfix_expr\nMissing ]\n", "]");
|
||||
|
@ -598,8 +661,9 @@ void unary_expr_sizeof()
|
|||
struct type* a = type_name();
|
||||
require_match("ERROR in unary_expr\nMissing )\n", ")");
|
||||
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("LOADUI R0 ");
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture)) emit_out("LOADUI R0 ");
|
||||
else if(X86 == Architecture) emit_out("LOAD_IMMEDIATE_eax %");
|
||||
else if(AMD64 == Architecture) emit_out("LOAD_IMMEDIATE_rax %");
|
||||
else if(ARMV7L == Architecture) emit_out("!");
|
||||
emit_out(numerate_number(a->size));
|
||||
if(ARMV7L == Architecture) emit_out(" R0 LOADI8_ALWAYS");
|
||||
|
@ -640,7 +704,7 @@ void postfix_expr()
|
|||
*/
|
||||
void additive_expr_stub()
|
||||
{
|
||||
if(KNIGHT_POSIX == Architecture)
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture))
|
||||
{
|
||||
general_recursion(postfix_expr, "ADD R0 R1 R0\n", "+", additive_expr_stub);
|
||||
general_recursion(postfix_expr, "SUB R0 R1 R0\n", "-", additive_expr_stub);
|
||||
|
@ -691,7 +755,7 @@ void additive_expr()
|
|||
|
||||
void relational_expr_stub()
|
||||
{
|
||||
if(KNIGHT_POSIX == Architecture)
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture))
|
||||
{
|
||||
general_recursion(additive_expr, "CMPSKIP.GE R1 R0\nLOADUI R2 1\nMOVE R0 R2\n", "<", relational_expr_stub);
|
||||
general_recursion(additive_expr, "CMPSKIP.G R1 R0\nLOADUI R2 1\nMOVE R0 R2\n", "<=", relational_expr_stub);
|
||||
|
@ -709,6 +773,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(AMD64 == Architecture)
|
||||
{
|
||||
general_recursion(additive_expr, "CMP\nSETL\nMOVEZX\n", "<", relational_expr_stub);
|
||||
general_recursion(additive_expr, "CMP\nSETLE\nMOVEZX\n", "<=", relational_expr_stub);
|
||||
general_recursion(additive_expr, "CMP\nSETGE\nMOVEZX\n", ">=", relational_expr_stub);
|
||||
general_recursion(additive_expr, "CMP\nSETG\nMOVEZX\n", ">", relational_expr_stub);
|
||||
general_recursion(additive_expr, "CMP\nSETE\nMOVEZX\n", "==", relational_expr_stub);
|
||||
general_recursion(additive_expr, "CMP\nSETNE\nMOVEZX\n", "!=", relational_expr_stub);
|
||||
}
|
||||
else if(ARMV7L == Architecture)
|
||||
{
|
||||
general_recursion(additive_expr, "'0' R0 CMP R1 AUX_ALWAYS\n!0 R0 LOADI8_ALWAYS\n!1 R0 LOADI8_L\n", "<", relational_expr_stub);
|
||||
|
@ -737,7 +810,7 @@ void relational_expr()
|
|||
*/
|
||||
void bitwise_expr_stub()
|
||||
{
|
||||
if(KNIGHT_POSIX == Architecture)
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture))
|
||||
{
|
||||
general_recursion(relational_expr, "AND R0 R0 R1\n", "&", bitwise_expr_stub);
|
||||
general_recursion(relational_expr, "AND R0 R0 R1\n", "&&", bitwise_expr_stub);
|
||||
|
@ -796,7 +869,7 @@ void primary_expr()
|
|||
|
||||
common_recursion(primary_expr);
|
||||
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("NEG R0 R0\n");
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == 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("'0' R0 R0 SUB R1 ARITH2_ALWAYS\n");
|
||||
}
|
||||
|
@ -807,7 +880,7 @@ void primary_expr()
|
|||
|
||||
common_recursion(postfix_expr);
|
||||
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("XORI R0 R0 1\n");
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == 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("'0' R0 R0 XOR R1 ARITH2_ALWAYS\n");
|
||||
}
|
||||
|
@ -815,7 +888,7 @@ void primary_expr()
|
|||
{
|
||||
common_recursion(postfix_expr);
|
||||
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("NOT R0 R0\n");
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture)) emit_out("NOT R0 R0\n");
|
||||
else if(X86 == Architecture) emit_out("NOT_eax\n");
|
||||
else if(ARMV7L == Architecture) emit_out("'0' R0 R0 MVN_ALWAYS\n");
|
||||
}
|
||||
|
@ -840,14 +913,16 @@ void expression()
|
|||
char* store = "";
|
||||
if(!match("]", global_token->prev->s) || !match("char*", current_target->name))
|
||||
{
|
||||
if(KNIGHT_POSIX == Architecture) store = "STORE R0 R1 0\n";
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture)) store = "STORE R0 R1 0\n";
|
||||
else if(X86 == Architecture) store = "STORE_INTEGER\n";
|
||||
else if(AMD64 == Architecture) store = "STORE_INTEGER\n";
|
||||
else if(ARMV7L == Architecture) store = "!0 R0 STORE32 R1 MEMORY\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
if(KNIGHT_POSIX == Architecture) store = "STORE8 R0 R1 0\n";
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture)) store = "STORE8 R0 R1 0\n";
|
||||
else if(X86 == Architecture) store = "STORE_CHAR\n";
|
||||
else if(AMD64 == Architecture) store = "STORE_CHAR\n";
|
||||
else if(ARMV7L == Architecture) store = "!0 R0 STORE8 R1 MEMORY\n";
|
||||
}
|
||||
|
||||
|
@ -865,25 +940,26 @@ void collect_local()
|
|||
struct token_list* a = sym_declare(global_token->s, type_size, function->locals);
|
||||
if(match("main", function->s) && (NULL == function->locals))
|
||||
{
|
||||
if(KNIGHT_POSIX == Architecture) a->depth = 20;
|
||||
if(KNIGHT_NATIVE == Architecture) a->depth = 4;
|
||||
else if(KNIGHT_POSIX == Architecture) a->depth = 20;
|
||||
else if(X86 == Architecture) a->depth = -20;
|
||||
else if(ARMV7L == Architecture) a->depth = 16;
|
||||
}
|
||||
else if((NULL == function->arguments) && (NULL == function->locals))
|
||||
{
|
||||
if(KNIGHT_POSIX == Architecture) a->depth = 4;
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture)) a->depth = 4;
|
||||
else if(X86 == Architecture) a->depth = -8;
|
||||
else if(ARMV7L == Architecture) a->depth = 8;
|
||||
}
|
||||
else if(NULL == function->locals)
|
||||
{
|
||||
if(KNIGHT_POSIX == Architecture) a->depth = function->arguments->depth + 8;
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == 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 + 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(KNIGHT_POSIX == Architecture) a->depth = function->locals->depth + 4;
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture)) a->depth = function->locals->depth + 4;
|
||||
else if(X86 == Architecture) a->depth = function->locals->depth - 4;
|
||||
else if(ARMV7L == Architecture) a->depth = function->locals->depth + 4;
|
||||
}
|
||||
|
@ -904,8 +980,9 @@ void collect_local()
|
|||
|
||||
require_match("ERROR in collect_local\nMissing ;\n", ";");
|
||||
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("PUSHR R0 R15\t#");
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture)) emit_out("PUSHR R0 R15\t#");
|
||||
else if(X86 == Architecture) emit_out("PUSH_eax\t#");
|
||||
else if(AMD64 == Architecture) emit_out("PUSH_RAX\t#");
|
||||
else if(ARMV7L == Architecture) emit_out("{R0} PUSH_ALWAYS\t#");
|
||||
emit_out(a->s);
|
||||
emit_out("\n");
|
||||
|
@ -926,8 +1003,9 @@ void process_if()
|
|||
require_match("ERROR in process_if\nMISSING (\n", "(");
|
||||
expression();
|
||||
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("JUMP.Z R0 @ELSE_");
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture)) emit_out("JUMP.Z R0 @ELSE_");
|
||||
else if(X86 == Architecture) emit_out("TEST\nJUMP_EQ %ELSE_");
|
||||
else if(AMD64 == Architecture) emit_out("TEST\nJUMP_EQ %ELSE_");
|
||||
else if(ARMV7L == Architecture) emit_out("!0 CMPI8 R0 IMM_ALWAYS\n^~ELSE_");
|
||||
|
||||
uniqueID_out(function->s, number_string);
|
||||
|
@ -936,8 +1014,9 @@ void process_if()
|
|||
require_match("ERROR in process_if\nMISSING )\n", ")");
|
||||
statement();
|
||||
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("JUMP @_END_IF_");
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture)) emit_out("JUMP @_END_IF_");
|
||||
else if(X86 == Architecture) emit_out("JUMP %_END_IF_");
|
||||
else if(AMD64 == Architecture) emit_out("JUMP %_END_IF_");
|
||||
else if(ARMV7L == Architecture) emit_out("^~_END_IF_");
|
||||
|
||||
uniqueID_out(function->s, number_string);
|
||||
|
@ -987,13 +1066,13 @@ void process_for()
|
|||
require_match("ERROR in process_for\nMISSING ;1\n", ";");
|
||||
expression();
|
||||
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("JUMP.Z R0 @FOR_END_");
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == 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("!0 CMPI8 R0 IMM_ALWAYS\n^~FOR_END_");
|
||||
uniqueID_out(function->s, number_string);
|
||||
if(ARMV7L == Architecture) emit_out(" JUMP_EQUAL\n");
|
||||
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("JUMP @FOR_THEN_");
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture)) emit_out("JUMP @FOR_THEN_");
|
||||
else if(X86 == Architecture) emit_out("JUMP %FOR_THEN_");
|
||||
else if(ARMV7L == Architecture) emit_out("^~FOR_THEN_");
|
||||
uniqueID_out(function->s, number_string);
|
||||
|
@ -1005,7 +1084,7 @@ void process_for()
|
|||
require_match("ERROR in process_for\nMISSING ;2\n", ";");
|
||||
expression();
|
||||
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("JUMP @FOR_");
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture)) emit_out("JUMP @FOR_");
|
||||
else if(X86 == Architecture) emit_out("JUMP %FOR_");
|
||||
else if(ARMV7L == Architecture) emit_out("^~FOR_");
|
||||
uniqueID_out(function->s, number_string);
|
||||
|
@ -1017,7 +1096,7 @@ void process_for()
|
|||
require_match("ERROR in process_for\nMISSING )\n", ")");
|
||||
statement();
|
||||
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("JUMP @FOR_ITER_");
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture)) emit_out("JUMP @FOR_ITER_");
|
||||
else if(X86 == Architecture) emit_out("JUMP %FOR_ITER_");
|
||||
else if(ARMV7L == Architecture) emit_out("^~FOR_ITER_");
|
||||
uniqueID_out(function->s, number_string);
|
||||
|
@ -1075,7 +1154,7 @@ void process_do()
|
|||
require_match("ERROR in process_do\nMISSING )\n", ")");
|
||||
require_match("ERROR in process_do\nMISSING ;\n", ";");
|
||||
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("JUMP.NZ R0 @DO_");
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture)) emit_out("JUMP.NZ R0 @DO_");
|
||||
else if(X86 == Architecture) emit_out("TEST\nJUMP_NE %DO_");
|
||||
else if(ARMV7L == Architecture) emit_out("!0 CMPI8 R0 IMM_ALWAYS\n^~DO_");
|
||||
uniqueID_out(function->s, number_string);
|
||||
|
@ -1114,7 +1193,7 @@ void process_while()
|
|||
require_match("ERROR in process_while\nMISSING (\n", "(");
|
||||
expression();
|
||||
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("JUMP.Z R0 @END_WHILE_");
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == 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("!0 CMPI8 R0 IMM_ALWAYS\n^~END_WHILE_");
|
||||
uniqueID_out(function->s, number_string);
|
||||
|
@ -1125,7 +1204,7 @@ void process_while()
|
|||
require_match("ERROR in process_while\nMISSING )\n", ")");
|
||||
statement();
|
||||
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("JUMP @WHILE_");
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture)) emit_out("JUMP @WHILE_");
|
||||
else if(X86 == Architecture) emit_out("JUMP %WHILE_");
|
||||
else if(ARMV7L == Architecture) emit_out("^~WHILE_");
|
||||
uniqueID_out(function->s, number_string);
|
||||
|
@ -1150,13 +1229,15 @@ void return_result()
|
|||
struct token_list* i;
|
||||
for(i = function->locals; NULL != i; i = i->next)
|
||||
{
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("POPR R1 R15\t# _return_result_locals\n");
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == 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(AMD64 == Architecture) emit_out("POP_RBX\t# _return_result_locals\n");
|
||||
else if(ARMV7L == Architecture) emit_out("{R1} POP_ALWAYS\t# _return_result_locals\n");
|
||||
}
|
||||
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("RET R15\n");
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture)) emit_out("RET R15\n");
|
||||
else if(X86 == Architecture) emit_out("RETURN\n");
|
||||
else if(AMD64 == Architecture) emit_out("RETURN\n");
|
||||
else if(ARMV7L == Architecture) emit_out("'1' LR RETURN\n");
|
||||
}
|
||||
|
||||
|
@ -1172,14 +1253,14 @@ void process_break()
|
|||
while(i != break_frame)
|
||||
{
|
||||
if(NULL == i) break;
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("POPR R1 R15\t# break_cleanup_locals\n");
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == 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("{R1} POP_ALWAYS\t# break_cleanup_locals\n");
|
||||
i = i->next;
|
||||
}
|
||||
global_token = global_token->next;
|
||||
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("JUMP @");
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture)) emit_out("JUMP @");
|
||||
else if(X86 == Architecture) emit_out("JUMP %");
|
||||
else if(ARMV7L == Architecture) emit_out("^~");
|
||||
|
||||
|
@ -1206,14 +1287,15 @@ 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)) ||
|
||||
(((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture)) && !match("RET R15\n", out->s)) ||
|
||||
((ARMV7L == Architecture) && !match("'1' LR RETURN\n", out->s)))
|
||||
{
|
||||
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");
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == 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(AMD64 == Architecture) emit_out("POP_RBX\t# _recursive_statement_locals\n");
|
||||
else if(ARMV7L == Architecture) emit_out("{R1} POP_ALWAYS\t# _recursive_statement_locals\n");
|
||||
}
|
||||
}
|
||||
|
@ -1279,7 +1361,7 @@ void statement()
|
|||
else if(match("goto", global_token->s))
|
||||
{
|
||||
global_token = global_token->next;
|
||||
if(KNIGHT_POSIX == Architecture) emit_out("JUMP @");
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture)) emit_out("JUMP @");
|
||||
else if(X86 == Architecture) emit_out("JUMP %");
|
||||
else if(ARMV7L == Architecture) emit_out("^~");
|
||||
emit_out(global_token->s);
|
||||
|
@ -1328,13 +1410,13 @@ void collect_arguments()
|
|||
struct token_list* a = sym_declare(global_token->s, type_size, function->arguments);
|
||||
if(NULL == function->arguments)
|
||||
{
|
||||
if(KNIGHT_POSIX == Architecture) a->depth = 0;
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture)) a->depth = 0;
|
||||
else if(X86 == Architecture) a->depth = -4;
|
||||
else if(ARMV7L == Architecture) a->depth = 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(KNIGHT_POSIX == Architecture) a->depth = function->arguments->depth + 4;
|
||||
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture)) a->depth = function->arguments->depth + 4;
|
||||
else if(X86 == Architecture) a->depth = function->arguments->depth - 4;
|
||||
else if(ARMV7L == Architecture) a->depth = function->arguments->depth + 4;
|
||||
}
|
||||
|
@ -1356,7 +1438,12 @@ void declare_function()
|
|||
|
||||
/* allow previously defined functions to be looked up */
|
||||
global_function_list = function;
|
||||
collect_arguments();
|
||||
if((KNIGHT_NATIVE == Architecture) && match("main", function->s))
|
||||
{
|
||||
require_match("Impossible error ( vanished\n", "(");
|
||||
require_match("Reality ERROR (USING KNIGHT-NATIVE)\nHardware does not support arguments\nthus neither can main on this architecture\ntry tape_01 and tape_02 instead\n", ")");
|
||||
}
|
||||
else collect_arguments();
|
||||
|
||||
/* If just a prototype don't waste time */
|
||||
if(global_token->s[0] == ';') global_token = global_token->next;
|
||||
|
@ -1371,8 +1458,9 @@ void declare_function()
|
|||
statement();
|
||||
|
||||
/* Prevent duplicate RETURNS */
|
||||
if((KNIGHT_POSIX == Architecture) && !match("RET R15\n", out->s)) emit_out("RET R15\n");
|
||||
if(((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == 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((AMD64 == Architecture) && !match("RETURN\n", out->s)) emit_out("RETURN\n");
|
||||
else if((ARMV7L == Architecture) && !match("'1' LR RETURN\n", out->s)) emit_out("'1' LR RETURN\n");
|
||||
}
|
||||
}
|
||||
|
|
50
cc_reader.c
50
cc_reader.c
|
@ -40,8 +40,9 @@ int consume_byte(int c)
|
|||
return fgetc(input);
|
||||
}
|
||||
|
||||
int consume_word(int c, int frequent)
|
||||
int preserve_string(int c)
|
||||
{
|
||||
int frequent = c;
|
||||
int escape = FALSE;
|
||||
do
|
||||
{
|
||||
|
@ -66,23 +67,9 @@ int consume_word(int c, int frequent)
|
|||
} while(0 != hold);
|
||||
}
|
||||
|
||||
int preserve_keyword(int c)
|
||||
int preserve_keyword(int c, char* S)
|
||||
{
|
||||
while(in_set(c, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"))
|
||||
{
|
||||
c = consume_byte(c);
|
||||
}
|
||||
if(':' == c)
|
||||
{
|
||||
fixup_label();
|
||||
return 32;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
int preserve_symbol(int c)
|
||||
{
|
||||
while(in_set(c, "<=>|&!-"))
|
||||
while(in_set(c, S))
|
||||
{
|
||||
c = consume_byte(c);
|
||||
}
|
||||
|
@ -114,26 +101,32 @@ reset:
|
|||
string_index = 0;
|
||||
|
||||
c = clearWhiteSpace(c);
|
||||
if('#' == c)
|
||||
if(c == EOF)
|
||||
{
|
||||
free(current);
|
||||
return c;
|
||||
}
|
||||
else if('#' == c)
|
||||
{
|
||||
c = purge_macro(c);
|
||||
goto reset;
|
||||
}
|
||||
else if(in_set(c, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"))
|
||||
{
|
||||
c = preserve_keyword(c);
|
||||
c = preserve_keyword(c, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_");
|
||||
if(':' == c)
|
||||
{
|
||||
fixup_label();
|
||||
c = ' ';
|
||||
}
|
||||
}
|
||||
else if(in_set(c, "<=>|&!-"))
|
||||
{
|
||||
c = preserve_symbol(c);
|
||||
c = preserve_keyword(c, "<=>|&!-");
|
||||
}
|
||||
else if(c == '\'')
|
||||
{ /* 39 == ' */
|
||||
c = consume_word(c, '\'');
|
||||
}
|
||||
else if(c == '"')
|
||||
else if(in_set(c, "'\""))
|
||||
{
|
||||
c = consume_word(c, '"');
|
||||
c = preserve_string(c);
|
||||
}
|
||||
else if(c == '/')
|
||||
{
|
||||
|
@ -160,11 +153,6 @@ reset:
|
|||
goto reset;
|
||||
}
|
||||
}
|
||||
else if(c == EOF)
|
||||
{
|
||||
free(current);
|
||||
return c;
|
||||
}
|
||||
else
|
||||
{
|
||||
c = consume_byte(c);
|
||||
|
|
20
cc_types.c
20
cc_types.c
|
@ -23,10 +23,14 @@ int numerate_string(char *a);
|
|||
/* Initialize default types */
|
||||
void initialize_types()
|
||||
{
|
||||
int register_size;
|
||||
if(AMD64 == Architecture) register_size = 8;
|
||||
else register_size = 4;
|
||||
|
||||
/* Define void */
|
||||
global_types = calloc(1, sizeof(struct type));
|
||||
global_types->name = "void";
|
||||
global_types->size = 4;
|
||||
global_types->size = register_size;
|
||||
global_types->type = global_types;
|
||||
/* void* has the same properties as void */
|
||||
global_types->indirect = global_types;
|
||||
|
@ -34,7 +38,7 @@ void initialize_types()
|
|||
/* Define int */
|
||||
struct type* a = calloc(1, sizeof(struct type));
|
||||
a->name = "int";
|
||||
a->size = 4;
|
||||
a->size = register_size;
|
||||
/* int* has the same properties as int */
|
||||
a->indirect = a;
|
||||
a->type = a;
|
||||
|
@ -42,7 +46,7 @@ void initialize_types()
|
|||
/* Define char* */
|
||||
struct type* b = calloc(1, sizeof(struct type));
|
||||
b->name = "char*";
|
||||
b->size = 4;
|
||||
b->size = register_size;
|
||||
b->type = b;
|
||||
|
||||
/* Define char */
|
||||
|
@ -54,7 +58,7 @@ void initialize_types()
|
|||
/* Define char** */
|
||||
struct type* d = calloc(1, sizeof(struct type));
|
||||
d->name = "char**";
|
||||
d->size = 4;
|
||||
d->size = register_size;
|
||||
d->type = b;
|
||||
d->indirect = d;
|
||||
|
||||
|
@ -65,7 +69,7 @@ void initialize_types()
|
|||
/* Define FILE */
|
||||
struct type* e = calloc(1, sizeof(struct type));
|
||||
e->name = "FILE";
|
||||
e->size = 4;
|
||||
e->size = register_size;
|
||||
e->type = e;
|
||||
/* FILE* has the same properties as FILE */
|
||||
e->indirect = e;
|
||||
|
@ -73,7 +77,7 @@ void initialize_types()
|
|||
/* Define FUNCTION */
|
||||
struct type* f = calloc(1, sizeof(struct type));
|
||||
f->name = "FUNCTION";
|
||||
f->size = 4;
|
||||
f->size = register_size;
|
||||
f->type = f;
|
||||
/* FUNCTION* has the same properties as FUNCTION */
|
||||
f->indirect = f;
|
||||
|
@ -81,7 +85,7 @@ void initialize_types()
|
|||
/* Define UNSIGNED */
|
||||
struct type* g = calloc(1, sizeof(struct type));
|
||||
g->name = "unsigned";
|
||||
g->size = 4;
|
||||
g->size = register_size;
|
||||
g->type = g;
|
||||
/* unsigned* has the same properties as unsigned */
|
||||
g->indirect = g;
|
||||
|
@ -89,7 +93,7 @@ void initialize_types()
|
|||
/* Custom type for mescc*/
|
||||
struct type* h = calloc(1, sizeof(struct type));
|
||||
h->name = "SCM";
|
||||
h->size = 4;
|
||||
h->size = register_size;
|
||||
h->indirect = h;
|
||||
|
||||
/* Finalize type list */
|
||||
|
|
86
makefile
86
makefile
|
@ -62,7 +62,10 @@ results:
|
|||
mkdir -p test/results
|
||||
|
||||
# tests
|
||||
test: test00-knight-posix-binary \
|
||||
test: test00-amd64-binary \
|
||||
test01-amd64-binary \
|
||||
test02-amd64-binary \
|
||||
test00-knight-posix-binary \
|
||||
test01-knight-posix-binary \
|
||||
test02-knight-posix-binary \
|
||||
test03-knight-posix-binary \
|
||||
|
@ -89,6 +92,24 @@ test: test00-knight-posix-binary \
|
|||
test24-knight-posix-binary \
|
||||
test99-knight-posix-binary \
|
||||
test100-knight-posix-binary \
|
||||
test00-knight-native-binary\
|
||||
test01-knight-native-binary\
|
||||
test02-knight-native-binary\
|
||||
test03-knight-native-binary\
|
||||
test04-knight-native-binary\
|
||||
test05-knight-native-binary\
|
||||
test06-knight-native-binary\
|
||||
test07-knight-native-binary\
|
||||
test08-knight-native-binary\
|
||||
test09-knight-native-binary\
|
||||
test10-knight-native-binary\
|
||||
test11-knight-native-binary\
|
||||
test12-knight-native-binary\
|
||||
test13-knight-native-binary\
|
||||
test17-knight-native-binary\
|
||||
test18-knight-native-binary\
|
||||
test20-knight-native-binary\
|
||||
test99-knight-native-binary\
|
||||
test00-armv7l-binary \
|
||||
test01-armv7l-binary \
|
||||
test02-armv7l-binary \
|
||||
|
@ -149,6 +170,15 @@ test: test00-knight-posix-binary \
|
|||
test100-x86-binary | results
|
||||
sha256sum -c test/test.answers
|
||||
|
||||
test00-amd64-binary: M2-Planet | results
|
||||
test/test00/hello-amd64.sh
|
||||
|
||||
test01-amd64-binary: M2-Planet | results
|
||||
test/test01/hello-amd64.sh
|
||||
|
||||
test02-amd64-binary: M2-Planet | results
|
||||
test/test02/hello-amd64.sh
|
||||
|
||||
test00-knight-posix-binary: M2-Planet | results
|
||||
test/test00/hello-knight-posix.sh
|
||||
|
||||
|
@ -230,6 +260,60 @@ test99-knight-posix-binary: M2-Planet | results
|
|||
test100-knight-posix-binary: M2-Planet | results
|
||||
test/test100/hello-knight-posix.sh
|
||||
|
||||
test00-knight-native-binary: M2-Planet | results
|
||||
test/test00/hello-knight-native.sh
|
||||
|
||||
test01-knight-native-binary: M2-Planet | results
|
||||
test/test01/hello-knight-native.sh
|
||||
|
||||
test02-knight-native-binary: M2-Planet | results
|
||||
test/test02/hello-knight-native.sh
|
||||
|
||||
test03-knight-native-binary: M2-Planet | results
|
||||
test/test03/hello-knight-native.sh
|
||||
|
||||
test04-knight-native-binary: M2-Planet | results
|
||||
test/test04/hello-knight-native.sh
|
||||
|
||||
test05-knight-native-binary: M2-Planet | results
|
||||
test/test05/hello-knight-native.sh
|
||||
|
||||
test06-knight-native-binary: M2-Planet | results
|
||||
test/test06/hello-knight-native.sh
|
||||
|
||||
test07-knight-native-binary: M2-Planet | results
|
||||
test/test07/hello-knight-native.sh
|
||||
|
||||
test08-knight-native-binary: M2-Planet | results
|
||||
test/test08/hello-knight-native.sh
|
||||
|
||||
test09-knight-native-binary: M2-Planet | results
|
||||
test/test09/hello-knight-native.sh
|
||||
|
||||
test10-knight-native-binary: M2-Planet | results
|
||||
test/test10/hello-knight-native.sh
|
||||
|
||||
test11-knight-native-binary: M2-Planet | results
|
||||
test/test11/hello-knight-native.sh
|
||||
|
||||
test12-knight-native-binary: M2-Planet | results
|
||||
test/test12/hello-knight-native.sh
|
||||
|
||||
test13-knight-native-binary: M2-Planet | results
|
||||
test/test13/hello-knight-native.sh
|
||||
|
||||
test17-knight-native-binary: M2-Planet | results
|
||||
test/test17/hello-knight-native.sh
|
||||
|
||||
test18-knight-native-binary: M2-Planet | results
|
||||
test/test18/hello-knight-native.sh
|
||||
|
||||
test20-knight-native-binary: M2-Planet | results
|
||||
test/test20/hello-knight-native.sh
|
||||
|
||||
test99-knight-native-binary: M2-Planet | results
|
||||
test/test99/hello-knight-native.sh
|
||||
|
||||
test00-armv7l-binary: M2-Planet | results
|
||||
test/test00/hello-armv7l.sh
|
||||
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
### Copyright (C) 2016 Jeremiah Orians
|
||||
### Copyright (C) 2017 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
### 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/>.
|
||||
|
||||
### elf64.hex2: 64 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
|
||||
|
||||
02 ## e_ident[EI_CLASS] Indicating 64 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
|
||||
3E 00 ## e_machine Indicating AMD64
|
||||
01 00 00 00 ## e_version Indicating original elf
|
||||
|
||||
&ELF_text 00 00 00 00 ## e_entry Address of the entry point (Number of bytes this header is + Base Address)
|
||||
%ELF_program_headers>ELF_base 00 00 00 00 ## e_phoff Address of program header table
|
||||
00 00 00 00 00 00 00 00 ## e_shoff Address of section header table
|
||||
|
||||
00 00 00 00 ## e_flags
|
||||
40 00 ## e_ehsize Indicating our 64 Byte header
|
||||
|
||||
38 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
|
||||
01 00 00 00 ## p_type
|
||||
06 00 00 00 ## Flags
|
||||
00 00 00 00 00 00 00 00 ## p_offset
|
||||
|
||||
&ELF_base 00 00 00 00 ## p_vaddr
|
||||
&ELF_base 00 00 00 00 ## p_physaddr
|
||||
|
||||
%ELF_end>ELF_base 00 00 00 00 ## p_filesz
|
||||
%ELF_end>ELF_base 00 00 00 00 ## p_memsz
|
||||
|
||||
01 00 00 00 00 00 00 00 ## Required alignment
|
||||
|
||||
:ELF_text
|
|
@ -0,0 +1,51 @@
|
|||
## 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/>.
|
||||
|
||||
|
||||
DEFINE ADD_IMMEDIATE_to_rax 4805
|
||||
DEFINE ADD_IMMEDIATE_to_rbp 4881C5
|
||||
DEFINE ADD_rbp_to_rax 4801E8
|
||||
DEFINE CALL_IMMEDIATE E8
|
||||
DEFINE CMP 4839D8
|
||||
DEFINE COPY_rax_to_rdi 4889C7
|
||||
DEFINE COPY_rbp_to_rax 4889E8
|
||||
DEFINE COPY_rdi_to_rbp 4889FD
|
||||
DEFINE COPY_rsp_to_rbp 4889E5
|
||||
DEFINE COPY_RSP_to_RDI 4889E7
|
||||
DEFINE JUMP E9
|
||||
DEFINE JUMP_EQ 0F84
|
||||
DEFINE LOAD_BASE_ADDRESS_rax 488D85
|
||||
DEFINE LOAD_EFFECTIVE_ADDRESS_rsi 488DB424
|
||||
DEFINE LOAD_IMMEDIATE_rax 48C7C0
|
||||
DEFINE LOAD_IMMEDIATE_rdi 48C7C7
|
||||
DEFINE LOAD_IMMEDIATE_rdx 48C7C2
|
||||
DEFINE LOAD_INTEGER 488B00
|
||||
DEFINE MOVEZX 480FB6C0
|
||||
DEFINE POP_RBP 5D
|
||||
DEFINE POP_RBX 5B
|
||||
DEFINE POP_RDI 5F
|
||||
DEFINE PUSH_RAX 50
|
||||
DEFINE PUSH_RBP 55
|
||||
DEFINE PUSH_RDI 57
|
||||
DEFINE RETURN C3
|
||||
DEFINE SAL_rax_Immediate8 48C1E0
|
||||
DEFINE SETE 0F94C0
|
||||
DEFINE SETG 0F9FC0
|
||||
DEFINE SETGE 0F9DC0
|
||||
DEFINE SETL 0F9CC0
|
||||
DEFINE SETLE 0F9EC0
|
||||
DEFINE SYSCALL 0F05
|
||||
DEFINE TEST 4885C0
|
|
@ -0,0 +1,27 @@
|
|||
/* 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 EXIT_FAILURE 1
|
||||
// CONSTANT EXIT_SUCCESS 0
|
||||
|
||||
void exit(int value)
|
||||
{
|
||||
asm("POP_RBX"
|
||||
"POP_RDI"
|
||||
"LOAD_IMMEDIATE_rax %0x3C"
|
||||
"SYSCALL");
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
/* 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 putchar(int c)
|
||||
{
|
||||
asm("LOAD_IMMEDIATE_rax %1"
|
||||
"LOAD_EFFECTIVE_ADDRESS_rsi %8"
|
||||
"LOAD_IMMEDIATE_rdi %1"
|
||||
"LOAD_IMMEDIATE_rdx %1"
|
||||
"SYSCALL");
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
## 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
|
||||
|
||||
COPY_rsp_to_rbp ; Protect rsp
|
||||
|
||||
;; Prepare argv
|
||||
LOAD_BASE_ADDRESS_rax %8 ; ARGV_address = RBP + 8
|
||||
PUSH_RAX ; Put argv on the stack
|
||||
|
||||
;; Prepare envp
|
||||
COPY_rbp_to_rax ; Address we need to load from
|
||||
LOAD_INTEGER ; Get ARGC
|
||||
ADD_IMMEDIATE_to_rax %2 ; OFFSET = ARGC + 2
|
||||
SAL_rax_Immediate8 !3 ; OFFSET = OFFSET * WORDSIZE
|
||||
ADD_rbp_to_rax ; ENVP_address = RSP + OFFSET
|
||||
PUSH_RAX ; Put envp on the stack
|
||||
|
||||
;; Stack offset
|
||||
ADD_IMMEDIATE_to_rbp %8 ; Fix rbp
|
||||
|
||||
;; Perform the main loop
|
||||
CALL_IMMEDIATE %FUNCTION_main
|
||||
|
||||
;; Exit to kernel
|
||||
COPY_rax_to_rdi ; Using the return code given by main
|
||||
LOAD_IMMEDIATE_rax %0x3C ; Syscall exit
|
||||
SYSCALL ; Exit with that code
|
|
@ -0,0 +1,25 @@
|
|||
/* 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 EXIT_FAILURE 1
|
||||
// CONSTANT EXIT_SUCCESS 0
|
||||
|
||||
void exit(int value)
|
||||
{
|
||||
/* Hardware doesn't have return codes */
|
||||
asm("HALT");
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
/* 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 0x1100
|
||||
// CONSTANT stdout 0x1101
|
||||
// CONSTANT stderr 0
|
||||
// CONSTANT EOF 0xFFFFFFFF
|
||||
|
||||
int fgetc(FILE* f)
|
||||
{
|
||||
asm("LOAD R1 R14 0"
|
||||
"FGETC");
|
||||
}
|
||||
|
||||
void fputc(char s, FILE* f)
|
||||
{
|
||||
asm("LOAD R0 R14 0"
|
||||
"LOAD R1 R14 4"
|
||||
"FPUTC");
|
||||
}
|
|
@ -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/>.
|
||||
*/
|
||||
|
||||
int getchar()
|
||||
{
|
||||
/* tape1 is 0x1100 */
|
||||
asm("LOADUI R1 0x1100"
|
||||
"FGETC");
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
/* 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 putchar(int c)
|
||||
{
|
||||
/* Console is 0 */
|
||||
asm("LOAD R0 R14 0"
|
||||
"LOADUI R1 0"
|
||||
"FPUTC");
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
/* 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 putchar(int c)
|
||||
{
|
||||
/* tape2 is 0x1101 */
|
||||
asm("LOAD R0 R14 0"
|
||||
"LOADUI R1 0x1101"
|
||||
"FPUTC");
|
||||
}
|
|
@ -0,0 +1,253 @@
|
|||
## 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 R14 E
|
||||
DEFINE R15 F
|
||||
|
||||
# 4OP Integer Group
|
||||
DEFINE ADD.CI 0100
|
||||
DEFINE ADD.CO 0101
|
||||
DEFINE ADD.CIO 0102
|
||||
DEFINE ADDU.CI 0103
|
||||
DEFINE ADDU.CO 0104
|
||||
DEFINE ADDU.CIO 0105
|
||||
DEFINE SUB.BI 0106
|
||||
DEFINE SUB.BO 0107
|
||||
DEFINE SUB.BIO 0108
|
||||
DEFINE SUBU.BI 0109
|
||||
DEFINE SUBU.BO 010A
|
||||
DEFINE SUBU.BIO 010B
|
||||
DEFINE MULTIPLY 010C
|
||||
DEFINE MULTIPLYU 010D
|
||||
DEFINE DIVIDE 010E
|
||||
DEFINE DIVIDEU 010F
|
||||
DEFINE MUX 0110
|
||||
DEFINE NMUX 0111
|
||||
DEFINE SORT 0112
|
||||
DEFINE SORTU 0113
|
||||
|
||||
# 3OP Integer Group
|
||||
DEFINE ADD 05000
|
||||
DEFINE ADDU 05001
|
||||
DEFINE SUB 05002
|
||||
DEFINE SUBU 05003
|
||||
DEFINE CMP 05004
|
||||
DEFINE CMPU 05005
|
||||
DEFINE MUL 05006
|
||||
DEFINE MULH 05007
|
||||
DEFINE MULU 05008
|
||||
DEFINE MULUH 05009
|
||||
DEFINE DIV 0500A
|
||||
DEFINE MOD 0500B
|
||||
DEFINE DIVU 0500C
|
||||
DEFINE MODU 0500D
|
||||
DEFINE MAX 05010
|
||||
DEFINE MAXU 05011
|
||||
DEFINE MIN 05012
|
||||
DEFINE MINU 05013
|
||||
DEFINE AND 05020
|
||||
DEFINE OR 05021
|
||||
DEFINE XOR 05022
|
||||
DEFINE NAND 05023
|
||||
DEFINE NOR 05024
|
||||
DEFINE XNOR 05025
|
||||
DEFINE MPQ 05026
|
||||
DEFINE LPQ 05027
|
||||
DEFINE CPQ 05028
|
||||
DEFINE BPQ 05029
|
||||
DEFINE SAL 05030
|
||||
DEFINE SAR 05031
|
||||
DEFINE SL0 05032
|
||||
DEFINE SR0 05033
|
||||
DEFINE SL1 05034
|
||||
DEFINE SR1 05035
|
||||
DEFINE ROL 05036
|
||||
DEFINE ROR 05037
|
||||
DEFINE LOADX 05038
|
||||
DEFINE LOADX8 05039
|
||||
DEFINE LOADXU8 0503A
|
||||
DEFINE LOADX16 0503B
|
||||
DEFINE LOADXU16 0503C
|
||||
DEFINE LOADX32 0503D
|
||||
DEFINE LOADXU32 0503E
|
||||
DEFINE STOREX 05048
|
||||
DEFINE STOREX8 05049
|
||||
DEFINE STOREX16 0504A
|
||||
DEFINE STOREX32 0504B
|
||||
DEFINE CMPJUMP.G 05050
|
||||
DEFINE CMPJUMP.GE 05051
|
||||
DEFINE CMPJUMP.E 05052
|
||||
DEFINE CMPJUMP.NE 05053
|
||||
DEFINE CMPJUMP.LE 05054
|
||||
DEFINE CMPJUMP.L 05055
|
||||
DEFINE CMPJUMPU.G 05060
|
||||
DEFINE CMPJUMPU.GE 05061
|
||||
DEFINE CMPJUMPU.LE 05064
|
||||
DEFINE CMPJUMPU.L 05065
|
||||
|
||||
# 2OP Integer Group
|
||||
DEFINE NEG 090000
|
||||
DEFINE ABS 090001
|
||||
DEFINE NABS 090002
|
||||
DEFINE SWAP 090003
|
||||
DEFINE COPY 090004
|
||||
DEFINE MOVE 090005
|
||||
DEFINE NOT 090006
|
||||
DEFINE BRANCH 090100
|
||||
DEFINE CALL 090101
|
||||
DEFINE PUSHR 090200
|
||||
DEFINE PUSH8 090201
|
||||
DEFINE PUSH16 090202
|
||||
DEFINE PUSH32 090203
|
||||
DEFINE POPR 090280
|
||||
DEFINE POP8 090281
|
||||
DEFINE POPU8 090282
|
||||
DEFINE POP16 090283
|
||||
DEFINE POPU16 090284
|
||||
DEFINE POP32 090285
|
||||
DEFINE POPU32 090286
|
||||
DEFINE CMPSKIP.G 090300
|
||||
DEFINE CMPSKIP.GE 090301
|
||||
DEFINE CMPSKIP.E 090302
|
||||
DEFINE CMPSKIP.NE 090303
|
||||
DEFINE CMPSKIP.LE 090304
|
||||
DEFINE CMPSKIP.L 090305
|
||||
DEFINE CMPSKIPU.G 090380
|
||||
DEFINE CMPSKIPU.GE 090381
|
||||
DEFINE CMPSKIPU.LE 090384
|
||||
DEFINE CMPSKIPU.L 090385
|
||||
|
||||
# 1OP Group
|
||||
DEFINE READPC 0D00000
|
||||
DEFINE READSCID 0D00001
|
||||
DEFINE FALSE 0D00002
|
||||
DEFINE TRUE 0D00003
|
||||
DEFINE JSR_COROUTINE 0D01000
|
||||
DEFINE RET 0D01001
|
||||
DEFINE PUSHPC 0D02000
|
||||
DEFINE POPPC 0D02001
|
||||
|
||||
# 2OPI Group
|
||||
DEFINE ADDI E1000E
|
||||
DEFINE ADDUI E1000F
|
||||
DEFINE SUBI E10010
|
||||
DEFINE SUBUI E10011
|
||||
DEFINE CMPI E10012
|
||||
DEFINE LOAD E10013
|
||||
DEFINE LOAD8 E10014
|
||||
DEFINE LOADU8 E10015
|
||||
DEFINE LOAD16 E10016
|
||||
DEFINE LOADU16 E10017
|
||||
DEFINE LOAD32 E10018
|
||||
DEFINE LOADU32 E10019
|
||||
DEFINE CMPUI E1001F
|
||||
DEFINE STORE E10020
|
||||
DEFINE STORE8 E10021
|
||||
DEFINE STORE16 E10022
|
||||
DEFINE STORE32 E10023
|
||||
DEFINE ANDI E100B0
|
||||
DEFINE ORI E100B1
|
||||
DEFINE XORI E100B2
|
||||
DEFINE NANDI E100B3
|
||||
DEFINE NORI E100B4
|
||||
DEFINE XNORI E100B5
|
||||
DEFINE CMPJUMPI.G E100C0
|
||||
DEFINE CMPJUMPI.GE E100C1
|
||||
DEFINE CMPJUMPI.E E100C2
|
||||
DEFINE CMPJUMPI.NE E100C3
|
||||
DEFINE CMPJUMPI.LE E100C4
|
||||
DEFINE CMPJUMPI.L E100C5
|
||||
DEFINE CMPJUMPUI.G E100D0
|
||||
DEFINE CMPJUMPUI.GE E100D1
|
||||
DEFINE CMPJUMPUI.LE E100D4
|
||||
DEFINE CMPJUMPUI.L E100D5
|
||||
|
||||
# 1OPI Group
|
||||
DEFINE JUMP.C E0002C0
|
||||
DEFINE JUMP.B E0002C1
|
||||
DEFINE JUMP.O E0002C2
|
||||
DEFINE JUMP.G E0002C3
|
||||
DEFINE JUMP.GE E0002C4
|
||||
DEFINE JUMP.E E0002C5
|
||||
DEFINE JUMP.NE E0002C6
|
||||
DEFINE JUMP.LE E0002C7
|
||||
DEFINE JUMP.L E0002C8
|
||||
DEFINE JUMP.Z E0002C9
|
||||
DEFINE JUMP.NZ E0002CA
|
||||
DEFINE JUMP.P E0002CB
|
||||
DEFINE JUMP.NP E0002CC
|
||||
DEFINE CALLI E0002D0
|
||||
DEFINE LOADI E0002D1
|
||||
DEFINE LOADUI E0002D2
|
||||
DEFINE SALI E0002D3
|
||||
DEFINE SARI E0002D4
|
||||
DEFINE SL0I E0002D5
|
||||
DEFINE SR0I E0002D6
|
||||
DEFINE SL1I E0002D7
|
||||
DEFINE SR1I E0002D8
|
||||
DEFINE LOADR E0002E0
|
||||
DEFINE LOADR8 E0002E1
|
||||
DEFINE LOADRU8 E0002E2
|
||||
DEFINE LOADR16 E0002E3
|
||||
DEFINE LOADRU16 E0002E4
|
||||
DEFINE LOADR32 E0002E5
|
||||
DEFINE LOADRU32 E0002E6
|
||||
DEFINE STORER E0002F0
|
||||
DEFINE STORER8 E0002F1
|
||||
DEFINE STORER16 E0002F2
|
||||
DEFINE STORER32 E0002F3
|
||||
DEFINE CMPSKIPI.G E000A00
|
||||
DEFINE CMPSKIPI.GE E000A01
|
||||
DEFINE CMPSKIPI.E E000A02
|
||||
DEFINE CMPSKIPI.NE E000A03
|
||||
DEFINE CMPSKIPI.LE E000A04
|
||||
DEFINE CMPSKIPI.L E000A05
|
||||
DEFINE CMPSKIPUI.G E000A10
|
||||
DEFINE CMPSKIPUI.GE E000A11
|
||||
DEFINE CMPSKIPUI.LE E000A14
|
||||
DEFINE CMPSKIPUI.L E000A15
|
||||
|
||||
# 0OPI Group
|
||||
DEFINE JUMP 3C00
|
||||
|
||||
# HALCODE Group
|
||||
DEFINE FOPEN_READ 42100000
|
||||
DEFINE FOPEN_WRITE 42100001
|
||||
DEFINE FCLOSE 42100002
|
||||
DEFINE REWIND 42100003
|
||||
DEFINE FSEEK 42100004
|
||||
DEFINE FGETC 42100100
|
||||
DEFINE FPUTC 42100200
|
||||
DEFINE HAL_MEM 42110000
|
||||
|
||||
# 0OP Group
|
||||
DEFINE NOP 00000000
|
||||
DEFINE HALT FFFFFFFF
|
|
@ -0,0 +1,34 @@
|
|||
## 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
|
||||
;; Prep TAPE_02
|
||||
LOADUI R0 0x1101
|
||||
FOPEN_WRITE
|
||||
|
||||
;; Prep TAPE_01
|
||||
LOADUI R0 0x1100
|
||||
FOPEN_READ
|
||||
|
||||
LOADR32 R12 @HEAP ; Setup HEAP pointer
|
||||
LOADUI R15 $STACK ; Setup initial stack pointer
|
||||
COPY R14 R15 ; Setup initial base pointer
|
||||
CALLI R15 @FUNCTION_main ; Go to main
|
||||
HALT ; Exit to kernel
|
||||
|
||||
;; Our default heap pointer
|
||||
:HEAP
|
||||
'00100000'
|
|
@ -0,0 +1,26 @@
|
|||
## 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
|
||||
LOADR32 R12 @HEAP ; Setup HEAP pointer
|
||||
LOADUI R15 $STACK ; Setup initial stack pointer
|
||||
COPY R14 R15 ; Setup initial base pointer
|
||||
CALLI R15 @FUNCTION_main ; Go to main
|
||||
HALT ; Exit to kernel
|
||||
|
||||
;; Our default heap pointer
|
||||
:HEAP
|
||||
'00100000'
|
|
@ -1,46 +1,63 @@
|
|||
e4482d2133772d1d9a00d30a8f46fee405a20b2354414fc735cbed077be7b61b test/results/test00-amd64-binary
|
||||
c35f3652100b9d0f46df4dcf00f7feb011993512d1cf48fb45e8ada057718b33 test/results/test00-armv7l-binary
|
||||
9b12e9ba86d56bf6e6f5a7e8513b244399755198d8028cbef4132ad0cf7336c1 test/results/test00-knight-native-binary
|
||||
64879eebceb475f21e54cb1f2e872996ca80e8c1fbb8b5895fb5fb6bac0c4384 test/results/test00-knight-posix-binary
|
||||
c52562bd0aabb86ce8ca177f22f8d0455769b444df2d4d62894faab63b7151d8 test/results/test00-x86-binary
|
||||
2c968b3736b6f2828982bad905018bfc4f159d7871e825f86a8f50b55b90b143 test/results/test01-amd64-binary
|
||||
579acd2d038e842bfe3ac56af2ad096d91a94c5a0f3d844b1dcc8ef380707eb7 test/results/test01-armv7l-binary
|
||||
eab60d537e8418af8b64af4b1d1a5711085fb8f668403ce93de4393584e0edea test/results/test01-knight-native-binary
|
||||
486ee05ccea796a9cfa9bfb23189b8e014b7ce8d14fea03b27d679d410fe17dd test/results/test01-knight-posix-binary
|
||||
eae96857f2b6d8e8ba86ac06e72345ea572622b358b23978bb5f2db1baadf41c test/results/test01-x86-binary
|
||||
d6158a185d9b3837a7bfa31c6d5d8d60eb1419c6b47c20139050b1fa9924a868 test/results/test02-amd64-binary
|
||||
63a79206ff41068e8cc585e535717a4f6a80506137891ee3905daf473bfc6420 test/results/test02-armv7l-binary
|
||||
bbcc2a7a785a29bcd36d26242afbc907d449346bce6e21634837d1f2ce31b7f9 test/results/test02-knight-native-binary
|
||||
e6493845b9e94a617649638252f23502f9212de583fd00cba6cc07fffd296e32 test/results/test02-knight-posix-binary
|
||||
8ead336d2f3f72d5874230492e0472edec61d355905e8636e3dfb2731695037c test/results/test02-x86-binary
|
||||
58e95f5eb581d8202c941809d8b162da1ffeda714af7d36699f330dc5c276880 test/results/test03-armv7l-binary
|
||||
18b906ce8866aea1e8464dbeb6eb118b28cfeb272896b20d1de1d7d69980a69c test/results/test03-knight-native-binary
|
||||
96849d5a9294799a9648c24db21b2dab1555dd5ba69d172d77df800622347226 test/results/test03-knight-posix-binary
|
||||
2313cb3f1a2b9eb6bf15f8d43418e15d6c16f7f1b5c22700fdfc2b38beb59192 test/results/test03-x86-binary
|
||||
69997b16f41de2ace669e6e331efbae4ad8da3483262476d7a490a450fe082ad test/results/test04-armv7l-binary
|
||||
9ce8ab26d1db3aad3d449d33dd012e1875acc2e8138911d24adda1a667db8deb test/results/test04-knight-native-binary
|
||||
df9ba08dfa69ac6cbb4483146dbbe079ef575d7de8318e2e52283151ebf24bd3 test/results/test04-knight-posix-binary
|
||||
b7ddb37063c541c6a315809c4438aa235d6702f54bb64f4ffc88dbe78617de81 test/results/test04-x86-binary
|
||||
f84660128cf57c135f5f163b3558527abd962e202bcc588abd13230862a287e1 test/results/test05-armv7l-binary
|
||||
0922872b8bf9baf032a378dcc2aa4aecf45ce94dcbf476ef443f145106888293 test/results/test05-knight-native-binary
|
||||
5db3a2fbd84150dae41e1c778f2822d053a0539cbdf59bba56e5514222f46674 test/results/test05-knight-posix-binary
|
||||
90321c43b2384050e5f03e5af67d345b55dd8a43e96d1f3b7f29d3c5dae3f077 test/results/test05-x86-binary
|
||||
e09cccfc8f46004f12a28cfca4f07835a895dfc5567e12759d19b57d63e1baaa test/results/test06-armv7l-binary
|
||||
6f1f99bdcde87e3674a4defd03f094b762a089c771ae91c33c401a0480091bff test/results/test06-knight-native-binary
|
||||
b177d769ae44c3509d9a08d0ee631ec69654dc5d723408bf0decdc67c42aae27 test/results/test06-knight-posix-binary
|
||||
663fc6eefe965f237b6bf5a211398c8ae1210f97ff39b59603677e92462c68c7 test/results/test06-x86-binary
|
||||
512e3d774b1d96808f046c01a6b08e818945056939515668530a2e17ea0ea6db test/results/test07-armv7l-binary
|
||||
d47fc54b2d577857ab15b3a571e7138fd60e80471066df524cff5313fd31b712 test/results/test07-knight-native-binary
|
||||
9159c4ba8196b24ec78bc9ebfbc7066d510ddbf03461736e7795a48634134dc5 test/results/test07-knight-posix-binary
|
||||
a9a3e332d13ded5f80d7431f8717f26527b3722b33ea57760a9a5723dffc099c test/results/test07-x86-binary
|
||||
8537995c4da57dae51a19f0845f4a57c682e67a9e7101352d5980ff06a5b2847 test/results/test08-armv7l-binary
|
||||
3a1de0143bfe2302ab0f7da189a0a14c285efebf7c16d7ea0177751c9e3b2175 test/results/test08-knight-native-binary
|
||||
b824859fd0e39f1417742a1b9a1cec18ade78afdd80ce2c64cb54cdf7683f53a test/results/test08-knight-posix-binary
|
||||
f1c01feb865c4d552033186d9ce50dd39468a7e8aebf762886c13ad3e03b5011 test/results/test08-x86-binary
|
||||
81cae9bfb57c727bcb16b59d81d9d588e84350b75a20170afa06e3d269029b87 test/results/test09-armv7l-binary
|
||||
b40d198af6c31f1af513ec70c6be9c6daa43cccf48a7191f4d984f81cdfbf623 test/results/test09-knight-native-binary
|
||||
0feaacc13ad24c2b513fd9d46a58c38b1af57e77275c9a148cafb4a0d3cc7b7a test/results/test09-knight-posix-binary
|
||||
9e4a0a6216bb4fde5dcefac91fd7c623e9e00b3e762946e5a47a1b50b4656103 test/results/test09-x86-binary
|
||||
5df859c88e9cbb2758f823e020d9993d50ba81fae20d469c03ec2b196d55f580 test/results/test10-armv7l-binary
|
||||
1154f39f25dcd6d914e9a542306f95280926baf985d011b2152c7ea0b87ab42d test/results/test10-knight-native-binary
|
||||
c1b5a2a3cd46c5e95e5540e871c2a916e028684ca80f51c001ef489342e27625 test/results/test10-knight-posix-binary
|
||||
020e86020819cc4963e6185b22e534fcf8306b6cb116f12643f254a24688ff0a test/results/test10-x86-binary
|
||||
8a6b78ae5fbd46610220a5e012e89ca3478b1ca20039bc81bc5f691f76779f36 test/results/test100-armv7l-binary
|
||||
1c64ac9e453c8404bc4c9024ded0f39092412e211ac55e4d582f177d06485f52 test/results/test100-knight-posix-binary
|
||||
336775a3418558370732c4c17ceb149512d6b8ee6dbf7225485f190b7e416eac test/results/test100-x86-binary
|
||||
ddf6194da431d9cd7fee7e1daef805d6070582160a7ca9246a69ee7acba4c2e7 test/results/test100-armv7l-binary
|
||||
46310bf40574fbc3d9474de0bc6f63e83072d39825997de697f4ba5a9a9a139c test/results/test100-knight-posix-binary
|
||||
ad3d2b2d8893bec961b28d249f38766c76a6edaead66acd2b04833631e992ad4 test/results/test100-x86-binary
|
||||
d9d465340abbce2d5964a6bc58e6cdd0ef93fb3d0199eaa823c86ec6abd0452a test/results/test11-armv7l-binary
|
||||
955b564d2c89abf2cfc6c80d766cd11479d146b828dec69e654b0958a62d5e6e test/results/test11-knight-native-binary
|
||||
63fd5fbf389d1b19031026df193ec55e98d923b8568007125b80bc246c094496 test/results/test11-knight-posix-binary
|
||||
3fd11bad4a426ce1ff8fd9c6d7d2b943effae9f3f5740b7376e426e9b0555851 test/results/test11-x86-binary
|
||||
fa46dd13a783d7531394603946c9e8784a9a9890b7e6cbfdd1f0b3dfb529017b test/results/test12-armv7l-binary
|
||||
21848cdee9c6f063c295680ae48f7a7677fe783f4892ece00c7504e8441b4c5b test/results/test12-knight-native-binary
|
||||
313536f9209d29d4c3b40f6ada898f81c1fb3b650ca1a84754f90b1db3b9e001 test/results/test12-knight-posix-binary
|
||||
f98ab8e4bb35580e0dde96126d7a56aff66bda208d02c8d89390b40d6cff591c test/results/test12-x86-binary
|
||||
8717f4034922836e75c9924edd48f9890a900cdadd322b2fd5949f64544d68c1 test/results/test13-armv7l-binary
|
||||
9d8c4ee9d5c8cad031880f1e15dcb419108e7cb2933c30622afabb8335c85641 test/results/test13-knight-native-binary
|
||||
e50c97ba330823cb5cbe938bb9d1575340b083e60fc42db8edefcfd95851daa2 test/results/test13-knight-posix-binary
|
||||
5051ffca2615144419f8ec1a5d4999486ae81e7781428f59e47e866af97cef92 test/results/test13-x86-binary
|
||||
c447dc62f437bdb045cb260d5965551e805de7ad4c09cc006229543cc9824530 test/results/test14-armv7l-binary
|
||||
|
@ -53,15 +70,18 @@ f24c62fb54b9ab510ce1b3a36d119e3b5d2ed56e33564c83782d828eac6a6773 test/results/t
|
|||
84f5472ce5711b9cad28fcd4c177eea673047c2561ea010ccb6bf5f50d89c713 test/results/test16-knight-posix-binary
|
||||
aeb94a4142633f20d7be4f8e74f0d5edc9050afb76f49cb504a1c264bf1ef96b test/results/test16-x86-binary
|
||||
aae309ad68840fbc1685412c4fe42bb54bb9caf20a92b3251cfa4749c8698a0b test/results/test17-armv7l-binary
|
||||
537f6885bf76a95ad322b4dc416d7de0bb73b5bbfc3bc2a9ea096e240b4081b8 test/results/test17-knight-native-binary
|
||||
0323ae8fa9e79cae9a58eec89a80b2c354db276d76c6f50b3bf50840327d4950 test/results/test17-knight-posix-binary
|
||||
403800bf92af0ca94563b0e1bdeceb355b805994bc6cbbd5691b37e8ade225da test/results/test17-x86-binary
|
||||
122d78f9943f3678a07a9ec82b491e041664b31931ac5056c8a238eb0753e879 test/results/test18-armv7l-binary
|
||||
4da569a63039551da7dc2f8fd1505d7c1661ec1765aae301071ac0c24c2064c3 test/results/test18-knight-native-binary
|
||||
d0f0b1428c8db70806d6e2e5b81aca4b6752c4a581a3fa83da064317ceb605b0 test/results/test18-knight-posix-binary
|
||||
8de7384c4633b1d5c60bbbb298d7f4b738e52fbc266ef4ef9a48b3cb995e3176 test/results/test18-x86-binary
|
||||
4e3f590623e2baae4c42e68b6f8f35d9731e4d5a64bbe5112780b8382225f916 test/results/test19-armv7l-binary
|
||||
32ba6ae74a8756fe4b95c65a643513bdd785778f98a878b3ea5459b5aaccaa38 test/results/test19-knight-posix-binary
|
||||
5706ee8a2228a04d22e4fa09523c6f27de6289c39e88f1dd9b773257f19acd24 test/results/test19-x86-binary
|
||||
ef9d0050388ab15454b437bc40c19737cda9211cb3704a0b2619fae232239d7f test/results/test20-armv7l-binary
|
||||
7ae1ba10ff6b6bf34148945ee44b9461aa6d1a16094e77fdf34b76e9a360a5b2 test/results/test20-knight-native-binary
|
||||
6a59795dbb4397d0efaf1ad613d646ec435eec62db30eb758bcf2499d651520e test/results/test20-knight-posix-binary
|
||||
365c96fb8368710d620a76facd6bebcdeeb6f6d30ceaf0a6f1567fc3fcbe9b54 test/results/test20-x86-binary
|
||||
737b2262e54035b5cac20fc43013956a0c4fd144c6b40ffc546ee05a6133922f test/results/test21-armv7l-binary
|
||||
|
@ -81,5 +101,6 @@ ef17edf7febc6da5f1cda6b8c367010ff9fd446df8edcfdaf9570ab4fcc63a7c test/results/t
|
|||
70480a64dc02b0ef9275c1d69ca61712cc0c649f57dd63a019cb2359dc24f07b test/results/test26-armv7l-binary
|
||||
d69771c515c55d11549e18c5b15c3772e101416c9390bda43d283a3b3938c4ad test/results/test26-x86-binary
|
||||
4cd7628090622b165d2c2d1d4c089476a6d661d494e2fadb1ad9b0906585cd75 test/results/test99-armv7l-binary
|
||||
eaca2f7f70b75b7503ee040bebd0dc0fa961a25597622356f70faadec759d696 test/results/test99-knight-native-binary
|
||||
bea554c06c8ecdb9eaae2c586a2006487968625b9570cbe305f69959c0e680e7 test/results/test99-knight-posix-binary
|
||||
23c98b1c7fb90eb850e26895033a243aa1a10c2420418ecd03a5364f347d8872 test/results/test99-x86-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 amd64 -f test/test00/return.c \
|
||||
-o test/test00/return.M1 || exit 1
|
||||
|
||||
# Macro assemble with libc written in M1-Macro
|
||||
M1 -f test/common_amd64/amd64_defs.M1 \
|
||||
-f test/common_amd64/libc-core.M1 \
|
||||
-f test/test00/return.M1 \
|
||||
--LittleEndian \
|
||||
--architecture amd64 \
|
||||
-o test/test00/return.hex2 || exit 2
|
||||
|
||||
# Resolve all linkages
|
||||
hex2 -f test/common_amd64/ELF-amd64.hex2 -f test/test00/return.hex2 --LittleEndian --architecture amd64 --BaseAddress 0x00600000 -o test/results/test00-amd64-binary --exec_enable || exit 3
|
||||
|
||||
# Ensure binary works if host machine supports test
|
||||
if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "amd64" ]
|
||||
then
|
||||
# Verify that the compiled program returns the correct result
|
||||
./test/results/test00-amd64-binary
|
||||
[ 42 = $? ] || exit 3
|
||||
fi
|
||||
exit 0
|
|
@ -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 knight-native -f test/test00/return.c \
|
||||
-o test/test00/return.M1 || exit 1
|
||||
|
||||
# Macro assemble with libc written in M1-Macro
|
||||
M1 -f test/common_knight/knight-native_defs.M1 \
|
||||
-f test/common_knight/libc-native.M1 \
|
||||
-f test/test00/return.M1 \
|
||||
--BigEndian \
|
||||
--architecture knight-native \
|
||||
-o test/test00/return.hex2 || exit 2
|
||||
|
||||
# Resolve all linkages
|
||||
hex2 -f test/test00/return.hex2 --BigEndian --architecture knight-native --BaseAddress 0x0 -o test/results/test00-knight-native-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
|
||||
./test/results/test00-knight-native-binary
|
||||
[ 42 = $? ] || exit 3
|
||||
fi
|
||||
exit 0
|
|
@ -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 -x
|
||||
# Build the test
|
||||
bin/M2-Planet --architecture amd64 -f test/common_amd64/functions/putchar.c \
|
||||
-f test/common_amd64/functions/exit.c \
|
||||
-f test/test01/library_call.c \
|
||||
-o test/test01/library_call.M1 || exit 1
|
||||
|
||||
# Macro assemble with libc written in M1-Macro
|
||||
M1 -f test/common_amd64/amd64_defs.M1 \
|
||||
-f test/common_amd64/libc-core.M1 \
|
||||
-f test/test01/library_call.M1 \
|
||||
--LittleEndian \
|
||||
--architecture amd64 \
|
||||
-o test/test01/library_call.hex2 || exit 2
|
||||
|
||||
# Resolve all linkages
|
||||
hex2 -f test/common_amd64/ELF-amd64.hex2 -f test/test01/library_call.hex2 --LittleEndian --architecture amd64 --BaseAddress 0x00600000 -o test/results/test01-amd64-binary --exec_enable || exit 3
|
||||
|
||||
# Ensure binary works if host machine supports test
|
||||
if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "amd64" ]
|
||||
then
|
||||
# Verify that the compiled program returns the correct result
|
||||
out=$(./test/results/test01-amd64-binary 2>&1)
|
||||
[ 42 = $? ] || exit 3
|
||||
[ "$out" = "Hello mes" ] || exit 4
|
||||
fi
|
||||
exit 0
|
|
@ -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 -x
|
||||
# Build the test
|
||||
bin/M2-Planet --architecture knight-native -f test/common_knight/functions/putchar-native.c \
|
||||
-f test/common_knight/functions/exit-native.c \
|
||||
-f test/test01/library_call.c \
|
||||
-o test/test01/library_call.M1 || exit 1
|
||||
|
||||
# Macro assemble with libc written in M1-Macro
|
||||
M1 -f test/common_knight/knight-native_defs.M1 \
|
||||
-f test/common_knight/libc-native.M1 \
|
||||
-f test/test01/library_call.M1 \
|
||||
--BigEndian \
|
||||
--architecture knight-native \
|
||||
-o test/test01/library_call.hex2 || exit 2
|
||||
|
||||
# Resolve all linkages
|
||||
hex2 -f test/test01/library_call.hex2 --BigEndian --architecture knight-native --BaseAddress 0x0 -o test/results/test01-knight-native-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/test01-knight-native-binary 2>&1)
|
||||
[ 42 = $? ] || exit 3
|
||||
[ "$out" = "Hello mes" ] || exit 4
|
||||
fi
|
||||
exit 0
|
|
@ -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 -x
|
||||
# Build the test
|
||||
bin/M2-Planet --architecture amd64 -f test/common_amd64/functions/putchar.c \
|
||||
-f test/common_amd64/functions/exit.c \
|
||||
-f test/test02/if.c \
|
||||
-o test/test02/if.M1 || exit 1
|
||||
|
||||
# Macro assemble with libc written in M1-Macro
|
||||
M1 -f test/common_amd64/amd64_defs.M1 \
|
||||
-f test/common_amd64/libc-core.M1 \
|
||||
-f test/test02/if.M1 \
|
||||
--LittleEndian \
|
||||
--architecture amd64 \
|
||||
-o test/test02/if.hex2 || exit 2
|
||||
|
||||
# Resolve all linkages
|
||||
hex2 -f test/common_amd64/ELF-amd64.hex2 -f test/test02/if.hex2 --LittleEndian --architecture amd64 --BaseAddress 0x00600000 -o test/results/test02-amd64-binary --exec_enable || exit 3
|
||||
|
||||
# Ensure binary works if host machine supports test
|
||||
if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "amd64" ]
|
||||
then
|
||||
# Verify that the compiled program returns the correct result
|
||||
out=$(./test/results/test02-amd64-binary 2>&1 )
|
||||
[ 42 = $? ] || exit 4
|
||||
[ "$out" = "Hello mes" ] || exit 5
|
||||
fi
|
||||
exit 0
|
|
@ -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 -x
|
||||
# Build the test
|
||||
bin/M2-Planet --architecture knight-native -f test/common_knight/functions/putchar-native.c \
|
||||
-f test/common_knight/functions/exit-native.c \
|
||||
-f test/test02/if.c \
|
||||
-o test/test02/if.M1 || exit 1
|
||||
|
||||
# Macro assemble with libc written in M1-Macro
|
||||
M1 -f test/common_knight/knight-native_defs.M1 \
|
||||
-f test/common_knight/libc-native.M1 \
|
||||
-f test/test02/if.M1 \
|
||||
--BigEndian \
|
||||
--architecture knight-native \
|
||||
-o test/test02/if.hex2 || exit 2
|
||||
|
||||
# Resolve all linkages
|
||||
hex2 -f test/test02/if.hex2 --BigEndian --architecture knight-native --BaseAddress 0x00 -o test/results/test02-knight-native-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/test02-knight-native-binary 2>&1 )
|
||||
[ 42 = $? ] || exit 4
|
||||
[ "$out" = "Hello mes" ] || exit 5
|
||||
fi
|
||||
exit 0
|
|
@ -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 -x
|
||||
# Build the test
|
||||
bin/M2-Planet --architecture knight-native -f test/common_knight/functions/putchar-native.c \
|
||||
-f test/common_knight/functions/exit-native.c \
|
||||
-f test/test03/constant.c \
|
||||
-o test/test03/constant.M1 || exit 1
|
||||
|
||||
# Macro assemble with libc written in M1-Macro
|
||||
M1 -f test/common_knight/knight-native_defs.M1 \
|
||||
-f test/common_knight/libc-native.M1 \
|
||||
-f test/test03/constant.M1 \
|
||||
--BigEndian \
|
||||
--architecture knight-native \
|
||||
-o test/test03/constant.hex2 || exit 2
|
||||
|
||||
# Resolve all linkages
|
||||
hex2 -f test/test03/constant.hex2 --BigEndian --architecture knight-native --BaseAddress 0x00 -o test/results/test03-knight-native-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/test03-knight-native-binary 2>&1 )
|
||||
[ 42 = $? ] || exit 4
|
||||
[ "$out" = "Hello mes" ] || exit 5
|
||||
fi
|
||||
exit 0
|
|
@ -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 -x
|
||||
# Build the test
|
||||
bin/M2-Planet --architecture knight-native -f test/common_knight/functions/putchar-native.c \
|
||||
-f test/common_knight/functions/exit-native.c \
|
||||
-f test/test04/call.c \
|
||||
-o test/test04/call.M1 || exit 1
|
||||
|
||||
# Macro assemble with libc written in M1-Macro
|
||||
M1 -f test/common_knight/knight-native_defs.M1 \
|
||||
-f test/common_knight/libc-native.M1 \
|
||||
-f test/test04/call.M1 \
|
||||
--BigEndian \
|
||||
--architecture knight-native \
|
||||
-o test/test04/call.hex2 || exit 2
|
||||
|
||||
# Resolve all linkages
|
||||
hex2 -f test/test04/call.hex2 --BigEndian --architecture knight-native --BaseAddress 0x00 -o test/results/test04-knight-native-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/test04-knight-native-binary 2>&1 )
|
||||
[ 42 = $? ] || exit 4
|
||||
[ "$out" = "Hello mes" ] || exit 5
|
||||
fi
|
||||
exit 0
|
|
@ -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 -x
|
||||
# Build the test
|
||||
bin/M2-Planet --architecture knight-native -f test/common_knight/functions/putchar-native.c \
|
||||
-f test/common_knight/functions/exit-native.c \
|
||||
-f test/test05/string.c \
|
||||
-o test/test05/string.M1 || exit 1
|
||||
|
||||
# Macro assemble with libc written in M1-Macro
|
||||
M1 -f test/common_knight/knight-native_defs.M1 \
|
||||
-f test/common_knight/libc-native.M1 \
|
||||
-f test/test05/string.M1 \
|
||||
--BigEndian \
|
||||
--architecture knight-native \
|
||||
-o test/test05/string.hex2 || exit 2
|
||||
|
||||
# Resolve all linkages
|
||||
hex2 -f test/test05/string.hex2 --BigEndian --architecture knight-native --BaseAddress 0x00 -o test/results/test05-knight-native-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/test05-knight-native-binary 2>&1 )
|
||||
[ 42 = $? ] || exit 4
|
||||
[ "$out" = "Hello mes" ] || exit 5
|
||||
fi
|
||||
exit 0
|
|
@ -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-native -f test/common_knight/functions/putchar-native.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-native_defs.M1 \
|
||||
-f test/common_knight/libc-native.M1 \
|
||||
-f test/test06/for.M1 \
|
||||
--BigEndian \
|
||||
--architecture knight-native \
|
||||
-o test/test06/for.hex2 || exit 2
|
||||
|
||||
# Resolve all linkages
|
||||
hex2 -f test/test06/for.hex2 --BigEndian --architecture knight-native --BaseAddress 0x00 -o test/results/test06-knight-native-binary --exec_enable || exit 3
|
||||
|
||||
# Ensure binary works if host machine supports test
|
||||
if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "knight" ]
|
||||
then
|
||||
. ./sha256.sh
|
||||
# Verify that the resulting file works
|
||||
./test/results/test06-knight-native-binary >| test/test06/proof || exit 4
|
||||
out=$(sha256_check test/test06/proof.answer)
|
||||
[ "$out" = "test/test06/proof: OK" ] || exit 5
|
||||
fi
|
||||
exit 0
|
|
@ -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 knight-native -f test/common_knight/functions/putchar-native.c \
|
||||
-f test/common_knight/functions/exit-native.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-native_defs.M1 \
|
||||
-f test/common_knight/libc-native.M1 \
|
||||
-f test/test07/do.M1 \
|
||||
--BigEndian \
|
||||
--architecture knight-native \
|
||||
-o test/test07/do.hex2 || exit 2
|
||||
|
||||
# Resolve all linkages
|
||||
hex2 -f test/test07/do.hex2 --BigEndian --architecture knight-native --BaseAddress 0x00 -o test/results/test07-knight-native-binary --exec_enable || exit 3
|
||||
|
||||
# Ensure binary works if host machine supports test
|
||||
if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "knight" ]
|
||||
then
|
||||
. ./sha256.sh
|
||||
# Verify that the resulting file works
|
||||
./test/results/test07-knight-native-binary >| test/test07/proof || exit 4
|
||||
out=$(sha256_check test/test07/proof.answer)
|
||||
[ "$out" = "test/test07/proof: OK" ] || exit 5
|
||||
fi
|
||||
exit 0
|
|
@ -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-native -f test/common_knight/functions/putchar-native.c \
|
||||
-f test/common_knight/functions/exit-native.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-native_defs.M1 \
|
||||
-f test/common_knight/libc-native.M1 \
|
||||
-f test/test08/struct.M1 \
|
||||
--BigEndian \
|
||||
--architecture knight-native \
|
||||
-o test/test08/struct.hex2 || exit 2
|
||||
|
||||
# Resolve all linkages
|
||||
hex2 -f test/test08/struct.hex2 --BigEndian --architecture knight-native --BaseAddress 0x00 -o test/results/test08-knight-native-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-native-binary 2>&1 )
|
||||
[ 16 = $? ] || exit 4
|
||||
[ "$out" = "35419896642975313541989657891634" ] || exit 5
|
||||
fi
|
||||
exit 0
|
|
@ -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 -x
|
||||
# Build the test
|
||||
bin/M2-Planet --architecture knight-native -f test/common_knight/functions/putchar-native.c \
|
||||
-f test/common_knight/functions/exit-native.c \
|
||||
-f test/test09/goto.c \
|
||||
-o test/test09/goto.M1 || exit 1
|
||||
|
||||
# Macro assemble with libc written in M1-Macro
|
||||
M1 -f test/common_knight/knight-native_defs.M1 \
|
||||
-f test/common_knight/libc-native.M1 \
|
||||
-f test/test09/goto.M1 \
|
||||
--BigEndian \
|
||||
--architecture knight-native \
|
||||
-o test/test09/goto.hex2 || exit 2
|
||||
|
||||
# Resolve all linkages
|
||||
hex2 -f test/test09/goto.hex2 --BigEndian --architecture knight-native --BaseAddress 0x00 -o test/results/test09-knight-native-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/test09-knight-native-binary 2>&1 )
|
||||
[ 42 = $? ] || exit 4
|
||||
[ "$out" = "Hello mes" ] || exit 5
|
||||
fi
|
||||
exit 0
|
|
@ -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-native -f test/common_knight/functions/putchar-native.c \
|
||||
-f test/common_knight/functions/exit-native.c \
|
||||
-f test/common_knight/functions/malloc.c \
|
||||
-f test/test10/nested_struct.c \
|
||||
-o test/test10/nested_struct.M1 || exit 1
|
||||
|
||||
# Macro assemble with libc written in M1-Macro
|
||||
M1 -f test/common_knight/knight-native_defs.M1 \
|
||||
-f test/common_knight/libc-native.M1 \
|
||||
-f test/test10/nested_struct.M1 \
|
||||
--BigEndian \
|
||||
--architecture knight-native \
|
||||
-o test/test10/nested_struct.hex2 || exit 2
|
||||
|
||||
# Resolve all linkages
|
||||
hex2 -f test/test10/nested_struct.hex2 --BigEndian --architecture knight-native --BaseAddress 0x00 -o test/results/test10-knight-native-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/test10-knight-native-binary 2>&1 )
|
||||
[ 12 = $? ] || exit 4
|
||||
[ "$out" = "35419896642975313541989657891634" ] || exit 5
|
||||
fi
|
||||
exit 0
|
|
@ -1 +1 @@
|
|||
b4c27994226f259c5fe2189915727eada317c941d010604db23e6b3ef7342084 test/test100/proof
|
||||
fa938b90d4dc96f81285c982432d444255e7958adf26eb5e621c5ce232bd01ab test/test100/proof
|
||||
|
|
|
@ -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 knight-native -f test/common_knight/functions/putchar-native.c \
|
||||
-f test/common_knight/functions/exit-native.c \
|
||||
-f test/test11/break-do.c \
|
||||
-o test/test11/break-do.M1 || exit 1
|
||||
|
||||
# Macro assemble with libc written in M1-Macro
|
||||
M1 -f test/common_knight/knight-native_defs.M1 \
|
||||
-f test/common_knight/libc-native.M1 \
|
||||
-f test/test11/break-do.M1 \
|
||||
--BigEndian \
|
||||
--architecture knight-native \
|
||||
-o test/test11/break-do.hex2 || exit 2
|
||||
|
||||
# Resolve all linkages
|
||||
hex2 -f test/test11/break-do.hex2 --BigEndian --architecture knight-native --BaseAddress 0x00 -o test/results/test11-knight-native-binary --exec_enable || exit 3
|
||||
|
||||
# Ensure binary works if host machine supports test
|
||||
if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "knight*" ]
|
||||
then
|
||||
. ./sha256.sh
|
||||
# Verify that the resulting file works
|
||||
./test/results/test11-knight-native-binary >| test/test11/proof || exit 4
|
||||
out=$(sha256_check test/test11/proof.answer)
|
||||
[ "$out" = "test/test11/proof: OK" ] || exit 5
|
||||
fi
|
||||
exit 0
|
|
@ -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 knight-native -f test/common_knight/functions/putchar-native.c \
|
||||
-f test/common_knight/functions/exit-native.c \
|
||||
-f test/test12/break-for.c \
|
||||
-o test/test12/break-for.M1 || exit 1
|
||||
|
||||
# Macro assemble with libc written in M1-Macro
|
||||
M1 -f test/common_knight/knight-native_defs.M1 \
|
||||
-f test/common_knight/libc-native.M1 \
|
||||
-f test/test12/break-for.M1 \
|
||||
--BigEndian \
|
||||
--architecture knight-native \
|
||||
-o test/test12/break-for.hex2 || exit 2
|
||||
|
||||
# Resolve all linkages
|
||||
hex2 -f test/test12/break-for.hex2 --BigEndian --architecture knight-native --BaseAddress 0x00 -o test/results/test12-knight-native-binary --exec_enable || exit 3
|
||||
|
||||
# Ensure binary works if host machine supports test
|
||||
if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "knight*" ]
|
||||
then
|
||||
. ./sha256.sh
|
||||
# Verify that the resulting file works
|
||||
./test/results/test12-knight-native-binary >| test/test12/proof || exit 4
|
||||
out=$(sha256_check test/test12/proof.answer)
|
||||
[ "$out" = "test/test12/proof: OK" ] || exit 5
|
||||
fi
|
||||
exit 0
|
|
@ -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 knight-native -f test/common_knight/functions/putchar-native.c \
|
||||
-f test/common_knight/functions/exit-native.c \
|
||||
-f test/test13/break-while.c \
|
||||
-o test/test13/break-while.M1 || exit 1
|
||||
|
||||
# Macro assemble with libc written in M1-Macro
|
||||
M1 -f test/common_knight/knight-native_defs.M1 \
|
||||
-f test/common_knight/libc-native.M1 \
|
||||
-f test/test13/break-while.M1 \
|
||||
--BigEndian \
|
||||
--architecture knight-native \
|
||||
-o test/test13/break-while.hex2 || exit 2
|
||||
|
||||
# Resolve all linkages
|
||||
hex2 -f test/test13/break-while.hex2 --BigEndian --architecture knight-native --BaseAddress 0x00 -o test/results/test13-knight-native-binary --exec_enable || exit 3
|
||||
|
||||
# Ensure binary works if host machine supports test
|
||||
if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "knight*" ]
|
||||
then
|
||||
. ./sha256.sh
|
||||
# Verify that the resulting file works
|
||||
./test/results/test13-kight-posix-binary >| test/test13/proof || exit 4
|
||||
out=$(sha256_check test/test13/proof.answer)
|
||||
[ "$out" = "test/test13/proof: OK" ] || exit 5
|
||||
fi
|
||||
exit 0
|
|
@ -0,0 +1,46 @@
|
|||
#! /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-native -f test/common_knight/functions/malloc.c \
|
||||
-f functions/calloc.c \
|
||||
-f test/common_knight/functions/putchar-native.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_knight/knight-native_defs.M1 \
|
||||
-f test/common_knight/libc-native.M1 \
|
||||
-f test/test17/memset.M1 \
|
||||
--BigEndian \
|
||||
--architecture knight-native \
|
||||
-o test/test17/memset.hex2 || exit 2
|
||||
|
||||
# Resolve all linkages
|
||||
hex2 -f test/test17/memset.hex2 --BigEndian --architecture knight-native --BaseAddress 0x00 -o test/results/test17-knight-native-binary --exec_enable || exit 3
|
||||
|
||||
# Ensure binary works if host machine supports test
|
||||
if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "knight*" ]
|
||||
then
|
||||
. ./sha256.sh
|
||||
# Verify that the resulting file works
|
||||
./test/results/test17-knight-native-binary >| test/test17/proof || exit 4
|
||||
out=$(sha256_check test/test17/proof.answer)
|
||||
[ "$out" = "test/test17/proof: OK" ] || exit 5
|
||||
fi
|
||||
exit 0
|
|
@ -0,0 +1,46 @@
|
|||
#! /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-native -f test/common_knight/functions/file-native.c \
|
||||
-f test/common_knight/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_knight/knight-native_defs.M1 \
|
||||
-f test/common_knight/libc-native-file.M1 \
|
||||
-f test/test18/math.M1 \
|
||||
--BigEndian \
|
||||
--architecture knight-native \
|
||||
-o test/test18/math.hex2 || exit 2
|
||||
|
||||
# Resolve all linkages
|
||||
hex2 -f test/test18/math.hex2 --BigEndian --architecture knight-native --BaseAddress 0x00 -o test/results/test18-knight-native-binary --exec_enable || exit 3
|
||||
|
||||
# Ensure binary works if host machine supports test
|
||||
if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "knight*" ]
|
||||
then
|
||||
. ./sha256.sh
|
||||
# Verify that the resulting file works
|
||||
./test/results/test18-knight-native-binary >| test/test18/proof || exit 4
|
||||
out=$(sha256_check test/test18/proof.answer)
|
||||
[ "$out" = "test/test18/proof: OK" ] || exit 5
|
||||
fi
|
||||
exit 0
|
|
@ -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-native -f test/common_knight/functions/putchar-native.c \
|
||||
-f test/common_knight/functions/exit-native.c \
|
||||
-f test/common_knight/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_knight/knight-native_defs.M1 \
|
||||
-f test/common_knight/libc-native.M1 \
|
||||
-f test/test20/struct.M1 \
|
||||
--BigEndian \
|
||||
--architecture knight-native \
|
||||
-o test/test20/struct.hex2 || exit 2
|
||||
|
||||
# Resolve all linkages
|
||||
hex2 -f test/test20/struct.hex2 --BigEndian --architecture knight-native --BaseAddress 0x00 -o test/results/test20-knight-native-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/test20-knight-native-binary 2>&1 )
|
||||
[ 20 = $? ] || exit 4
|
||||
[ "$out" = "35419896642975313541989657891634" ] || exit 5
|
||||
fi
|
||||
exit 0
|
|
@ -0,0 +1,48 @@
|
|||
#! /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-native \
|
||||
-f test/common_knight/functions/putchar-tape2.c \
|
||||
-f test/common_knight/functions/getchar-tape1.c \
|
||||
-f test/common_knight/functions/exit-native.c \
|
||||
-f test/common_knight/functions/malloc.c \
|
||||
-f test/test99/cc500.c \
|
||||
-o test/test99/cc0.M1 || exit 1
|
||||
|
||||
# Macro assemble with libc written in M1-Macro
|
||||
M1 -f test/common_knight/knight-native_defs.M1 \
|
||||
-f test/common_knight/libc-native-file.M1 \
|
||||
-f test/test99/cc0.M1 \
|
||||
--BigEndian \
|
||||
--architecture knight-native \
|
||||
-o test/test99/cc0.hex2 || exit 2
|
||||
|
||||
# Resolve all linkages
|
||||
hex2 -f test/test99/cc0.hex2 --BigEndian --architecture knight-native --BaseAddress 0x00 -o test/results/test99-knight-native-binary --exec_enable || exit 3
|
||||
|
||||
# Ensure binary works if host machine supports test
|
||||
if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "knight*" ]
|
||||
then
|
||||
. ./sha256.sh
|
||||
# Verify that the compiled program can compile itself
|
||||
./test/results/test99-binary < test/test99/cc500.c >| test/test99/cc1 || exit 4
|
||||
out=$(sha256_check test/test99/proof0.answer)
|
||||
[ "$out" = "test/test99/cc1: OK" ] || exit 5
|
||||
fi
|
||||
exit 0
|
Loading…
Reference in New Issue