Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

how to set and clear RTS in a 32-bit Delphi4 (pascal) console app

how to set and clear RTS in a 32-bit Delphi4 (pascal) console app

how to set and clear RTS in a 32-bit Delphi4 (pascal) console app


I am trying to write a very simple Delphi4 32-bit console application {$APPTYPE CONSOLE} which sets and clears the RTS pin of the COM1 RS232 serial port.

What is the simplest way to do this?

I tried writing asm code (see below) but not surprisingly I got a run-time exception (see below).

Does Delphi4 have built-in support for setting/clearing RTS? I could not find it.

Thank you.

---------begin code--------------
procedure SetRTS;
mov dx, 03fch; {get COM1 MCR}
in al,dx;
or al, 2; {set RTS}
out dx, al;

procedure ClearRTS;
mov dx, 03fch;
in al,dx;
and al, 0fdh;
out dx, al;
---------end code-------------

-------begin runtime error message-------------
Exception EPrivilege in module z.exe at 00008254.
Privileged instruction.[/QUOTE]
-------end runtime error message-------------

RE: how to set and clear RTS in a 32-bit Delphi4 (pascal) console app

You can't use privileged instructions within Windows NT class operating systems in writing 32-bit windows programs.  To access hardware functions, you need to go through the Win32 API.  See below link which describes it for serial ports.


For future reference, the Delphi forum is here: forum102: Embarcadero: Delphi

It is not possible for anyone to acknowledge truth when their salary depends on them not doing it.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close