Hardware Reference
In-Depth Information
#include <conio.h>
#include <stdio.h>
int c, byte_val1, byte_val2, byte_val3;
int port1 = 0x378, port2 = 0x379, port3 = 0x37A ;
int kbhit(void);
int main()
{
gotoxy(0,6);
printf("Press any key to stop ....");
do {
byte_val1 = inp(port1);
byte_val2 = inp(port2);
byte_val3 = inp(port3);
gotoxy(0,0);
printf("The value from port1 (%d decimal) is %d \n", port1,
byte_val1);
printf("The value from port2 (%d decimal) is %d \n", port2,
byte_val2);
printf("The value from port3 (%d decimal) is %d \n", port3,
byte_val3);
} while (!kbhit());
return 0;
}
Example 2 :
/* Name:
bitfld1.c
*/
/* Language: Borland C++ 4.5
*/
/* Output:
Sends output data to a port */
#include <stdio.h>
#include <conio.h>
#include <math.h>
int byte_value[8];
int i;
int bit_no;
int port1 = 0x378;
int out_byte;
char c;
void main()
{
byte_value[0]=0;
byte_value[1]=1;
byte_value[2]=1;
byte_value[3]=0;
byte_value[4]=1;
byte_value[5]=0;
byte_value[6]=1;
byte_value[7]=0;
/* Display bitfield data in binary */
bit_no = 0;
while(bit_no <=8)
Search WWH ::




Custom Search