ID Number: Q68886
6.00 6.00a 6.00ax 7.00
MS-DOS
Summary:
In Microsoft C versions 5.1, 6.0, 6.0a, 6.0ax, and C/C++ version 7.0 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.
Under C versions 6.0, 6.0a, 6.0ax, and 7.0 and QuickC versions 2.0,
2.01, 2.5, and 2.51, you can work around this by using inline assembly
to call the interrupt function and then check the status of the zero
flag.
Sample Code
-----------
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: 5.10 6.00 6.00a 6.00ax 7.00