I think I have figured out where you are getting confused. You don't understand how an x86 CPU operates.
An x86 has two modes. "Real mode" and "Protected mode". Think of "Real mode" as DOS and "Protected mode" as Windows.
These two modes are incompatible with each other. One of the most drastic changes is the memory management and how data is accessed.
In Real Mode, (Or DOS mode), you only have direct access to 640k of ram. (You really have access to 1024K, or 1 MB, but the other 384K is taken by the system) To make matters worse, you really can only access this though 64k segments, even more confusing is that the segemts aren't liniar, and can actually overlap each other. You can point a segment anywere in in the 1MB of addrssable memory and then access data within that segment using a pointer. Most of the memory management is taken care of by the compiler.
Now, at the veeeeery bottom of the memory, there is something called a "vector table". All it is is a list of addresses to jump to when you make an interupt call. There are 256 entries, one for each int call. Then you make an int call, your current place in the program is "bookmarked" on the stack and the int is ran. When the init is done, it will "pop" your last state off of the stack and return to your program.
That's why it's called an "interrupt" it's job is to interrupt your program for a little bit and then allow it to continue.
You can change the addresses in the vector table to point to you own programs. This is called "masking" and creates a kind of psudo-multitasking environment.
Aha! You say. djgpp allows you to allocate all of your memory. Not just 640k.
That's because when you run a program made by djgpp, there is an intrupt vector installed that opens a "window" into the 16 bit address space. This is done with a DOS Protected Mode Interface (Or DPMI)
You can't run a djgpp program without a DPMI manager.
Windows 9x comes on one, or you can use CWSDPMI.
Now about Protected mode.
When you switch a computer into protected mode, (You can't run both modes at the same time), you gain all kinds of cool benifits.
- You have more registers that hold more data
- You have the ability to keep programs seperated so they don't write all over each other.
- You're memory is no longer segnmented and goes from 0 to however much you have.
Windows runs in protected mode. When you put your fingers into parts of memory that doesn't belong to you, you generate a general protection fault. The program is then teminiated as it can no longer continue.
But here's the problem, and here is the sad thing.
When you go into protected mode, you loose your vector table. It's GONE All those cute things like int 33h for mouse, int 21h for dos functions, and int 10h for graphics are ALL GONE!
The real mode intrrupt system only works with segemnted memory and you gave that up when you switched modes.
When you use a compiler like MingW, you are using a full protected mode compiler that must run it's code NATIVELY in protected mode. It generates windows .EXE files, not dos .EXE files. These two formats are different! It's better to call them by thier real names. a DOS executable, and a Windows PE executable. PE executables are a lot like an ActiveX control. Worlds of diffrence.
So how do you access things without interupts?
You use the Windows API or talk with the hardware directly, but you arn't going to do the later without communicating though a windows driver of some sort. The hardware is protected anyway windows doesn't allow you to directly access it.
All your graphics hardware is ran by a windows driver. Not only that, many graphics cards now a days have low level functions that are SECRET and you MUST access them though a windows driver. Some graphic card companies will even take you to court for violation of trade secrets of you discolse how thier cards work on a low level.
Don't think this is a Windows thing. You can't directly access hardware on Linux either. You have to go through the kernel. The Nvidia driver for Linux is secret. There is no code avilable for it, just the wrapper.
Well, if you are root on linux, you have direct access to hardware, but then no one else can run your program. When using Linux, you also loose your ability to do intrrupts as well.
So how does windows run DOS programs?
It uses a psudo-emulator that catches the calls and tries it's best to handle them. It's not perfect. Windows NT/XP has stricter control over memory management than Win9x and that why it runs less DOS programs.
Pick a mode a stick with it. If you want DOS interrupts, use djgpp. if you want windows protected mode, use MingW, but you can't have both.
Sorry, that's the way the system works.
Do you have any questions?