Skip to content
Snippets Groups Projects
Commit dcde37b8 authored by Wilke Pierre's avatar Wilke Pierre
Browse files

fix load_int_arg problem causing segfault in qemu

parent 85526676
No related branches found
No related tags found
No related merge requests found
...@@ -163,9 +163,11 @@ let riscv_load_args oc : unit res = ...@@ -163,9 +163,11 @@ let riscv_load_args oc : unit res =
List.map (fun i -> List.map (fun i ->
[LConst(reg_a0, i); [LConst(reg_a0, i);
LCall("load_int_arg"); LCall("load_int_arg");
LBranch(Rceq, reg_a0, reg_zero, Printf.sprintf "riscv_load_arg_%d" i);
LCall("atoi"); LCall("atoi");
LStore(reg_fp, - !Archi.wordsize*i, LStore(reg_fp, - !Archi.wordsize*i,
reg_a0, !Archi.wordsize) reg_a0, !Archi.wordsize);
LLabel(Printf.sprintf "riscv_load_arg_%d" i);
]) in ]) in
(* for each arg in [1..8] (* for each arg in [1..8]
ld a{arg-1}, -8*arg(fp) ld a{arg-1}, -8*arg(fp)
...@@ -181,6 +183,9 @@ let riscv_fun_load_arg oc () = ...@@ -181,6 +183,9 @@ let riscv_fun_load_arg oc () =
("load_int_arg",{ ("load_int_arg",{
ltlfunargs = 0; ltlfunargs = 0;
(* (*
*( fp + a0 * wordsize + 8)
t0 <- Archi.wordsize (in this example 8) t0 <- Archi.wordsize (in this example 8)
mul a0, a0, t0 mul a0, a0, t0
add t0, fp, a0 add t0, fp, a0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment