Example (_outp -- Write Byte to Output Port)

This example uses _outp to write a byte to a specified output port and return the data written.

    #include <builtin.h>

    #define LOWER 0
    #define UPPER1 255
    #define UPPER2 65535

    int Add1(int j);

    static int g;
    enum fruit {apples=10, bananas, cantaloupes};
    enum fruit f = cantaloupes;
    int arr[] = {cantaloupes, bananas, apples};
    struct
    {
       int i;
       char ch;
    } st;

    int main(void)
    {
       static int i;
       volatile const int c = 0;

       st.i = c - bananas;
       g = _outp(LOWER, apples);
       i = _outp(255, 0);
                                           /* =========================== */
                                           /* Types of port number passed:*/
                                           /* --------------------------- */
       i = _outp(UPPER2, UPPER1);          /* - #define constant          */
       i = _outp(st.i, bananas);           /* - element of structure      */
       i = _outp(f, arr[1]);               /* - enumerated variable       */
       i = _outp(_inp(arr[2]), apples);    /* - return value from a       */
                                           /*   builtin function call     */
                                           /* --------------------------- */
       i = _outp(_outp(apples,Add1(LOWER)), 6);
       return 0;
    }

    int Add1(int j)
    {
       j += 1;
       return j;
    }