Superb post on writing OS exception handlers in Rust (with a small dose of asm): https://os.phil-opp.com/better-exception-messages.html (has great worked examples)