Thread: Creepy DOS and BIOS functions (need help!!!)

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    20

    Exclamation Creepy DOS and BIOS functions (need help!!!)

    I use Borland C++ Compiler 5.5,which runs in DOS, I just put bcc32 and the source code (the .cpp file that has source code) and it compiles it. Well I am having the following problem while trying to call a DOS function. Here is my program:

    Code:
    #include <stdio.h> 
    #include <dos.h> 
    
    void main() 
    { 
    int major,minor; 
    union REGS regs; //required for making DOS calls 
    
    regs.h.al=1; //Get version number 
    regs.h.ah=0x30; //Get version function 30h 
    int86(0x21, & regs, & regs); //Call DOS 
    major=regs.h.al; //Get major version no. 
    minor=regs.h.ah; //Get minor version no. 
    
    printf("This is DOS version %i, release %i",major,minor); 
    }
    NOTE: In Line 11 & and regs are supposed to be joined, but if I join it posts this sign ®.

    I get a lot of error messages and it won't compile my program. Here are the error messages:

    Error E2450 dosver.c 7: Undefined structure 'REGS' in function main
    Error E2449 dosver.c 7: Size of 'regs' is unknown or zero in function main
    Error E2450 dosver.c 7: Undefined structure 'REGS' in function main
    Error E2450 dosver.c 7: Undefined structure 'REGS' in function main
    Error E2449 dosver.c 7: Size of 'regs' is unknown or zero in function main
    Error E2451 dosver.c 9: Undefined symbol 'h' in function main
    Error E2451 dosver.c 10: Undefined symbol 'h' in function main
    Warning W8065 dosver.c 11: Call to function 'int86' with no prototype in function main
    Error E2451 dosver.c 12: Undefined symbol 'h' in function main
    Error E2451 dosver.c 13: Undefined symbol 'h' in function main
    *** 9 errors in Compile ***

    I have taken this program from a C book (C for Dummies Volume One), and I copied it exactly, but it still doesn't work. Can anyone help me?
    Last edited by James00; 04-29-2003 at 07:43 PM.

  2. #2
    Registered User Draco's Avatar
    Join Date
    Apr 2002
    Posts
    463
    how old is your book? I don't know much about what your problem could be, but maybe the book was using an earlier OS where you had control of full dos, not like with newer OS' such as WinXP,ME, etc. that would make your code invalid

  3. #3
    Registered User
    Join Date
    Apr 2003
    Posts
    32
    I don't think Borland 5.5 supports interrupts, if you still want to compile this code, try another compiler, an older one like Turbo C, it should work there. My suggestion would be, leave interrupts and DOS, they're all dead.

    >void main()
    This is incorrect, pass trough the FAQ and see why it is wrong.

    Good luck with your code,
    Serruya.

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    1) Your compiler might not like the fact that you're using '.cpp' extensions, as this typically means "C++".

    2) Main never returns void. It always returns an int. Thus, every program you write takes one of these two forms:
    Code:
    int main( void )
    {
        ...stuff...
    
        return 0;
    }
    Or:
    Code:
    int main( int argc, char *argv[]  )
    {
        ...stuff...
    
        return 0;
    }
    Naturally the return value doesn't always have to be zero, but the main thing to note here is that you always return an integer.

    3) It's possible you're not including the correct header file, or that your compiler simply doesn't contain the needed information. (IE: Not all compilers are DOS compilers.)

    [edit]Curses, foiled again![/edit]

    Quzah.
    Hope is the first step on the road to disappointment.

  5. #5
    Registered User
    Join Date
    Apr 2003
    Posts
    20
    Thanks for all the help!!! I actually save my source code with the .c at the end instead of .cpp. And thanks for the comments about void main(), I will use int from now on. I think I will have to get another compiler to run the program, although I know using it is a dead art, but I just want to know how it works. Thanks all, for your help.

  6. #6
    Walt
    Guest
    I just compiled it on my XP system and the program compiled and actually ran correctly, giving me DOS ver 5, release 0
    (ver gave XP version 5.1.2600)

    Granted I used a different version of Borland, but 5 should handle it fine. It was released long before DOS was dead.

    Many interrupts though will not work in NT, 2000, and XP becaue they are not true DOS. I found reading CD sectors with interrupts didn't work.

    Another compiler probably won't work at all unless it's Borland. Doesn't 5 also come with 4.5? Try that one.

  7. #7
    Registered User
    Join Date
    Apr 2003
    Posts
    20
    Well, I have tried a lot of things and none work, but then I noticed that my compiler compiled by deafult in 32 bit, and my programs only runs in 16 bit. How do I make my compiler compile in 16 bit? Any one got any ideas? Thanks.

  8. #8
    Registered User Draco's Avatar
    Join Date
    Apr 2002
    Posts
    463
    I don't know anything about Borland, but I'm sure that somewhere in your documentation it would tell you. You just have to go look for it.

  9. #9
    Registered User
    Join Date
    Apr 2003
    Posts
    20
    I have looked at the help files but I can't really find what I am looking. What I do is this: I open the only possible folder in the help menu, Command Line Tools. Then I get all these C++ Builder tools, here they are:

    File Description
    BCC32.EXE C++ compiler (32-bit), command-line version
    BPR2MAK.EXE Converts project file from XML to MAKE file format for use with command-line tools
    BRC32.EXE Resource compiler (32-bit), command-line version
    BRCC32.EXE Resource shell (32-bit)
    CONVERT.EXE Converts .DFM form files into a .TXT file format
    CPP32.EXE C preprocessor (32-bit), command-line version
    DCC32.EXE Object Pascal compiler (32-bit), command-line version
    FCONVERT.EXE Converts text files between OEM and ANSI formats
    GREP.EXE File search utility
    ILINK32.EXE Incremental linker (32-bit), command-line version
    IMPDEF.EXE Utility used when building apps with Libraries
    IMPLIB.EXE Utility used when building apps with Libraries
    MAKE.EXE Make utility
    REGSRVR.EXE Registers ActiveX and OLE server .DLLs
    RLINK32.DLL Resource linker (32-bit)
    TDUMP.EXE File dump utility
    TLIB.EXE Utility for maintaining static-link libraries
    TLIBIMP.EXE (Type Library Import) tool. Takes existing type libraries and creates C++Builder Interface files. Incorporated into the Type Library editor.
    TOUCH.EXE Change files stamps to current date/time
    TRIGRAPH.EXE Converts 3-character trigraph sequences into single characters
    VCTOBPR.EXE Converts Microsoft Visual C++ 5.0 and 6.0 project (.DSP) and workspace (.DSW) files to their equivalent Borland C++Builder files
    WS32.EXE WinSight32, 32-bit utility to watch Windows messages

    Now each of the Command Line Tools (file in blue), has a help menu, but which one of those do I enter to find how to make 16 bit programs. Thanks.

  10. #10
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,164
    The test I compiled that worked was with Turbo C++ ver 1.00, Turbo Link ver 3.0 -- no surprises.

    If you run BCC32 from the command line without parameters, you should get a list of all the command line switches. There may be one to compile 16bit code. BCC is the "Borland C Compiler".

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. TSR to detect video mode
    By surdy in forum C Programming
    Replies: 4
    Last Post: 03-21-2004, 07:31 PM
  2. various BIOS questions
    By Waldo2k2 in forum Tech Board
    Replies: 14
    Last Post: 01-24-2003, 07:01 AM
  3. real mode dos & win dos
    By scott27349 in forum A Brief History of Cprogramming.com
    Replies: 26
    Last Post: 08-19-2002, 06:15 AM
  4. How do I print to COM1 via DOS?
    By JWHolland in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 07-31-2002, 02:17 PM
  5. ASM interrupt and others
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 06-08-2002, 07:18 PM