Example (_inpd -- Read Doubleword from Input Port)

This example uses _inpd to read a doubleword value from the specified input port and return the data read.

#include <builtin.h>
#define LOWER 0
#define UPPER 65535
int Add1(int j);
static long g;
enum        fruit {apples=10, bananas, cantaloupes};
int         arr[] = {cantaloupes, bananas, apples};
union
{
   int  i;
   char ch;
} un;
int main(void)
{
   unsigned long      l;
   volatile const int c = 0;
   un.i = 65534;
   g = _inpd(255);         /* put the data read in a global variable  */
                                       /* =========================== */
                                       /* Types of port number passed:*/
                                       /* --------------------------- */
   l = _inpd(c);                       /* - constant                  */
   l = _inpd(un.i);                    /* - element of union          */
   l = _inpd(Add1(cantaloupes));       /* - return value from a       */
                                       /*   function call             */
   l = _inpd(_inp(arr[Add1(LOWER)]));  /* - return value from a       */
                                       /*   builtin function call     */
                                       /* --------------------------- */
   return 0;
}
int Add1(int j)
{
   j += 1;
   return j;
}