Add assembly generation stage
This commit is contained in:
@@ -1109,10 +1109,10 @@ begin
|
||||
_write_s("\tbeqz", 5)
|
||||
elsif instruction_kind = ElnaTacOperator.start then
|
||||
argument_count := 0;
|
||||
_write_z("\taddi sp, sp, -128\n\tsw ra, 124(sp)\n\tsw s0, 120(sp)\n\taddi s0, sp, 128\0")
|
||||
_write_z("\taddi sp, sp, -144\n\tsw ra, 140(sp)\n\tsw s0, 136(sp)\n\taddi s0, sp, 144\0")
|
||||
elsif instruction_kind = ElnaTacOperator.ret then
|
||||
argument_count := 0;
|
||||
_write_z("\tlw ra, 124(sp)\n\tlw s0, 120(sp)\n\taddi sp, sp, 128\0")
|
||||
_write_z("\tlw ra, 140(sp)\n\tlw s0, 136(sp)\n\taddi sp, sp, 144\0")
|
||||
end;
|
||||
return argument_count
|
||||
end;
|
||||
@@ -1900,7 +1900,7 @@ begin
|
||||
first_instruction := _elna_tac_unary_expression(operand_node, symbol_table);
|
||||
|
||||
(* Save the value of the left expression on the stack. *)
|
||||
instruction := _elna_tac_store_word(ElnaTacRegister.t0, ElnaTacRegister.sp, 64);
|
||||
instruction := _elna_tac_store_word(ElnaTacRegister.t0, ElnaTacRegister.sp, 72);
|
||||
_elna_tac_instruction_set_next(first_instruction, instruction);
|
||||
current_instruction := instruction;
|
||||
|
||||
@@ -1910,7 +1910,7 @@ begin
|
||||
current_instruction := instruction;
|
||||
|
||||
(* Load the left expression from the stack; *)
|
||||
instruction := _elna_tac_load_word(ElnaTacRegister.t1, ElnaTacRegister.sp, 64);
|
||||
instruction := _elna_tac_load_word(ElnaTacRegister.t1, ElnaTacRegister.sp, 72);
|
||||
_elna_tac_instruction_set_next(current_instruction, instruction);
|
||||
current_instruction := instruction;
|
||||
|
||||
@@ -2088,7 +2088,7 @@ begin
|
||||
stack_offset := argument_count * 4;
|
||||
|
||||
instruction := _elna_tac_store_word(ElnaTacRegister.t0,
|
||||
ElnaTacRegister.sp, 116 - stack_offset);
|
||||
ElnaTacRegister.sp, 132 - stack_offset);
|
||||
_elna_tac_instruction_set_next(current_instruction, instruction);
|
||||
current_instruction := instruction;
|
||||
|
||||
@@ -2103,9 +2103,9 @@ begin
|
||||
argument_count := argument_count - 1;
|
||||
stack_offset := argument_count * 4;
|
||||
|
||||
(* Calculate the stack offset: 116 - (4 * argument_counter) *)
|
||||
(* Calculate the stack offset: 132 - (4 * argument_counter) *)
|
||||
instruction := _elna_tac_load_word(ElnaTacRegister.a0 + argument_count,
|
||||
ElnaTacRegister.sp, 116 - stack_offset);
|
||||
ElnaTacRegister.sp, 132 - stack_offset);
|
||||
_elna_tac_instruction_set_next(current_instruction, instruction);
|
||||
current_instruction := instruction;
|
||||
|
||||
@@ -2502,7 +2502,7 @@ begin
|
||||
first_instruction := _elna_tac_designator(current_expression, symbol_table, @is_address);
|
||||
|
||||
(* Save the assignee address on the stack. *)
|
||||
current_instruction := _elna_tac_store_word(ElnaTacRegister.t0, ElnaTacRegister.sp, 60);
|
||||
current_instruction := _elna_tac_store_word(ElnaTacRegister.t0, ElnaTacRegister.sp, 76);
|
||||
_elna_tac_instruction_set_next(first_instruction, current_instruction);
|
||||
|
||||
(* Compile the assignment. *)
|
||||
@@ -2510,7 +2510,7 @@ begin
|
||||
instruction := _elna_tac_binary_expression(current_expression, symbol_table);
|
||||
_elna_tac_instruction_set_next(current_instruction, instruction);
|
||||
|
||||
current_instruction := _elna_tac_load_word(ElnaTacRegister.t1, ElnaTacRegister.sp, 60);
|
||||
current_instruction := _elna_tac_load_word(ElnaTacRegister.t1, ElnaTacRegister.sp, 76);
|
||||
_elna_tac_instruction_set_next(instruction, current_instruction);
|
||||
|
||||
instruction := _elna_tac_store_word(ElnaTacRegister.t0, ElnaTacRegister.t1, 0);
|
||||
@@ -3415,9 +3415,9 @@ begin
|
||||
|
||||
current_word := current_word + 4;
|
||||
|
||||
(* Calculate the stack offset: 88 - (4 * parameter_counter) *)
|
||||
(* Calculate the stack offset: 104 - (4 * parameter_counter) *)
|
||||
offset := parameter_index * 4;
|
||||
current_word^ := 88 - offset;
|
||||
current_word^ := 104 - offset;
|
||||
|
||||
return result
|
||||
end;
|
||||
|
||||
1156
boot/stage16/cl.elna
1156
boot/stage16/cl.elna
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user