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

Better debug messages

parent e5d3e736
......@@ -40,14 +40,16 @@ let get_halfword ram addr =
try Array.concat [ram.(addr) ; ram.(addr+1)]
with Invalid_argument _ -> array_err "Ram.get_halfword" addr
else
raise @@ Invalid_RAM_access "Address must be even."
raise @@ Invalid_RAM_access (
Printf.sprintf "Address must be even (%d)." addr)
let get_word ram addr =
if addr mod 4 = 0 then
try Array.concat [ram.(addr) ; ram.(addr+1) ; ram.(addr+2) ; ram.(addr+3)]
with Invalid_argument _ -> array_err "Ram.get_word" addr
else
raise @@ Invalid_RAM_access "Address must be a multiple of 4."
raise @@ Invalid_RAM_access (
Printf.sprintf "Address must be a multiple of 4 (%d)." addr)
let write_byte ram addr b =
......@@ -67,7 +69,8 @@ let write_halfword ram addr hw =
end else
raise @@ Invalid_RAM_access "A halfword must be 16 bits"
else
raise @@ Invalid_RAM_access "Address must be even."
raise @@ Invalid_RAM_access (
Printf.sprintf "Address must be even (%d)." addr)
with Invalid_argument _ -> array_err "Ram.write_halfword" addr
......@@ -80,7 +83,8 @@ let write_word ram addr w =
ram.(addr+2) <- sub 16 8;
ram.(addr+3) <- sub 24 8
end else
raise @@ Invalid_RAM_access "Address must be a multiple of 4."
raise @@ Invalid_RAM_access (
Printf.sprintf "Address must be a multiple of 4 (%d)." addr)
with Invalid_argument _ -> array_err "Ram.write_word" addr
......
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