Board index » delphi » Accessing port address in pascal

Accessing port address in pascal

I make a interface card with 8255. But I do not know the statement how to
access the specified address with Pascal. I want to initialize and
send/receive (OUT and IN statement in BASIC) some data to that card.
In BASIC the statement like this :

110 BaseAddress = 640
120 PortA = BaseAddress
130 ControlPort = BaseAddress + 3
140 OUT ControlPort, 128
150 OUT PortA, 1

I hope anyone help me.
Thank

 

Re:Accessing port address in pascal


Quote
In article <mb%c5.3135$K6.20198@news>, T Hari P wrote:
>I make a interface card with 8255. But I do not know the statement how to
>access the specified address with Pascal. I want to initialize and
>send/receive (OUT and IN statement in BASIC) some data to that card.
>In BASIC the statement like this :

>110 BaseAddress = 640
>120 PortA = BaseAddress
>130 ControlPort = BaseAddress + 3
>140 OUT ControlPort, 128
>150 OUT PortA, 1

>I hope anyone help me.

const BaseAddress = 640;
      PortA       = BaseAddress;
      ControlPort = BaseAddress+3;

begin
 port[controlport]:=128;
 port[PortA]:=1;
end.

I hereby assume these are 8-bits ports.

Re:Accessing port address in pascal


Marco van de Voort heeft geschreven in bericht ...

Quote
>const BaseAddress = 640;
>      PortA   = BaseAddress;
>      ControlPort = BaseAddress+3;

>begin
> port[controlport]:=128;
> port[PortA]:=1;
>end.

I hereby assume this is Free Pascal not Turbo Pascal
(nor ISO-pascal).

Huub.

Re:Accessing port address in pascal


Quote
In article <8l1iqm$c5...@news.IAEhv.nl>, Huub van Dooren wrote:
>Marco van de Voort heeft geschreven in bericht ...
>>const BaseAddress = 640;
>>      PortA   = BaseAddress;
>>      ControlPort = BaseAddress+3;

>>begin
>> port[controlport]:=128;
>> port[PortA]:=1;
>>end.

>I hereby assume this is Free Pascal not Turbo Pascal
>(nor ISO-pascal).

I don't have any Dos version here at work. I wrote from memory what I
thought was TP,  or BP 7.0 in real mode to be more exact. Older TP's might
do it differently, but that is even longer ago, and I only used older versions
briefly.
I can be mixing up things since I've been using FPC for 2 years now.

IIRC for FPC you might have to include the ports unit.

I never used any ISO pascal, so I certainly didn't mix up with that.

---

If you think it isn't proper TP compatible code, feel free to post the
correct answer.

Re:Accessing port address in pascal


Huub van Dooren <hvdoo...@iae.nl> a crit:

Quote
> Marco van de Voort heeft geschreven in bericht ...
> >const BaseAddress = 640;
> >      PortA   = BaseAddress;
> >      ControlPort = BaseAddress+3;

> >begin
> > port[controlport]:=128;
> > port[PortA]:=1;
> >end.

> I hereby assume this is Free Pascal not Turbo Pascal
> (nor ISO-pascal).

This should work in TP and BP, in real and protected mode. I constantly use
similar statements.
But check that base address is indeed decimal because it's usually given in
hex (Port[$xxx]).
___________
Olivier Avenel  SPEC / CEA-Saclay   91191 Gif-sur-Yvette Cedex  France
ave...@drecam.saclay.cea.fr

Re:Accessing port address in pascal


JRS:  In article <mb%c5.3135$K6.20198@news> of Tue, 18 Jul 2000
09:00:38 seen in news:comp.lang.pascal.borland, T Hari P

Quote
<thpurwa...@telkom.net> wrote:
>I make a interface card with 8255. But I do not know the statement how to
>access the specified address with Pascal. I want to initialize and
>send/receive (OUT and IN statement in BASIC) some data to that card.

Assuming turbo/Borland pascal : the ports are treated as pseudo-arrays,
of byte and word - Port[] and PortW[] - these do not have all the
properties of normal arrays.

--
? John Stockton, Surrey, UK.  j...@merlyn.demon.co.uk   Turnpike v4.00   MIME. ?
 <URL: http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
 <URL: ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal FAQ;
 <URL: http://www.merlyn.demon.co.uk/clpb-faq.txt> Pedt Scragg: c.l.p.b. mFAQ.

Re:Accessing port address in pascal


Dr John Stockton heeft geschreven in bericht
<9ufTnpFhXGd5E...@merlyn.demon.co.uk>...
Quote
>JRS:  In article <mb%c5.3135$K6.20198@news> of Tue, 18 Jul 2000
>09:00:38 seen in news:comp.lang.pascal.borland, T Hari P
><thpurwa...@telkom.net> wrote:
>>I make a interface card with 8255. But I do not know the statement
how to
>>access the specified address with Pascal. I want to initialize and
>>send/receive (OUT and IN statement in BASIC) some data to that card.

>Assuming turbo/Borland pascal : the ports are treated as
pseudo-arrays,
>of byte and word - Port[] and PortW[] - these do not have all the
>properties of normal arrays.

>--

Sorry, my mistake. I thought it was a standard function or procedure
(which as such, is not in the manual). I only used Mem[] or MemW[]
occasionally. I should have tested it (as always), before posting.

Thanks for the tip. Huub.

Re:Accessing port address in pascal


Dr John Stockton heeft geschreven in bericht
<9ufTnpFhXGd5E...@merlyn.demon.co.uk>...
Quote
>JRS:  In article <mb%c5.3135$K6.20198@news> of Tue, 18 Jul 2000
>09:00:38 seen in news:comp.lang.pascal.borland, T Hari P
><thpurwa...@telkom.net> wrote:
>>I make a interface card with 8255. But I do not know the statement
how to
>>access the specified address with Pascal. I want to initialize and
>>send/receive (OUT and IN statement in BASIC) some data to that card.

>Assuming turbo/Borland pascal : the ports are treated as
pseudo-arrays,
>of byte and word - Port[] and PortW[] - these do not have all the
>properties of normal arrays.

>--

Sorry, my mistake. I thought it was a standard function or procedure
(which as such, is not in the manual). I only used Mem[] or MemW[]
occasionally. I should have tested it (as always), before posting.

Thanks for the tip. Huub.

Other Threads