Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Re: port I/O in C

Reply
Thread Tools

Re: port I/O in C

 
 
Bryan Bullard
Guest
Posts: n/a
 
      07-07-2003
as was stated these operation are platform specific. however, they are
generally easily implemented with an assembler (either inline or separately
linked).

e.g.

BYTE
_in(WORD wPort)
{
BYTE value;
asm volatile ("inb %w1,%b0" : "=a"(value) : "d"(wPort));
return value;
}

good luck
-bryan


"Kevin Cifuentes" <(E-Mail Removed)> wrote in message
news_LNa.6699$(E-Mail Removed)...
> Hey all i need some of your help. I tried compiling this using Dev-C++ and
> at no suprise it gave me an error. I say w/out suprise because I just
> discovered that the _outp and possibly the _inp functions are
> windows-specific in conio.h. I checked in conio.h provided in Dev-C++ and

I
> couldn't find the functions anywhere. Do any of you know where I can find

a
> header or library that has port I/O specific functions much similar to

_inp
> and _outp? Thanx. Here's the code:
>
> Code:
>
> #include <time.h>
> #include <conio.h>
>
> int status;
> if(!m_iNote) return;
> m_iNote = (unsigned)(1193280L / m_iNote);
> _outp(0x43,0xb6);
> _outp(0x42,(char)m_iNote);
> _outp(0x42,(char)(m_iNote >> );
> status = _inp(0x61);
> _outp(0x61,status | 0x03);
> delay( (clock_t)m_iDuration );
> _outp(0x61, status );
>
>



 
Reply With Quote
 
 
 
 
Lew Pitcher
Guest
Posts: n/a
 
      07-07-2003
On Mon, 07 Jul 2003 14:48:55 GMT, "Bryan Bullard" <(E-Mail Removed)>
wrote:

>as was stated these operation are platform specific. however, they are
>generally easily implemented with an assembler (either inline


"inline assembly" is also a platform-specific extension of the C language.

>or separately linked).
>
>e.g.
>
>BYTE
>_in(WORD wPort)
>{
> BYTE value;
> asm volatile ("inb %w1,%b0" : "=a"(value) : "d"(wPort));


a) won't work in a strictly conforming standard C compiler
b) won't work on an IBM S/390 processor

> return value;
>}
>


--
Lew Pitcher
IT Consultant, Enterprise Technology Solutions
Toronto Dominion Bank Financial Group

(Opinions expressed are my own, not my employers')
 
Reply With Quote
 
 
 
 
Tom St Denis
Guest
Posts: n/a
 
      07-07-2003
Lew Pitcher wrote:
> On Mon, 07 Jul 2003 14:48:55 GMT, "Bryan Bullard" <(E-Mail Removed)>
> wrote:
>
>
>>as was stated these operation are platform specific. however, they are
>>generally easily implemented with an assembler (either inline

>
>
> "inline assembly" is also a platform-specific extension of the C language.
>
>
>>or separately linked).
>>
>>e.g.
>>
>>BYTE
>>_in(WORD wPort)
>>{
>> BYTE value;
>> asm volatile ("inb %w1,%b0" : "=a"(value) : "d"(wPort));

>
>
> a) won't work in a strictly conforming standard C compiler
> b) won't work on an IBM S/390 processor



I don't get the point of this thread. If you are doing hardware I/O
that is *BY DEFINITION* platform dependent. Find me an 8051 with an AGP
port and I'll buy ya a beer.

Besides GCC has #defines for various processors. So if you wanted to
support multiple hardware archs from the same code you could.

Tom

 
Reply With Quote
 
Bryan Bullard
Guest
Posts: n/a
 
      07-07-2003
guys-

like i said, "these operation are platform specific." the code listing was
an EXAMPLE for mr. kevin.

lighten up.

-bryan

"Tom St Denis" <(E-Mail Removed)> wrote in message
news:HhgOa.90404$(E-Mail Removed) .rogers.com...
> Lew Pitcher wrote:
> > On Mon, 07 Jul 2003 14:48:55 GMT, "Bryan Bullard"

<(E-Mail Removed)>
> > wrote:
> >
> >
> >>as was stated these operation are platform specific. however, they are
> >>generally easily implemented with an assembler (either inline

> >
> >
> > "inline assembly" is also a platform-specific extension of the C

language.
> >
> >
> >>or separately linked).
> >>
> >>e.g.
> >>
> >>BYTE
> >>_in(WORD wPort)
> >>{
> >> BYTE value;
> >> asm volatile ("inb %w1,%b0" : "=a"(value) : "d"(wPort));

> >
> >
> > a) won't work in a strictly conforming standard C compiler
> > b) won't work on an IBM S/390 processor

>
>
> I don't get the point of this thread. If you are doing hardware I/O
> that is *BY DEFINITION* platform dependent. Find me an 8051 with an AGP
> port and I'll buy ya a beer.
>
> Besides GCC has #defines for various processors. So if you wanted to
> support multiple hardware archs from the same code you could.
>
> Tom
>



 
Reply With Quote
 
Mr. 4X
Guest
Posts: n/a
 
      07-07-2003
"Bryan Bullard" <(E-Mail Removed)> wrote:

> as was stated these operation are platform specific. however, they
> are generally easily implemented with an assembler (either inline or
> separately linked).
>
> e.g.
>
> BYTE
> _in(WORD wPort)
> {
> BYTE value;
> asm volatile ("inb %w1,%b0" : "=a"(value) : "d"(wPort));


Now THAT is really platform specific - and I guess really OT here

> return value;
> }
>
> good luck
> -bryan
>
>
> "Kevin Cifuentes" <(E-Mail Removed)> wrote in message
> news_LNa.6699$(E-Mail Removed)...
>> Hey all i need some of your help. I tried compiling this using
>> Dev-C++ and at no suprise it gave me an error. I say w/out suprise
>> because I just discovered that the _outp and possibly the _inp
>> functions are windows-specific in conio.h. I checked in conio.h
>> provided in Dev-C++ and

> I
>> couldn't find the functions anywhere. Do any of you know where I can
>> find

> a
>> header or library that has port I/O specific functions much similar
>> to

> _inp
>> and _outp? Thanx. Here's the code:
>>
>> Code:
>>
>> #include <time.h>
>> #include <conio.h>
>>
>> int status;
>> if(!m_iNote) return;
>> m_iNote = (unsigned)(1193280L / m_iNote);
>> _outp(0x43,0xb6);
>> _outp(0x42,(char)m_iNote);
>> _outp(0x42,(char)(m_iNote >> );
>> status = _inp(0x61);
>> _outp(0x61,status | 0x03);
>> delay( (clock_t)m_iDuration );
>> _outp(0x61, status );
>>
>>

>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Overhead of 4-port over 2-port SRAM John T. Goodman VHDL 0 01-25-2005 04:27 PM
4 port ethernet, 1 port broadband Link Cisco 1 05-09-2004 10:41 PM
Port-security on 16-port FastEthernet module (NM-ESW-16) Dmitry Cisco 0 04-01-2004 06:38 PM
Port security on a Catalyst 4000 - fails to shut down port Jon Whitear Cisco 2 11-04-2003 11:01 PM
about "match ip rtp starting-port-number port-range" Weiguang Shi Cisco 1 10-25-2003 07:14 AM



Advertisments