Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

User exception handler in C (Developers)

posted by tkchia Homepage, 31.07.2020, 19:36

Hello RayeR,

> Thanks, it led me to this example:
> http://www.delorie.com/djgpp/doc/libc/libc_641.html
> It seems DJGPP have good tools for exception handling.
> CPU context is probably saved automatically in __djgpp_exception_state
> structure from where I can check the opcode caused exception, read an
> manipulate registers and also skip "bad" opcode and resume program
> execution by longjmp(__djgpp_exception_state, 0);

Hmm... this is interesting. One worry I have with using
longjmp(__djgpp_exception_state, 0);
is that a longjmp(, ) will always alter eax, because that is how longjmp(, ) works. This may be problematic if your code doing the RDMSR (or whatever) happens to rely on eax not changing at that particular point.

I guess I will need to learn more about the finer details of how __djgpp_exception_state works. But for now, I suspect that it might be safer for you to set up your own jmp_buf (using sigsetjmp) and then jump to it.

Thank you!

---
https://gitlab.com/tkchia · https://codeberg.org/tkchia · 😴 "MOV AX,0D500H+CMOS_REG_D+NMI"

 

Complete thread:

Back to the forum
Board view  Mix view
22049 Postings in 2034 Threads, 396 registered users, 61 users online (0 registered, 61 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum