[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
CppComPort
You might also use assembler code:
Reading one of seven registers (I know the code is not beautiful or so, so please post a better solution
):
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
CppComPort
(C++) Access the COM port
When you use Microsoft's Visual C++ check this link: http://msdn2.microsoft.com/en-us/library/aa363195.aspxYou might also use assembler code:
//When you have a LED soldered between GND and DTR this will cause it to flicker.
//A speaker will create a high pitched tone
int main()
{
while(1)
{
//Write 0 to register 4
asm
{
mov dx, 0x3FC //Write to index 4
mov al, 0 //The value 0
out dx,al
}
//Write 1 to register 4
asm
{
mov dx, 0x3FC //Write to index 4
mov al, 1 //The value 1
out dx,al
}
}
return 0;
}
Reading one of seven registers (I know the code is not beautiful or so, so please post a better solution
int readRegister(const int& reg) const
{
char myVal = 0;
if (reg==0)
{
asm
{
mov dx, 0x3F8 + 0
in al, dx
mov myVal,al
}
return myVal;
}
if (reg==1)
{
asm
{
mov dx, 0x3F8 + 1
in al, dx
mov myVal,al
}
return myVal;
}
if (reg==2)
{
asm
{
mov dx, 0x3F8 + 2
in al, dx
mov myVal,al
}
return myVal;
}
if (reg==3)
{
asm
{
mov dx, 0x3F8 + 3
in al, dx
mov myVal,al
}
return myVal;
}
if (reg==4)
{
asm
{
mov dx, 0x3F8 + 4
in al, dx
mov myVal,al
}
return myVal;
}
if (reg==5)
{
asm
{
mov dx, 0x3F8 + 5
in al, dx
mov myVal,al
}
return myVal;
}
if (reg==6)
{
asm
{
mov dx, 0x3F8 + 6
in al, dx
mov myVal,al
}
return myVal;
}
assert(!"Should not get here");
return 0;
}
'COM Port' links
External links
- Beyond Logic: http://www.beyondlogic.org
- Deep Software: http://www.deepsoftware.com/nrcomm
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
