Files
nub-os/src/exceptions.c
nub31 751a182122 ...
2025-08-23 22:45:59 +02:00

31 lines
581 B
C

#include "print.h"
#include <stdint.h>
void exception_handler(uint64_t* stack)
{
uint64_t interrupt_num = stack[0];
uint64_t error_code = stack[1];
print("EXCEPTION: ");
if (interrupt_num == 0)
{
print("Division by zero");
}
else if (interrupt_num == 13)
{
print("General protection fault");
}
else
{
print("Unknown exception");
}
print("\nError code: ");
// You'd need to implement number printing here
print("\nSystem halted.\n");
while (1)
{
__asm__ volatile("hlt");
}
}