Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Bios Calls From Delphi

bios registers turbo pascal

  • Please log in to reply
1 reply to this topic

#1 dejanristanovic

dejanristanovic

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 15 April 2012 - 01:07 PM

I am trying to convert some old Turbo Pascal 5.5 program to Delphi, so that it would run in 32-bit environment. It was easier than I expected, and the program basically works. However, there is the part where I control Centronics printer, with the code like:

procedure lpt_send_char (ch: byte);
var regs: registers;
a: char;
status: Boolean;
begin
repeat
repeat
regs.ah:=$2;
regs.dx:=0; {port}
intr ($17, regs);
until (regs.ah and $80)<>0;
regs.ah:=$0; regs.al:=ch; regs.dx:=0;
intr ($17, regs);
status:=(regs.ah and $29)=0;
if not status then
begin
writeln ('Printer I/O error');
write ('Abort, Retry?');
repeat until keypressed;
a:=upcase(readkey); writeln (a);
if a='A' then halt;
end;
until status;
end;

Now is there even a remote chance to make this work in 32-bit/64-bit environment or should I start rewriting the complete printer control segment?

Thank you for your help.

Dejan
  • 0

#2 Luthfi

Luthfi

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1320 posts
  • Programming Language:PHP, Delphi/Object Pascal, Pascal, Transact-SQL
  • Learning:C, Java, PHP

Posted 15 April 2012 - 08:42 PM

Hi Dejan, Welcome to CodeCall!

First, please wrap codes inside "CODE" tag. Select all the codes and click button with <> icon. Will make it easier to read and comprehend.

If you run this code under NT based Windows (Windows 2000, XP, Vista, 2003, and 7), it will fail. Because these OS prevent direct access to port. But there is way to make the code works, ie. by using "fake" device driver code. Search library called tinyport, or posts related with it.

However, accessing the printer the way you did with your code is not recommended under Windows (i.e. the 32/64 bit OS). Use windows api instead. Since you are using Delphi, you don't have to directly use windows api. You can use TPrinter object declared in Printers unit. I recently posted sample code on how to printing with Delphi.
  • 0




Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download