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

Fix addresses in RAM

parent 8b8c4010
......@@ -104,14 +104,14 @@ let write_instruction (rom_env : rom_t env) (ram_env : ram_t env) instr =
| Iinstrl2(opcode, r1, r2, label) ->
let addr = try find_label rom_env label
with UnknownLabel _ ->
find_label ram_env label in
4*(find_label ram_env label) in
[boiu 6 opcode; reg r2; reg r1; boiu 16 addr]
| Iinstrofs(opcode, r1, r2, ofs) ->
[boiu 6 opcode; reg r2; reg r1; boiu 16 ofs]
| Lui_l(r, label) ->
let addr = try find_label rom_env label
with UnknownLabel _ ->
find_label ram_env label in
4*(find_label ram_env label) in
[boiu 6 0xF; zeros 5; reg r; boiu 16 (addr lsr 16)]
(*
J format: opcode address
......@@ -172,4 +172,5 @@ 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;
Hashtbl.iter (Printf.printf " -> %s: %d\n") ram_env.labels;
(rom_env.addr, ram_env.addr)
......@@ -14,12 +14,12 @@ let sys_print_str ram start_addr =
let addr = ref start_addr in
let current_char = ref 0 in
let read_char () =
let c = Ram.int_of_bits @@ Ram.get_byte ram !addr in
current_char := c;
current_char := (Ram.int_of_bits @@ Ram.get_byte ram !addr);
incr addr in
while (read_char () ; !current_char <> 0) do
print_char (char_of_int !current_char)
Printf.printf "%c" (char_of_int !current_char)
done;
flush stdout;
0
(** Stops the simulator execution, maybe a little bit violent but… It will do
......
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