#### Archived

This topic is now archived and is closed to further replies.

# Registers and C

This topic is 6020 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Im playing around with video modes and im trying to set the video mode to 13h, a standard 320x200 mode but when i run the code union REGS regs; regs.x.ax = 0x13; int86( 0x10, ®s, ®s ); I receive a serious General protection fault error. I managed to narrow it down to the above lines, it seems i get this error when the video mode is trying to be set. Im running Win2k and compiling using DJGPP with gcc 2.953 Exiting due to signal SIGSEGV General Protection Fault at eip=00011989 eax=6168732f ebx=00591510 ecx=00000059 edx=6168732f esi=00000054 edi=000291d4 ebp=0058ff30 esp=0058ff24 program=C:\TEMP\STARS.EXE cs: sel=01a7 base=017b0000 limit=0059ffff ds: sel=01af base=017b0000 limit=0059ffff es: sel=01af base=017b0000 limit=0059ffff fs: sel=017f base=00005800 limit=0000ffff gs: sel=01bf base=00000000 limit=0010ffff ss: sel=01af base=017b0000 limit=0059ffff App stack: [00590000..00510000] Exceptn stack: [00029128..000271e8] Call frame traceback EIPs: 0x00011989 0x0000e683 0x0000190b 0x000016fd 0x00010ca2 after the program is run this is the result i get ... anyone have any ideas .. or any suggestions on a different way to do this

##### Share on other sites
i''m not quite sure but what you are trying to do is use a dos function, but win2k doens''t have a dos kernel anymore so i don''t think you can only do that on win98/me and below...

##### Share on other sites
all im trying to do is set the video mode in my program to the old standard bios mode of 13h and then call int10 which should set the display to 320x200 but instead i get all that register dumps above.

You mentioned that win2k no longer supports the dos kernel so im guessing what im trying to do is set the video mode through the bios wont work.

Unfortunely i cant check if this is the case on win98/me because im only running 2k.

##### Share on other sites
DOS used to allow you to do all those kind of under the hood tricks, but its not the same anymore in Windows, the windows kernel makes sure you cant just poke around the bios and system calls without doing even more tricks, do you have a DOS/Win95/98 bootdisk? try running your program booting with that, if you see no problems, then you can blame Windows.

##### Share on other sites
DOS programs in Win2K can switch to int10h modes; NTVDM traps the call and does "the right thing".

However, I do not believe that Win32 programs can do so.

##### Share on other sites
I''m pretty sure that DOS programs, even those that use Mode13h, will run under WinNT/2k. This may have something to do with DJGPP''s DPMI server. You could try to use the following code, which I use. It is essentially your code, but it uses compiler-specific DPMI server commands:

  void setmode13h(){ __dpmi_regs r; r.x.ax = 0x13; __dpmi_int(0x10, &r);}void settextmode(){ __dpmi_regs r; r.x.ax = 0x3; __dpmi_int(0x10, &r);}

##### Share on other sites
I think this is why everybody else is using Direct Draw/X.

It certainly does the right thing.

When programming for Windows, you are not supposed to bother the poor little bios. Leave it alone, will you?

##### Share on other sites
TerranFury is quite correct. DJGPP''s int86() only supports a small portion of the possible interrupts, and should not be used. Use the __dpmi family of functions instead, and your program will work fine in Win2k. For more info, see the DJGPP docs.

##### Share on other sites
Great guys .. i will give this a try .. thx for the input

and im not doing windows programming, im playing around with the simplest of video modes just as an exercise to see what can be done ..

1. 1
2. 2
3. 3
Rutin
19
4. 4
5. 5

• 14
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631424
• Total Posts
3000008
×