TURBO PASCAL

Новости

Программы   

Turbo Pascal 

Игры

Документация   

Странности

FAQ

Ссылки

Форум

Гостевая книга

Рассылка

Благодарности

Об авторе

7. What are interrupts and how to use them in Turbo Pascal?

 Q: What are interrupts and how to use them in Turbo Pascal?
 A: An interrupt is a signal to the 
processor from a program, a
hardware device, or the processor itself, to suspend temporarily
what the program is doing, and to perform a routine that is stored
in the operating system. There are 256 such interrupt routines, with
many subservices stored in memory at locations, which are given 
in
the so called interrupt table. Turbo Pascal (somewhat like C) has a
special keyword Intr, and a predefined variable registers (in the
Dos unit) to access these interrupt routines. One way of looking at
them is as Turbo Pascal (complicated lowlevel) subroutines that 
are
already there ready for you to call.
   A detailed description of interrupt routines is way beyond a
single message with limited space. Instead, I shall give a simple
example, and good references to the subject. (For a somewhat 
more
comprehensive description of what an interrupt is, see 
INTERRUP.PRI
in Ralf Brown's ftp://garbo.uwasa.fi/pc/programming/inter46b.zip.)
     :
     uses Dos;
     (* This procedure turns on the border color for CGA and VGA *)
     procedure BORDER (color : byte);
     var regs : registers;  (* Predeclared in the Dos unit *)
     begin
       FillChar (regs, SizeOf(regs), 0);  (* A precaution *)
       regs.ax := $0B00;    (* Service number *)
       regs.bh := $00;      (* Subservice number *)
       regs.bl := color;
       Intr ($10, regs);    (* ROM BIOS video driver interrupt *)
     end;  (* border *)
   If you are new the subject and / or want ideas on the most useful
interrupts in Turbo Pascal programming, Ben Ezzel (1989),
Programming the IBM User Interface Using Turbo Pascal, is 
definitely
the best reference to look at. There are also many other good
references for a novice interrupt user, such as Jamsa & 
Nameroff,
Turbo Pascal Programmer's Library.
   If you are a more advanced interrupt user you'll find the
following references very useful. Michael Tischer (1990), Turbo
Pascal Internals; Norton & Wilton (1988), The New Peter 
Norton
Programmer's guide to the IBM PC & PS/2; Ray Duncan 
(1988), Advanced
MS-DOS Programming; Terry Dettmann (1989), Dos 
Programmer's
Reference, Second edition, Que. Furthermore, there is an 
impressive
list of interrupts collected and maintained by Ralf Brown. His
extensive ftp://garbo.uwasa.fi:/pc/programming/inter46a.zip,
inter46b.zip, inter46c.zip, inter46d.zip, inter46e.zip and
inter46f.zip (or whatever are the current versions when you read
this) is available by anonymous FTP or mail server from
garbo.uwasa.fi. A definite must for an advanced user. Also see the
reference to Brown's and Kyle's book in the bibliography at the 
end
of this FAQ. Another useful (but in many respects a replicate) list
is contained in the file 
ftp://garbo.uwasa.fi/pc/programming/dosref33.zip
(or, sigh, whatever is the current version). There is also a good
hypertext advanced programmer's quick reference
ftp://garbo.uwasa.fi/pc/programming/helppc21.zip which you might
find useful.
   One more point for Turbo Pascal users. When Borland 
upgraded from
version 3 to 4.0 quite a number of tasks that needed to be done
using interrupts (such as getting the current time) were included as
normal TP routines. This means that while definitely useful,
interrupt programming is now relevant only in advanced Turbo 
Pascal
programming. Turbo Pascal 5.0 introduced a few more, but you 
can
find some of the missing TP 4.0 routines in the compatibility unit
in my ftp://garbo.uwasa.fi/pc/ts/tspa3440.zip TP units collection.
 

 Contents

На первую страницу

Rambler's Top100 Rambler's Top100
PROext: Top 1000

(с)Все права защищены

По всем интересующим вопросам прошу писать на электронный адрес

Hosted by uCoz