Accessing Interrupt Return Status in Zero Flag

Last reviewed: July 17, 1997
Article 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:

  • The C Run-time (CRT), included with:

        - 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
    

SUMMARY

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.

MORE INFORMATION

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: kbinf 5.10 6.00 6.00a 6.00ax 7.00 1.00 1.50
KBCategory: kbprg kbcode
KBSubcategory: CRTIss
Keywords : kb16bitonly


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 17, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.