Commit e35832af authored by Martin Pépin's avatar Martin Pépin
Browse files

typo, debug, exit

parent b3d7abd7
......@@ -26,7 +26,6 @@ where
jump_addr = incr_addr[0..3] . partial_jump_addr . 0.0;
(* Branch address *)
(* (branch_addr, c1) = adder_n<word>(incr_addr, (imm.0.0)[2..], 0); *)
branch_addr = (imm.0.0)[2..];
(* Computing the next value of PC *)
......
......@@ -18,11 +18,11 @@ let mkenv ram init = {
labels = Hashtbl.create 17 ;
}
let incaddr env = env.addr <- env.addr + 1
let incaddr env = env.addr <- env.addr + 4
exception UnknownLabel of string
let find_label env label =
try Hashtbl.find env.labels label
try (Hashtbl.find env.labels label)/4
with Not_found -> raise @@ UnknownLabel label
(* Conversion of integers into boolean arrays *)
......@@ -133,7 +133,7 @@ let write_textline (rom_env : rom_t env) (ram_env : ram_t env) = function
| TLabel _ -> ()
| TInstr i ->
let instr = write_instruction rom_env ram_env i in
Ram.write_word rom_env.ram (4*rom_env.addr) instr;
Ram.write_word rom_env.ram rom_env.addr instr;
incaddr rom_env
......@@ -154,6 +154,7 @@ let write_dataline (env : ram_t env) = function Asciiz (label, str) ->
env.addr <- env.addr + 1 in
String.iter write_char str;
write_char '\000';
env.addr <- env.addr + 1;
if env.addr mod 4 <> 0 then
env.addr <- 4*(env.addr/4) + 4
......@@ -171,4 +172,4 @@ let write_on_rom rom ram prog =
List.iter (find_text_labels rom_env) prog.text;
rom_env.addr <- program_start;
List.iter (write_textline rom_env ram_env) prog.text;
(4*rom_env.addr, 4*ram_env.addr)
(rom_env.addr, ram_env.addr)
(** Prints an integer on stdout and returns 0 *)
let sys_print_int a0 =
Format.printf "\n\n ==> %d\n\n@?" a0;
Format.printf "%d@?" a0;
0
(** Reads an integer from stdin and returns it *)
......
......@@ -10,4 +10,7 @@ f:
end:
li $v0, 1 # Appel système pour afficher le résultat ($a0)
syscall
exit:
li $v0, 10
syscall
.data
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