Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using 'union REGS regs'

Status
Not open for further replies.

deanlwvu

Technical User
Jul 23, 2003
25
US
I have a major problem with the union REGS regs command in C. I have a program, source below, that generates errors whenever I compile. I've used Borland C++ 6.0, Visual Studio.NET, and Borland C++ 5.5. All of said compilers on Windows 2k, and all generating same errors, saying that structures are not defined. Do I have to create the structure?

Code below:
Code:
// Local variables.
    union REGS dRegs;                   
    union REGS mRegs;                   
    union REGS tRegs;  
    
    unsigned int year;   
    unsigned char day;  
    unsigned char hours;     
    unsigned char leapYears;          
    unsigned char minutes;            
    unsigned char month;              
    unsigned char seconds;            

// Get the current date and time.

    mRegs.h.ah = 0x2A;         
    int86(&mRegs,&mRegs);        

    tRegs.h.ah = 0x2C;              
    int86(&tRegs,&tRegs);          

    dRegs.h.ah = 0x2A;               
    int86(&dRegs,&dRegs);
 
You need a 16 bit compiler, producing real-mode programs.
An example is the old Turbo-C 2.01 listed here

All your compilers produce 32-bit protected-mode programs.

The long-term answer is to update your code to use the win32 API to access the information you want.

Under NT/2K/XP, all 16-bit DOS programs run in some kind of "compatibility mode" emulation of DOS, so it isn't like the real thing in all respects. Expect the occasional surprise if you dig too deeply.

--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top