Hardware Reference
In-Depth Information
{
i = byte_value[bit_no];
printf("%i",i);
bit_no++;
};
printf("\n");
/* Output bitfield data to port */
bit_no = 0;
out_byte = 0;
while(bit_no <=8)
{
if (byte_value[bit_no]==1)
{
out_byte = out_byte + pow(2, bit_no);
};
bit_no++;
};
outp(port1, out_byte);
printf("Done!\n");
}
Example 3 :
/* Name:
portin1.c
*/
/* Language: Borland C++ 4.5
*/
/* Input:
Reads a port using assembly language
*/
#include <conio.h>
#include <stdio.h>
int c, byte_val;
int port = 889;
int main()
{
byte_val = inp(port);
asm
{
mov ax, 0x0e07
xor bx, bx
int 0x10
}
printf("The value from port %d is %d \n", port, byte_val);
return 0;
}
Search WWH ::




Custom Search