Commit be4bba3b authored by Daru13's avatar Daru13
Browse files

Fixed jal and jr instructions, which now seem to work :)

parent 955cbb36
......@@ -14,7 +14,9 @@ require alu/main
main (b) = (instruction:[word], syscall, ctrl:[2], alu_result:[32],
alu_input_2:[32], alu_ctrl:[4]) where
*)
main () = (instruction:[word], pc_value:[word]) where
main () = (instruction:[word], pc_value:[word], is_jr,
imm_addr:[word], is_jal, pc_incr:[word])
where
(* Reading the next instruction from the ROM *)
(instruction, syscall, ctrl, pc_incr, pc_value) = next_instruction(instruction[6..],
......@@ -62,8 +64,8 @@ main (b) = (instruction:[word], syscall, ctrl:[2], alu_result:[32],
read_data_mem = data_mem<32,word>(alu_result, read_data2, mem_read,
mem_write);
(* If is_jal is set, PC+4 is taken as input for registers *)
(* If is_jal is set, (PC+4)/4 is taken as input for registers *)
write_data = mux_n<word>(is_jal,
pc_incr,
0.0.(pc_incr[..word-3]),
mux_n<word>(mem_to_reg, read_data_mem, alu_result));
end where
......@@ -8,7 +8,6 @@ main:
jal print_1
# Affiche 2
la $ra, here
j print_2
here:
......@@ -22,7 +21,9 @@ here:
print_1:
li $a0, 1
add $t1, $zero, $ra
jal print_int
add $ra, $zero, $t1
jr $ra
# Ne devrait pas arriver !
......@@ -31,7 +32,9 @@ print_1:
print_2:
li $a0, 2
add $t1, $zero, $ra
jal print_int
add $ra, $zero, $t1
jr $ra
# Ne devrait pas arriver !
......@@ -40,7 +43,9 @@ print_2:
print_3_and_exit:
li $a0, 3
add $t1, $zero, $ra
jal print_int
add $ra, $zero, $t1
j exit
# Ne devrait pas arriver !
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment