_outpw -- Write Word to Output Port

Format

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

Language Level: Extension
_outpw writes an unsigned short word to the specified port. The port number must be an unsigned integer value within the range 0 to 65 535 inclusive. The unsigned short word must be in the range 0 to 65 535.

Note: _outpw 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
_outpw returns the value that was output to the specified port. There is no error return value, and _outpw does not set errno.

Example
This example uses _outpw to write an unsigned short value to a specified output port and return the data written.

#include <builtin.h>
#define LOWER 0
#define UPPER 65535
int Add1(int j);
unsigned int g;
int main(void)
{
   enum fruit {apples = 10, bananas, cantaloupes};
   enum fruit f = cantaloupes;
   int arr[] = {cantaloupes, bananas, apples};
   unsigned short s;
   static int i = 0;
   volatile const int c = 255;
   g = _outpw(cantaloupes, i);
                                     /* ============================= */
                                     /* Types of port number passed : */
                                     /* ----------------------------- */
   s = _outpw(UPPER, LOWER);         /* - #define constant            */
   s = _outpw(c, Add1(255));         /* - constant                    */
   s = _outpw(_inpw(arr[2]),apples); /* - return value from a         */
                                     /*   builtin function call       */
                                     /* ----------------------------- */
   s = _outpw(_outpw(bananas ,UPPER),6);
   return 0;
}
int Add1(int j)
{
   j += 1;
   return j;
}



_inp -- Read Byte from Input Port
_inpw -- Read Unsigned Short from Input Port
_inpd -- Read Doubleword from Input Port
_outp -- Write Byte to Output Port
_outpd -- Write Double Word to Output Port
<builtin.h>
<conio.h>