Board index » cppbuilder » outportb (ok so im old)

outportb (ok so im old)


2004-02-09 01:37:49 AM
cppbuilder36
Hello:
I am trying to do a single use application that needs to have hardware port
access. I have C++ Builder 1 4 5 6. The earlier versions appear to support
this statement, but when I compile a simple program I get undefined function
error.
includes
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include <dos.h>
#include <stdio.h>
code
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int port = 0x0378;
int value = 0x55;
outportb(port, value);
}
Thanks
 
 

Re:outportb (ok so im old)

The issue is not as much what compiler version you are using as it is what
operating system you are using.
Win32 application programs are banned from direct port I/O. However the
method used by Win95 and 98 to support legacy programs lets such I/O slip
though. Under those operating systems you could try something like this
with BCB6.
_DX = 0x0055;
_AX = 0x0378;
_asm out ax,dx
Since you are aiming at the parallel port your data probably go to the
virtual port that Windows sets up to mitigate communications from multiple
processes so your results may vary.
I think it would be better to use the support built within Windows for
parallel port usage instead of using MSDOS methods of direct hardware
manipulation. Look up CreateFile, WriteFile and CloseHandle in the Win32
help.
And if you must bit bang the port then look around for a device driver.
. Ed
Quote
Fayette Sims wrote in message
news: XXXX@XXXXX.COM ...

I am trying to do a single use application that needs to
have hardware port access. I have C++ Builder 1 4 5 6.
The earlier versions appear to support this statement,
but when I compile a simple program I get undefined
function error.

includes
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include <dos.h>
#include <stdio.h>

code

void __fastcall TForm1::Button1Click(TObject *Sender)
{
int port = 0x0378;
int value = 0x55;

outportb(port, value);
}