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++ 3.0r4 - <b>inp</b> 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


   Note-These function are not available under OS/2.

   This is a C interface to the hardware ports using the in 80x86 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 

   /* This function will turn off the MDA cursor */
   #include <stdio.h>
   #include <dos.h>

   #include <stdlib.h>

   int porta,portb,bytea,byteb;

   int 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);
       return EXIT_SUCCESS;
   }

   /* File 2 - This function will turn on the MDA cursor */
   #include <dos.h>

   #include <stdlib.h>

   int porta,portb,bytea,byteb;

   int main()
   {
       porta = 0x3b4;
       portb = 0x3b5;
       bytea = 10;
       byteb = 11;
       outp(porta,bytea);
       outp(portb,byteb);
       return EXIT_SUCCESS;
   }

See Also

   outp, outpw




See Also: outp

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