tangled
alpha
login
or
join now
tjh.dev
/
um32
1
fork
atom
Implementation of the UM-32 "Universal Machine" as described by the
Cult of the Bound Variable
1
fork
atom
overview
issues
pulls
pipelines
panic on illegal operations
tjh
1 year ago
9a425502
68570a36
+12
-1
1 changed file
expand all
collapse all
unified
split
src
main.rs
+12
-1
src/main.rs
···
73
73
a: Register,
74
74
value: u32,
75
75
},
76
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
103
-
_ => Self::Halt,
104
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
344
+
345
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
406
+
}
407
407
+
408
408
+
#[inline(never)]
409
409
+
fn panic(&self) -> ! {
410
410
+
panic!(
411
411
+
"universal machine failure: instruction: {:08x}, program_counter: {:08x}, registers: {:08x?}",
412
412
+
self.memory[0][self.program_counter as usize], self.program_counter, self.registers
413
413
+
)
403
414
}
404
415
}