Add and test an invalid opcode handler function

This commit is contained in:
Philipp Oppermann
2016-08-03 16:26:22 +02:00
parent 71ebb23ec3
commit df1e39edb2
2 changed files with 13 additions and 6 deletions

View File

@@ -52,12 +52,8 @@ pub extern "C" fn rust_main(multiboot_information_address: usize) {
// initialize our IDT
interrupts::init();
fn divide_by_zero() {
unsafe { asm!("mov dx, 0; div dx" ::: "ax", "dx" : "volatile", "intel") }
}
// provoke a divide by zero fault inside println
println!("{:?}", divide_by_zero());
// provoke a invalid opcode exception
unsafe { asm!("ud2") };
println!("It did not crash!");
loop {}