DOS Crash

DOS specific questions.
Donatello
Posts: 31
Joined: Mar 04, 2014 17:50
Contact:

DOS Crash

Postby Donatello » Mar 04, 2014 17:55

I am new to FreeBASIC and I tried a 5 line program:

CLS
Screen 19

Sleep
Stop

When I run the program it crashes the system and locks up.
I am usin FreeBASIC in DOS (WIndows 98)

First line of error is: "Invalid Opcode at eip=00008b04"
fxm
Posts: 9727
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: DOS Crash

Postby fxm » Mar 05, 2014 17:29

I don't think that DOS supports this graphic mode.
Have you test it with "Screen 12"?
Donatello
Posts: 31
Joined: Mar 04, 2014 17:50
Contact:

Re: DOS Crash

Postby Donatello » Mar 05, 2014 19:08

I have tried different screen modes. I even tried adding "#include fbgfx.bi"

For some reason in "pure" DOS mode no graphics modes work, but in DOSBox it does work.

DOS used is DOS that is included with Windows 98.
NOt sure it matters but the system is an old Pentium computer 166Mhz 128mb memory.
marcov
Posts: 2973
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Re: DOS Crash

Postby marcov » Mar 05, 2014 20:54

If mode 19 is a vesa mode, did you load a vesa driver?
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Re: DOS Crash

Postby MichaelW » Mar 06, 2014 0:11

The Invalid Opcode exception probably indicates that something in the program is executing an instruction that the processor does not support. What command line are you passing to the compiler?
TJF
Posts: 3596
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: DOS Crash

Postby TJF » Mar 06, 2014 6:33

Hello Donatello, welcome to the forum!

Try to remove the last line. 'Stop' is a FreeBasic keyword that may get mixed up with an ASM instruction. You don't need it here.
Donatello
Posts: 31
Joined: Mar 04, 2014 17:50
Contact:

Re: DOS Crash

Postby Donatello » Mar 06, 2014 11:36

I don't know what it is but DOS only seems to work (at least for me) using text mode and none of the graphics modes. I tried many different things and get nowhere. Not sure where the fault is.

I decided to try running a program using DOS 7.1 on a laptop (boot off USB) It has a dual-core cpu 2Ghz with 3GB of memory and again it crashes but this time the system doesn't lock up and I get a different screen message.

I am gonna try again, this time with FreeDOS as the DOS instead of the bug "Microsoft" DOS and see where that gets me.

Has anyone tried running FreeBASIC in DOS (NOT DOSBox or DOS command line used in Windows), but true DOS and able to get the graphics modes to work?
vdecampo
Posts: 2982
Joined: Aug 07, 2007 23:20
Location: Maryland, USA
Contact:

Re: DOS Crash

Postby vdecampo » Mar 06, 2014 13:06

I'm no DOS expert but don't you have to be using a 32-Bit DOS or 32-Bit DOS extender? Regular DOS only runs 16-Bit programs does it not?

I could be wrong.

-Vince
Donatello
Posts: 31
Joined: Mar 04, 2014 17:50
Contact:

Re: DOS Crash

Postby Donatello » Mar 06, 2014 13:23

In response to ya comment vdecampo ("I'm no DOS expert but don't you have to be using a 32-Bit DOS or 32-Bit DOS extender? Regular DOS only runs 16-Bit programs does it not?") please see this:

DOS related FAQ
http://www.freebasic.net/wiki/wikka.php ... qDOS#item1

FB is a 32-bit compiler - do I need a 32-bit DOS?
No, the DOS version of FreeBASIC uses a DOS extender, allowing you to execute 32-bit code on top of a 16 bit DOS kernel. You can use FreeDOS (16-bit), Enhanced-Dr-DOS, old closed Dr-DOS, or even MS-DOS down to version cca 4.
Donatello
Posts: 31
Joined: Mar 04, 2014 17:50
Contact:

Re: DOS Crash

Postby Donatello » Mar 06, 2014 13:36

TJF wrote:Hello Donatello, welcome to the forum!

Try to remove the last line. 'Stop' is a FreeBasic keyword that may get mixed up with an ASM instruction. You don't need it here.



Thank you TJF.

Yes I did remove the Stop.
Donatello
Posts: 31
Joined: Mar 04, 2014 17:50
Contact:

Re: DOS Crash

Postby Donatello » Mar 06, 2014 13:38

MichaelW wrote:The Invalid Opcode exception probably indicates that something in the program is executing an instruction that the processor does not support. What command line are you passing to the compiler?

0
What I do is I edit the source code in DOS Edit and then I run fbc.exe File.bas which creates File.exe and then I run the exe file.

No compiler command line options are used.
Dinosaur
Posts: 1350
Joined: Jul 24, 2005 1:13
Location: Hervey Bay
Contact:

Re: DOS Crash

Postby Dinosaur » Mar 06, 2014 21:54

Hi All

Donatello, if you look a few lines lower in the area you quoted.

3. When running FreeBASIC in DOS, I get a 'Error: No DPMI' message!
You need a DPMI host (DPMI kernel, DPMI server), means the file "CWSDPMI.EXE" (cca 20 KiB) or HDPMI32.EXE (cca 34 KiB). See requirements, and FAQ 4 for more details.


Do you have a DPMI host installed when trying to run in Dos ?

Has anyone tried running FreeBASIC in DOS (NOT DOSBox or DOS command line used in Windows), but true DOS and able to get the graphics modes to work?
Yes works perfectly, so will FreeDos.

Regards
DOS386
Posts: 798
Joined: Jul 02, 2005 20:55

Re: DOS Crash

Postby DOS386 » Mar 29, 2014 6:55

Code: Select all

CLS
Screen 19
Sleep
Stop


less buggy code:

Code: Select all

SCREENRES 640,480,8 '' CLS not needed
IF (SCREENPTR=0) THEN ASM INT3 '' If it crashes with "breakpoint" then ...
SLEEP 10000 '' Wait 10 s
SCREEN 0 '' Back to text mode
END


Donatello wrote:I don't know what it is but DOS only seems to work (at least for me) using text mode and none of the graphics modes. I tried many different things and get nowhere. Not sure where the fault is.

Has anyone tried running FreeBASIC in DOS (NOT DOSBox or DOS command line used in Windows), but true DOS and able to get the graphics modes to work?


YES ... it mostly works.

Hints:

- use SCREENRES instead of SCREEN
- use FreeDOS
- don't use any junk memory managers (...EMM386...) or other unneeded resident stuff
- use HDPMI32 (resident)
- your 166 MHz CPU is barely sufficient (see FAQ and try lower resolutions)
- try 640x480x8bpp indexed or 320x200x8bpp

http://www.freebasic.net/wiki/wikka.php ... engraphics
http://www.freebasic.net/wiki/wikka.php ... gScreenres
http://www.freebasic.net/wiki/wikka.php?wakka=GfxLib
http://www.freebasic.net/wiki/wikka.php?wakka=FaqDOS especially FAQ11 and FAQ19
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Re: DOS Crash

Postby MichaelW » Mar 29, 2014 8:25

Or you could try ScreenList.

Code: Select all

dim as integer mode,w,h,depths(1 to 5)={8,15,16,24,32}
for i as integer = 1 to 5
    mode = screenlist(depths(i))
    do while mode
        w = hiword(mode)
        h = loword(mode)
        print w & "x" & h & "x" & depths(i),
        mode = screenlist()
    loop
    print
next
sleep

I cross-compiled to a FBDOS app and ran it under MS-DOS 6.22/HDPMI32 on two systems.

For the first system, with an old Matrox G400 display adapter, it displayed 16 modes. For the second system, with an ancient ATI Rage Pro Turbo that supports a very wide range of VESA modes, it displayed ~50 modes.
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Re: DOS Crash

Postby MichaelW » Mar 29, 2014 23:19

This tests the 8 bpp and higher modes returned by ScreenList:

Code: Select all

type MODETYPE
    w as integer
    h as integer
    d as integer
end type

dim as MODETYPE modes()
dim as integer count,mode,depths(1 to 5)={8,15,16,24,32}

for i as integer = 1 to 5
    mode = screenlist(depths(i))
    do while mode
        count += 1
        redim preserve modes(1 to count)
        modes(count).w = hiword(mode)
        modes(count).h = loword(mode)
        modes(count).d = depths(i)
        mode = screenlist()
    loop
    print
next

for i as integer = 1 to count
    screen 0
    print modes(i).w, modes(i).h, modes(i).d
    sleep
    screenres modes(i).w, modes(i).h, modes(i).d
    cls
    print modes(i).w, modes(i).h, modes(i).d
    if modes(i).d > 8 then
        line (20,20)-(120,120),rgb(0,0,255),B
        circle (70,70),48,rgb(255,0,0)
    else
        line (20,20)-(120,120),9,B
        circle (70,70),48,12
    end if
    sleep
next

sleep

The code switches back to screen 0 to ensure that it can display the parameters for next mode to be tested, in case the next mode cannot display. Using 0.90.1 I cross-compiled to a FBDOS app and ran it under MS-DOS 6.22/HDPMI32 on the system with the Rage Pro Turbo only. All of the modes displayed the text, box, and circle as expected, but until I added the CLS after the ScreenRes statement many of the modes also displayed garbage at various locations on the screen. This suggests to me that fbgfx might be failing to clear the display memory at mode set, but my switching between screen 0 and the other modes could be causing the problem, and in any case a CLS is easy and effective.

Edit: I have now also tested the system with the Matrox G400, and all of the modes returned by ScreenList work as expected.

Edit2: In case it’s not clear what I mean by “cross-compiled to a FBDOS app”, I compiled under Windows XP with the FreeBASIC 0.90.1 Win32 compiler (with the necessary DOS components added to the bin, lib, and inc directories) using this command line:
fbc -w pendantic -target dos -v -C -R -s console test.bas

Return to “DOS”

Who is online

Users browsing this forum: No registered users and 1 guest