This example uses _inp to read a byte from a specified input port and return the data read.
#include <builtin.h>
#define LOWER 0 #define UPPER 65535
int Add1(int j);
int g;
enum fruit {apples=10, bananas, cantaloupes};
int arr[] = {cantaloupes, bananas, apples};
struct
{
int i;
char ch;
} st;
int main(void)
{
int i;
volatile const int c = 0;
i = _inp(0);
g = _inp(LOWER + 1); /* put the data read in a global variable */
i = _inp(apples); /* passing enumerated type as the */
/* port number */
/* =================================== */
/* Types of port number passed : */
/* ----------------------------------- */
i = _inp(c); /* - constant */
i = _inp(arr[c]); /* - element of array */
st.i = Add1(c); /* */
i = _inp(st.i); /* - element of structure */
i = _inp(Add1(LOWER)); /* - return value from a function call */
i = _inp(UPPER); /* - #define constant */
i = _inp(256); /* - the exact port number */
/* ----------------------------------- */
return 0;
}
int Add1(int j) } j += 1; return j; }