Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ Language Reference - inp, inpw http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
   inp, inpw

   Usage
   #include <dos.h>
   int inp(int port_address);
   int inpw(port_address);

   Description
   This is a C interface to the 8086 hardware ports using the "in"   8086
   I/O instructions.

   inp reads a byte from the specified port.
   inpw reads a word from the specified port.

   The  compiler  will generate inline code for these. The  real  library
   functions can be called if #undef inpw and #undef inp are inserted  in
   the source file after #include <dos.h>.

   Return Value
   The value read from the port is returned.

   Example
   /* File 1 - This function will turn off the MDA cursor */
   #include <stdio.h>
   #include <dos.h>
   int porta,portb,bytea,byteb;
   main()
   {
   char result;
        porta = 0x3b4;
        portb = 0x3b5;
        bytea = 10;
        byteb = 32;
        result = inpw(porta);
        printf("The value from port #%x is %x hex\n",porta,result);
        outp(porta,bytea);
        outp(portb,byteb);
   }

   /* File 2 - This function will turn on the MDA cursor */
   #include <dos.h>
   int porta,portb,bytea,byteb;
   main()
   {
        porta = 0x3b4;
        portb = 0x3b5;
        bytea = 10;
        byteb = 11;
        outp(porta,bytea);
        outp(portb,byteb);
   }

See Also: outp outpw

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson