I am trying to develop my own basic kernel for educational purpose. I was reading the Intel 80386 and reading about the the interrupt 0 :- Divide by zero exception.
In there, it was written :-
Saved Instruction Pointer
Saved contents of CS and EIP registers point to the instruction that generated the exception.
My question is where are these registers saved. How, can I access these registers ?
An Interrupt pushes the current contents of the EFLAGS, CS, and EIP registers (in that order) on the stack. For some exceptions the CPU push an error code after EIP but not for Divide by zero.
If you develop your own kernel you should really take a look into the Intel Software Developer Manual. There is a chapter about Interrupts and Exceptions (6.4 in the actual version) and this includes a complete description what is when pushed.