Skip to content

Commit

Permalink
Fix programs that are too long from panicking
Browse files Browse the repository at this point in the history
Signed-off-by: Jerrett Longworth <[email protected]>
  • Loading branch information
jerrettl committed Jul 31, 2023
1 parent db0b43e commit 957434e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/emulation_core/mips/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl Memory {
fn check_valid_address(&self, address: usize) -> Result<(), String> {
if address % 4 != 0 {
Err(format!("Address `{address}` is not word-aligned"))
} else if address > self.memory.len() {
} else if address >= self.memory.len() {
Err(format!(
"Address `{}` out of bounds of memory of size {}",
address,
Expand Down
6 changes: 4 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,10 @@ fn app() -> Html {
// Load the binary into the datapath's memory
match datapath.initialize(assembled) {
Ok(_) => (),
// In the case of an error, stop early.
Err(_) => return,
Err(msg) => {
// In the case of an error, note this and stop early.
parser_text_output.set(format!("This program failed to load into the datapath. Message returned by datapath: {msg}"));
}
}
// log!(datapath.memory.to_string());
text_model.set_value(&program_info.updated_monaco_string); // Expands pseudo-instructions to their hardware counterpart.
Expand Down

0 comments on commit 957434e

Please sign in to comment.