Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Martin Pepin
sysdig
Commits
7c79f7fe
Commit
7c79f7fe
authored
Jan 17, 2017
by
Martin Pépin
Browse files
Better debug messages
parent
e5d3e736
Changes
1
Hide whitespace changes
Inline
Side-by-side
simulator/ram.ml
View file @
7c79f7fe
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment