Implementation of the UM-32 "Universal Machine" as described by the Cult of the Bound Variable

panic on illegal operations

tjh 9a425502 68570a36

Changed files
+12 -1
src
+12 -1
src/main.rs
··· 73 73 a: Register, 74 74 value: u32, 75 75 }, 76 + IllegalInstruction, 76 77 } 77 78 78 79 impl From<Platter> for Op { ··· 100 101 let value = value & 0x01ffffff; 101 102 Self::Orthography { a, value } 102 103 } 103 - _ => Self::Halt, 104 + _ => Self::IllegalInstruction, 104 105 } 105 106 } 106 107 } ··· 340 341 Op::Orthography { a, value } => { 341 342 self.save_register(a, value); 342 343 } 344 + 345 + Op::IllegalInstruction => self.panic(), 343 346 } 344 347 345 348 self.program_counter += 1; ··· 400 403 self.free_blocks.push(block); 401 404 self.memory[block as usize] = vec![]; 402 405 } 406 + } 407 + 408 + #[inline(never)] 409 + fn panic(&self) -> ! { 410 + panic!( 411 + "universal machine failure: instruction: {:08x}, program_counter: {:08x}, registers: {:08x?}", 412 + self.memory[0][self.program_counter as usize], self.program_counter, self.registers 413 + ) 403 414 } 404 415 }