Implement map_addr functions
Signed-off-by: jmug <u.g.a.mariano@gmail.com>
This commit is contained in:
parent
ef00bbf168
commit
55089bde91
1 changed files with 11 additions and 2 deletions
|
|
@ -179,14 +179,23 @@ let interp_cnd { fo; fs; fz } : cnd -> bool = function
|
|||
|
||||
(* Maps an X86lite address into Some OCaml array index,
|
||||
or None if the address is not within the legal address space. *)
|
||||
let map_addr (addr : quad) : int option = failwith "map_addr not implemented"
|
||||
let map_addr (addr : quad) : int option =
|
||||
if addr >=. mem_bot && addr <. mem_top then
|
||||
Some (Int64.to_int (addr -. mem_bot))
|
||||
else
|
||||
None
|
||||
|
||||
|
||||
(* Your simulator should raise this exception if it tries to read from or
|
||||
store to an address not within the valid address space. *)
|
||||
exception X86lite_segfault
|
||||
|
||||
(* Raise X86lite_segfault when addr is invalid. *)
|
||||
let map_addr_segfault (addr : quad) : int = failwith "map_addr_segfault not implemented"
|
||||
let map_addr_segfault (addr : quad) : int =
|
||||
let idx = map_addr addr in
|
||||
match idx with
|
||||
| Some i -> i
|
||||
| None -> raise X86lite_segfault
|
||||
|
||||
(* Simulates one step of the machine:
|
||||
- fetch the instruction at %rip
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue