ID: Q68886
5.10 6.00 6.00a 6.00ax 7.00 | 1.00 1.50
MS-DOS | WINDOWS
kbprg kbcode
The information in this article applies to:
- Microsoft C for MS-DOS, versions 5.10, 6.0, 6.0a, and 6.0ax
- Microsoft C/C++ for MS-DOS, version 7.0
- Microsoft Visual C++ for Windows, versions 1.0 and 1.5
In order to call BIOS interrupts, the int86() function is typically used. Passing of register values is done by initializing fields of a variable declared as union REGS, and then reading them on return. However, there is no way to check the value of the zero flag upon completion of the BIOS function. Thus, there is no way of checking the return status of BIOS Interrupt 16h function 01h and function 11h which both return a status in the zero flag.
You can work around this by using inline assembly to call the interrupt function and then check the status of the zero flag.
int KeyPeek(void)
// Returns either the key value and scan code for that key or 0,
// indicating no key waiting.
{
union
{
int rc;
struct Key
{
char Value, ScanCode;
};
} KeyInfo;
KeyInfo.rc = 0;
_asm
{
mov AH, 01h
int 16h
jz done
mov KeyInfo.Value, AL
mov KeyInfo.ScanCode, AH
done:
}
return(KeyInfo.rc);
}
Additional reference words: kbinf 5.10 6.00 6.00a 6.00ax 7.00 1.00 1.50 KBCategory: kbprg kbcode KBSubcategory: CRTIss Keywords : kb16bitonly
Last Reviewed: July 18, 1997