-
outportb(); Variables?
I am designing a program to work with a circuit I created. I'm just using a 16-bit base DOS compiler because I don't understand the CreateFile() function yet...here's the code:
Code:
#include <stdio.h>
#include <dos.h>
void main(void)
{
int a;
char LPT[]="6F28767C395D5F687F7D";
printf("\n\n\tDisplay Number (0 to 9): ");
scanf("%i",&a);
if ((a>9) || (a<0))
{
printf("\n\tInvalid Number! (0 to 9 Only)");
}
a*=2;
outportb(0x378,0xLPT[a],LPT[a+1]);
}
When the outportb() function is run, what will it send to the 0x378 location? Say a=0....Would it send 0x6F to the x378 location? I know the code works with printf...it prints out the right array values...I just don't know if I can use a combination of letters, then a variable like that...?
Last question...would using an array like that work faster than just using a switch statement and making a case for each number?
-
> void main(void)
Nope, its
int main(void)
> outportb(0x378,0xLPT[a],LPT[a+1]);
Read the manual page - does it take 3 params?
Try
outportb(0x378,LPT[a]);
outportb(0x378,LPT[a+1]);
-
Could I just do:
Code:
outportb(0x378,0xLPT[a]LPT[a+1]);
? If i don't put 0xLPT[a] and I JUST put LPT[a] will it recognize the character has hexadecimal, and send that, or will it send the ASCII character value?
-
If you really want to send those bytes as hex, then write that in the first place
char LPT[]="\x6F\x28\x76\x7C\x39\x5D\x5F\x68\x7F\x7D";
And drop the a*=2 bit as well, since you now have real hex bytes coded in one character, not two hex-ascii chars
The result is simply
outportb(0x378,LPT[a]);