🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #14669

Re: Whats Wrong in this code ???

#14669
From: Andrue Cope
Date: Wed, 06 Aug 2003 15:06
57 lines
2339 bytes
Umar Kazi,

> #define baseadd (0x378)
> #define status (0x379)
> #define control (0x37A)
> 
> int main(int argc,char* argv[])
> 
> {
> int a;
> outval(control,5);
> a = inpval(status);
> }
>

This looks like it's attempting direct port I/O and that isn't 
possible under Win32 - the OS won't let you.

Jonathan Arnold wrote an excellent response to this question so here 
it is (with all credit to Jonathan):

You can't use inport / outport any more.  Win32 is more "protected" 
than that, so it isn't allowed. 

However, you do have a few different options, as have been posted 
here before:

Discussion of Port I/O under NT:
http://users.skynet.be/k-net/ParPort/index.html
http://www.bcbdev.com/faqs/faq30.htm

> Harold Howe has contributed something that you might be able to use
> under win95 only:
> http://www.bcbdev.com/components.htm

Or EnTech's Port I/O component:
http://www.entechtaiwan.com/tools.htm

Or, for Win9x only, if you have TASM, you can use the following:

#define outportb(port,val) outb(val,port)

void __fastcall outb(Byte val, WORD port)
{
 asm  out dx,al
}

#define inportb(port) inb(0,port)

Byte __fastcall inb(Byte dummy, WORD port)
{
 asm  in al,dx
}

--
Andrue Cope
[Bicester, UK]
Technical Details
Message-ID: <VA.00001e87.01939cc8@email.address.sorry>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-08!supernews.com!small1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3f310f05$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,143569703218d259
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-08-06 08:10:55 PST
Date: Wed, 06 Aug 2003 16:06:18 +0100
Newsgroups: borland.public.cppbuilder.nativeapi
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-Newsreader: Virtual Access by Atlantic Coast PLC, http://www.atlantic-coast.com/va
Message-ID: <VA.00001e87.01939cc8@email.address.sorry>
Subject: Re: Whats Wrong in this code ???
From: Andrue Cope <not.a.valid@email.address.sorry>
Reply-To: not.a.valid@email.address.sorry
References: <3f310f05$1@newsgroups.borland.com>
NNTP-Posting-Host: 217.207.223.34
X-Trace: newsgroups.borland.com 1060182443 217.207.223.34 (6 Aug 2003 08:07:23 -0700)
Lines: 58
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-08!supernews.com!small1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail