WATCOM C Library Reference : _bios_keybrd, _bios_memsize, _bios_printer, _bios_serialcom

 

 

 

 

_bios_keybrd

 

Synopsis : #include <bios.h> 

              unsigned short _bios_keybrd( unsigned service );

Description : The bios keybrd function uses INT 0x16 to access the BIOS keyboard services. possible values for service are the following constants: 

Constant                   Meaning

_KEYBRD_READ              Reads the next character from the keyboard. The function will wait until a character has been typed.
_KEYBRD_READY            Checks to see if a character has been typed. If there is one, then its value will be returned, but it is not removed from the input buffer.
_KEYBRD_SHIFTSTATUS     Returns the current state of special keys.
_NKEYBRD_READ            Reads the next character from an enhanced keyboard. The function will wait until a character has been typed.
_NKEYBRD_READY           Checks to see if a character has been typed on an enhanced keyboard. If there is one, then its value will be returned, but it is not removed from the input buffer.
_NKEYBRD_SHIFTSTATUS   Returns the current state of special keys on an enhanced keyboard.

 


Returns :  The return value depends on the service requested.
The _KEYBRD_READ and _NKEYBRD_READ services return the character's ASCII value in the low-order byte and the character's keyboard scan code in the high-order byte.


The _KEYBRD_READY and _NKEYBRD_READY services return zero if there was no character available, otherwise it returns the same value returned by _KEYBRD_READ and _NKEYBRD_READ.


The shift status is returned in the low-order byte with one bit for each special key defined as follows:


Bit                    Meaning

bit 0 (0x01)             Right SHIFT key is pressed

bit 1 (0x02)             Left SHIFT key is pressed

bit 2 (0x04)             CTRL key is pressed

bit 3 (0x08)             ALT key is pressed

bit 4 (0x10)             SCROLL LOCK is on

bit 5 (0x20)             NUM LOCK is on

bit 6 (0x40)             CAPS LOCK is on

bit 7 (0x80)             Insert mode is set

 


Example :

#include <stdio.h> 

#include <bios.h>


void main( )

{
    unsigned short key_state;
    key_state = _bios_keybrd( _KEYBRD_SHIFTSTATUS);

    if( key_state & 0x10 )
        printf( "SCROLL LOCK is on\n" );

    if( key_state & 0x20 )
        printf( "NUM LOCK is on\n" );

    if( key_state & 0x40 )
        printf( "CAPS LOCK is on\n" );

}

produces the following :

NUM LOCK is on

 


Classification : BIOS
Systems : DOS, Win, NT, DOS/PM

 

 

 

 

_bios_memsize

 

Synopsis : #include <bios.h> 

              unsigned short bios_memsize ( void );


Description : The _bios_memsize function uses INT 0x12 to determine the total amount of memory available.


Returns : The _bios_memsize function returns the total amount of 1K blocks of memory installed (maximum 640).

Example :
#include <stdio.h> 

#include <bios.h>


void main( )

{
    unsigned short memsize;


    memsize = _bios_memsize( );

    printf( "The total amount of memory is: %dK\n", memsize );

}

 

produces the following :

The total amount of memory is : 640K


Classification : BIOS
Systems : DOS, Win, NT, DOS/PM


 

 

 

_bios_printer

 

Synopsis : #include <bios.h> 

              unsigned short bios-printer( unsigned service, unsigned port, unsigned data );


Description : The _bios_printer function uses INT 0x17 to perform printer output services to the printer specified by port. The values for service are:
Value                   Meaning

_PRINTER_WRITE         Sends the low-order byte of data to the printer specified by port.
_PRINTER_INIT          Initializes the printer specified by port.
_PRINTER STATUS       Get the status of the printer specified by port.

 


Returns : The _bios_printer function returns a printer status byte defined as follows:

Bit                       Meaning

bit 0 (0x01)                 Printer timed out

bits 1-2                      Unused

bit 3 (0x08)                 I/O error

bit 4 (0x10)                 Printer selected

bit 5 (0x20)                 Out of paper

bit 6 (0x40)                 Printer acknowledge

bit 7 (0x80)                 Printer not busy

 


Example :
#include <stdio.h> 

#include <bios.h>


void main( )

{
    unsigned short status;
    status = _bios_printer( _PRINTER_STATUS, 1, 0 );

    printf( "Printer status : 0x%2.2X\n", status );

}

Classification : BIOS
Systems : DOS, Win, NT, DOS/PM

 

 

 

 

_bios_serialcom

 

Synopsis : #include <bios.h> 

              unsigned short _bios_serialcom( unsigned service, unsigned serial_port, unsigned data );


Description : The bios serialcom function The bios serialcom function uses INT 0x14 to provide serial communications services to the serial port specified by serial_port. 0 represents COMI. 1 represents COM2, etc. The values for service are:

Value                   Meaning

_COM_INIT                 Initializes the serial port to the parameters specified in data.
_COM_SEND               Transmits the low-order byte of data to the serial port.
_COM_RECEIVE           Reads an input character from the serial port.
_COM_STATUS          Returns the current status of the serial port.

 

The value passed in data for the _COM_INIT service can be built using the appropriate combination of the following values:

Value                        Meaning

_COM_110                   110 baud 
_COM_150                   
150 baud

_COM_300                   300 baud

_COM_600                   600 baud

_COM_1200                  1200 baud

_COM_2400                  2400 baud

_COM_4800                  4800 baud

_COM_9600                  9600 baud

 

_COM_NOPARITY           No parity

_COM_EVENPARITY        Even parity

_COM_ODDPARITY         Odd parity

 

_COM_CHR7                   7 data bits

_COM_CHR8                8 data bits


_COM_STOP1               
1 stop bit

_COM_STOP2               2 stop bits

 

 

Returns : 

The _bios_serialcom function returns a 16-bit value with the high-order byte containing status information defined as follows:


Bit                     Meaning

bit 15 (0x8000)              Timed out

bit 14 (0x4000)              Transmit shift register empty

bit 13 (0x2000)              Transmit holding register empty

bit 12 (0x1000)              Break detected

bit 11 (0x0800)              Framing error 

bit 10 (0x0400)              Parity error

bit 9 (0x0200)               Overrun error

bit 8 (0x0100)               Data ready


    
The low-order byte of the return value depends on the value of the service argument.
When service is _COM_SEND, bit 15 will be set if the data could not be sent clear, the return value equals the byte sent.


When service is _COM_RECEIVE, the byte read will be returned in the low-order there was no error. If there was an error, at least one of the high-order status bits will be set.


When service is _COM_INIT or _COM_STATUS the low-order bits are defined as follows:

 

Bit                          Meaning

bit 0 (0x01)                    Clear to send (CTS) changed

bit 1 (0x02)                    Data set ready changed

bit 2 (0x04)                    Trailing-edge ring detector

bit 3 (0x08)                    Receive line signal detector changed

bit 4 (0x10)                    Clear to send

bit 5 (0x20)                    Data-set ready

bit 6 (0x40)                    Ring indicator

bit 7 (0x80)                    Receive-line signal detected

 



Example :
#include <stdio.h> 

#include <bios.h>


void main( )

{
    unsigned short status;
    status = _bios_serialcom ( _COM_STATUS, 1, 0 );

    printf( "Serial status: 0x%2.2X\n", status );

}

 

 

Classification : BIOS
Systems : DOS, Win, NT, DOS/PM

 

 

 

 

 

This manual describes the WATCOM C library for DOS, Windows, and OS/2, It includes the Standard C Library (as defined in the ANSI C Standard).

 

WATCOM C Language Reference manual describes the ANSI C Programming language and extensions to it which are supported by WATCOM C/C++ (32bit)

 

 

 

728x90
반응형
Posted by 전화카드
,