Skip to content

Commit

Permalink
Change knight-native to be support large binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
oriansj committed Feb 1, 2020
1 parent f443b62 commit 41f99a9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
3 changes: 3 additions & 0 deletions High_level_prototypes/defs
Original file line number Diff line number Diff line change
Expand Up @@ -251,3 +251,6 @@ DEFINE HAL_MEM 42110000
# 0OP Group
DEFINE NOP 00000000
DEFINE HALT FFFFFFFF

# CC_* ops
DEFINE NULL 00000000
10 changes: 5 additions & 5 deletions stage2/High_level_prototypes/cc_knight-native/cc_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -193,15 +193,15 @@ 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");
}

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");
Expand Down Expand Up @@ -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 */
Expand Down
22 changes: 17 additions & 5 deletions stage2/cc_knight-native.s
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,9 @@ Missing )
RET R15

:function_load_string0
"LOADUI R0 $FUNCTION_"
"LOADR R0 4
JUMP 4
&FUNCTION_"


;; global_load function
Expand Down Expand Up @@ -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
"
Expand Down Expand Up @@ -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_"

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
"
Expand All @@ -3488,6 +3496,10 @@ No ) was found
:function_call_string15
"POPR R13 R15 # Prevent overwrite
"
:function_call_string16
"
CALL R0 R15
"


;; emit function
Expand Down

0 comments on commit 41f99a9

Please sign in to comment.