Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   Re: port I/O in C (http://www.velocityreviews.com/forums/t314057-re-port-i-o-in-c.html)

Bryan Bullard 07-07-2003 02:48 PM

Re: port I/O in C
 
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" <kc915hakrez@yahoo.com> wrote in message
news:p_LNa.6699$351.2755197@twister.nyc.rr.com...
> 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 >> 8));
> status = _inp(0x61);
> _outp(0x61,status | 0x03);
> delay( (clock_t)m_iDuration );
> _outp(0x61, status );
>
>




Lew Pitcher 07-07-2003 03:00 PM

Re: port I/O in C
 
On Mon, 07 Jul 2003 14:48:55 GMT, "Bryan Bullard" <the_bullards@sbcglobal.net>
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')

Tom St Denis 07-07-2003 03:25 PM

Re: port I/O in C
 
Lew Pitcher wrote:
> On Mon, 07 Jul 2003 14:48:55 GMT, "Bryan Bullard" <the_bullards@sbcglobal.net>
> 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


Bryan Bullard 07-07-2003 04:26 PM

Re: port I/O in C
 
guys-

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

lighten up.

-bryan

"Tom St Denis" <tomstdenis@iahu.ca> wrote in message
news:HhgOa.90404$2ay.990@news01.bloor.is.net.cable .rogers.com...
> Lew Pitcher wrote:
> > On Mon, 07 Jul 2003 14:48:55 GMT, "Bryan Bullard"

<the_bullards@sbcglobal.net>
> > 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
>




Mr. 4X 07-07-2003 08:43 PM

Re: port I/O in C
 
"Bryan Bullard" <the_bullards@sbcglobal.net> 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" <kc915hakrez@yahoo.com> wrote in message
> news:p_LNa.6699$351.2755197@twister.nyc.rr.com...
>> 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 >> 8));
>> status = _inp(0x61);
>> _outp(0x61,status | 0x03);
>> delay( (clock_t)m_iDuration );
>> _outp(0x61, status );
>>
>>

>
>




All times are GMT. The time now is 06:00 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.