| Previous | Next | Up | Top |
Q: OK, I've succeeded in converting and compiling my assembly-language program, but when I run it, I get "Segmentation Violation" and "General Protection Fault". This program
works when compiled with MASM, so how can this be?
A: In DJGPP, your program runs in protected mode. There are certain things you can't do in protected-mode programs (that's why it is called protected mode).
This issue is too complex to describe here, so only a few of the more important aspects will be briefly mentioned. If you are serious about writing assembly language protected-mode code, or have a
large body of existing code to convert to protected mode, you should read any of the available books about protected-mode programming with 80x86 processors.
Here is a short list of some of the techniques found in many real-mode programs, which will trigger protection violation or erratic behavior in protected mode:
- Loading arbitrary values into segment registers, then using them to reference code or data.
- Referencing code with data segment register, or vice versa.
- Assuming certain locations (like BIOS area or video memory) will be found at certain absolute addresses.
- Calling DOS or BIOS services with
INT NN
instruction.
- Hooking interrupts by poking absolute addresses.

You can help support this site by
visiting the advertisers that sponsor it! (only once each, though)