Board index » delphi » Pascal "Port"

Pascal "Port"

Hi all,

There used to be a "Port" identifier in Turbo Pascal.
But it is not available in Dlphi anymore.
I guess it was used for reading and writing  IO ports, right?

I got these functions to use in Delphi for reading and writing and am just
wondering if they can be used instead of "Port" in Pascal. Any ideas are
appreciated

x:=Port[ControlPort];       pascal
FUNCTION PortIn(IOport: WORD): BYTE; ASSEMBLER; REGISTER; delphi
ASM
  MOV DX,AX
  IN AL,DX
END;

Port[ControlPort] := $06; {SDA Low & SCL High} pascal
PROCEDURE PortOut(IOport: WORD; Value: BYTE); ASSEMBLER; REGISTER; delphi
ASM
  XCHG DX,AX
  OUT DX,AL
END;

 

Re:Pascal "Port"


Quote
Vlado wrote:
> I got these functions to use in Delphi for reading and writing and am just
> wondering if they can be used instead of "Port" in Pascal. Any ideas are
> appreciated

That'll work under Windows 9x but not in Windows NT/2000.

--
Kent Briggs, kbri...@briggsoft.com
Briggs Softworks, http://www.briggsoft.com

Re:Pascal "Port"


Quote
In article <FtgG6.371$Ew.28...@news.siol.net>, Vlado wrote:
> Hi all,

> There used to be a "Port" identifier in Turbo Pascal.
> But it is not available in Dlphi anymore.
> I guess it was used for reading and writing  IO ports, right?

> I got these functions to use in Delphi for reading and writing and am just
> wondering if they can be used instead of "Port" in Pascal. Any ideas are
> appreciated

> x:=Port[ControlPort];       pascal
> FUNCTION PortIn(IOport: WORD): BYTE; ASSEMBLER; REGISTER; delphi
> ASM
>   MOV DX,AX
>   IN AL,DX
> END;

> Port[ControlPort] := $06; {SDA Low & SCL High} pascal
> PROCEDURE PortOut(IOport: WORD; Value: BYTE); ASSEMBLER; REGISTER; delphi
> ASM
>   XCHG DX,AX
>   OUT DX,AL
> END;

It can also be done in Kylix I think. But only as root (or maybe SU)
(ioperm etc)

Re:Pascal "Port"


The x86 microprocessor architecture includes an "I/O permission map" and
"I/O privilege levels," according to page 203 of my ever-so-trusty
"Lance Leventhal's 80386 Programming Guide."  (The one with -that-
picture on the cover .. you know the one .. show of hands from everyone
who has a copy? .. thank you.)  ;-)  Good little book, actually.

So the CPU can completely control whether or not your program can
address any port at all, and/or any particular port.  And most operating
systems do not allow you to do so directly, because port-operations
imply I/O and that implies interrupts are probably going to be needed ..
and operating systems generally require to be in-control of all such
things.

Windows is really an incredibly "loosy goosy" system to allow you to do
such things at all; it's done to provide compatibility for DOS programs,
I think, and it's going-away, I think.

Quote
>Marco van de Voort wrote:

> In article <FtgG6.371$Ew.28...@news.siol.net>, Vlado wrote:
> > Hi all,

> > There used to be a "Port" identifier in Turbo Pascal.
> > But it is not available in Dlphi anymore.
> > I guess it was used for reading and writing  IO ports, right?

> > I got these functions to use in Delphi for reading and writing and am just
> > wondering if they can be used instead of "Port" in Pascal. Any ideas are
> > appreciated

> > x:=Port[ControlPort];       pascal
> > FUNCTION PortIn(IOport: WORD): BYTE; ASSEMBLER; REGISTER; delphi
> > ASM
> >   MOV DX,AX
> >   IN AL,DX
> > END;

> > Port[ControlPort] := $06; {SDA Low & SCL High} pascal
> > PROCEDURE PortOut(IOport: WORD; Value: BYTE); ASSEMBLER; REGISTER; delphi
> > ASM
> >   XCHG DX,AX
> >   OUT DX,AL
> > END;

> It can also be done in Kylix I think. But only as root (or maybe SU)
> (ioperm etc)

------------------------------------------------------------------
Sundial Services :: Scottsdale, AZ (USA) :: (480) 946-8259
mailto:i...@sundialservices.com  (PGP public key available.)

- Show quoted text -

Quote
> Fast(!), automatic table-repair with two clicks of the mouse!
> ChimneySweep(R):  "Click click, it's fixed!" {tm}
> http://www.sundialservices.com/products/chimneysweep

Re:Pascal "Port"


Quote
In article <3AECCE8F.6...@sundialservices.com>, Sundial Services wrote:
> The x86 microprocessor architecture includes an "I/O permission map" and
> "I/O privilege levels," according to page 203 of my ever-so-trusty
> "Lance Leventhal's 80386 Programming Guide."  (The one with -that-
> picture on the cover .. you know the one .. show of hands from everyone
> who has a copy? .. thank you.)  ;-)  Good little book, actually.

(for the interested:
Academic Service, Dutch version is ISBN 90-6233-440-7.
p. 203 seems to be page 219 in the Dutch version :-)

Quote
> So the CPU can completely control whether or not your program can
> address any port at all, and/or any particular port.  And most operating
> systems do not allow you to do so directly, because port-operations
> imply I/O and that implies interrupts are probably going to be needed ..
> and operating systems generally require to be in-control of all such
> things.

At least FreeBSD and Linux allow it. But you have to ask permission (per
port IIRC) if you are not Root. And under FreeBSD you can't even get
permission if you are not in Wheel.

Quote
> Windows is really an incredibly "loosy goosy" system to allow you to do
> such things at all; it's done to provide compatibility for DOS programs,
> I think, and it's going-away, I think.

Windows 9x, yes. NT,2000, afaik: no.

Other Threads