Hello.

I am trying to write a very simple Delphi4 32-bit console app which toggles 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:

Exception EPrivilege in module z.exe at 00008254.
Privileged instruction.


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

Thank you.

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

procedure ClearRTS;
asm  
mov dx, 03fch;
in al,dx;
and al, 0fdh;
out dx, al; 
end;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.