diff --git a/High_level_prototypes/defs b/High_level_prototypes/defs index d8b22e0..1d806fc 100644 --- a/High_level_prototypes/defs +++ b/High_level_prototypes/defs @@ -251,3 +251,6 @@ DEFINE HAL_MEM 42110000 # 0OP Group DEFINE NOP 00000000 DEFINE HALT FFFFFFFF + +# CC_* ops +DEFINE NULL 00000000 diff --git a/stage2/High_level_prototypes/cc_knight-native/cc_core.c b/stage2/High_level_prototypes/cc_knight-native/cc_core.c index f2c67fb..44ff2cd 100644 --- a/stage2/High_level_prototypes/cc_knight-native/cc_core.c +++ b/stage2/High_level_prototypes/cc_knight-native/cc_core.c @@ -147,9 +147,9 @@ void function_call(char* s, int bool) else { emit_out("MOVE R14 R13\n"); - emit_out("CALLI R15 @FUNCTION_"); + emit_out("LOADR R0 4\nJUMP 4\n&FUNCTION_"); emit_out(s); - emit_out("\n"); + emit_out("\nCALL R0 R15\n"); } for(; passed > 0; passed = passed - 1) @@ -193,7 +193,7 @@ void function_load(struct token_list* a) return; } - emit_out("LOADUI R0 $FUNCTION_"); + emit_out("LOADR R0 4\nJUMP 4\n&FUNCTION_"); emit_out(a->s); emit_out("\n"); } @@ -201,7 +201,7 @@ void function_load(struct token_list* a) void global_load(struct token_list* a) { current_target = a->type; - emit_out("LOADUI R0 $GLOBAL_"); + emit_out("LOADR R0 4\nJUMP 4\n&GLOBAL_"); emit_out(a->s); emit_out("\n"); if(!match("=", global_token->s)) emit_out("LOAD R0 R0 0\n"); @@ -230,7 +230,7 @@ void primary_expr_string() { char* number_string = numerate_number(current_count); current_count = current_count + 1; - emit_out("LOADUI R0 $STRING_"); + emit_out("LOADR R0 4\nJUMP 4\n&STRING_"); uniqueID_out(function->s, number_string); /* The target */ diff --git a/stage2/cc_knight-native.s b/stage2/cc_knight-native.s index 9bf68d9..0341c09 100644 --- a/stage2/cc_knight-native.s +++ b/stage2/cc_knight-native.s @@ -889,7 +889,9 @@ Missing ) RET R15 :function_load_string0 - "LOADUI R0 $FUNCTION_" + "LOADR R0 4 +JUMP 4 +&FUNCTION_" ;; global_load function @@ -923,7 +925,9 @@ Missing ) RET R15 :global_load_string0 - "LOADUI R0 $GLOBAL_" + "LOADR R0 4 +JUMP 4 +&GLOBAL_" :global_load_string1 "LOAD R0 R0 0 " @@ -1002,7 +1006,9 @@ Missing ) RET R15 :primary_expr_string_string0 - "LOADUI R0 $STRING_" + "LOADR R0 4 +JUMP 4 +&STRING_" :primary_expr_string_string1 ":STRING_" @@ -3415,7 +3421,7 @@ Missing ; CALLI R15 @emit_out ; emit it MOVE R0 R2 ; Using S CALLI R15 @emit_out ; emit it - LOADUI R0 $newline ; Using "\n" + LOADUI R0 $function_call_string16 ; The terminator CALLI R15 @emit_out ; emit it :function_call_call_done @@ -3478,7 +3484,9 @@ No ) was found "MOVE R14 R13 " :function_call_string12 - "CALLI R15 @FUNCTION_" + "LOADR R0 4 +JUMP 4 +&FUNCTION_" :function_call_string13 "POPR R1 R15 # _process_expression_locals " @@ -3488,6 +3496,10 @@ No ) was found :function_call_string15 "POPR R13 R15 # Prevent overwrite " +:function_call_string16 + " +CALL R0 R15 +" ;; emit function