_inpw -- Read Unsigned Short from Input Port

Format

#include <conio.h>  /* also in <builtin.h> */
unsigned short _inpw(const unsigned int port);

Language Level: Extension
_inpw reads an unsigned short value from the specified input port. The port number must be an unsigned short value within the range 0 to 65 535 inclusive.

Note: _inpw is a built-in function, which means it is implemented as an inline instruction and has no backing code in the library. For this reason:

You can run code containing this function only at ring zero. Otherwise, an invalid instruction exception is generated.

Return Value
_inpw returns the value read from the specified port. There is no error return value, and _inpw does not set errno.

Example
This example uses _inpw to read an unsigned short value from the specified input port and return the data read.

#include <builtin.h>
#define LOWER 0
#define UPPER 65535
int Add1(int j);
volatile short g;
int main(void)
{
   volatile unsigned short s;
   volatile const int c = 0;
   int i = 65534;
   enum fruit {apples, bananas, cantaloupes};
   int arr[] = {cantaloupes, bananas, apples};
   g = _inpw(LOWER);       /* put the data read in a global variable  */
   s = _inpw(bananas);                 /* passing enumerated type     */
                                       /* as the port number          */
                                       /* =========================== */
                                       /* Types of port number passed:*/
                                       /* --------------------------- */
   s = _inpw(c);                       /* - constant                  */
   s = _inpw(i+1);                     /* - integer                   */
   s = _inpw(arr[bananas]);            /* - element of array          */
   s = _inpw(_outp(UPPER,cantaloupes));/* - return value from a       */
                                       /*   builtin function call     */
                                       /* --------------------------- */
   return 0;
}



_inp -- Read Byte from Input Port
_inpd -- Read Doubleword from Input Port
isatty -- Test Handle for Character Device
_outp -- Write Byte to Output Port
_outpw -- Write Word to Output Port
_outpd -- Write Double Word to Output Port
<builtin.h>
<conio.h>