Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2006-08

DOS Timer Interrupt, serial Interrupt

7 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Rainer Stratmann

Hello,

is there a document or sample code for accessing the timer interrupt and the serial interrupt in DOS mode.

Rainer

This does not work:

program time;
uses crt,dos;
var timervar:longint;
procedure hardtime; interrupt;
begin
 inc(timervar);
end;
var htimeivecbak : pointer;  // Interrupt Vector
const int_vectime = $1c;
procedure starttim;
begin
 timervar:=0;
 getintvec(int_vectime,htimeivecbak);
 setintvec(int_vectime,@hardtime);
end;
procedure stoptim;
begin
 setintvec(int_vectime,htimeivecbak);
end;
begin
 starttim;
 repeat
  writeln(timervar);
 until keypressed;
 readkey;
 stoptim;
end.
Andreas Berger
to Rainer Stratmann
Rainer Stratmann wrote 8 lines
Hello, is there a document or sample code for accessing the timer interrupt and the serial interrupt in DOS mode. Rainer

I found that *getintvec* and *setintvec* do not work. Use *get_pm_interrupt* and *set_pm_interrupt* instead.

Andreas

Alexey Pavluchenko
to Rainer Stratmann: is there a document or sample code for accessing the timer interrupt and the serial…

Hello Rainer,

Wednesday, August 09, 2006, 1:19:52 PM, you wrote:

RS> is there a document or sample code for accessing the timer interrupt and the RS> serial interrupt in DOS mode.

RS> This does not work:
[skip]

You should use get_pm_interrupt and set_pm_interrupt from GO32 unit instead of DOS unit procedures. At least it was so in FPC 1.x, I didn't try to compile anything for DOS with 2.x.

Best regards, Alexey
Rainer Stratmann
to Alexey Pavluchenko

Hello Alexey,

the program is changed now, but is has the same effect. May be it has to do with the special role of the timer interrupt.

Best regards
Rainer

program time;
uses crt,dos,go32;
var timervar:longint;
procedure hardtime; interrupt;
begin
 inc(timervar);
end;
var
 htimeivecbak : tseginfo;  // old Interrupt Vector
 htimeivec    : tseginfo;  // new Interrupt Vector
const int_vectime = $1c;
procedure starttim;
begin
 get_pm_interrupt(int_vectime,htimeivecbak);
 ;
 htimeivec.segment:=get_ds;
 set_pm_interrupt(int_vectime,htimeivec);
end;
procedure stoptim;
begin
 set_pm_interrupt(int_vectime,htimeivecbak);
end;
begin
 timervar:=0;
 starttim;
 repeat
  writeln(timervar);
 until keypressed;
 readkey;
 stoptim;
end.
Alexey Pavluchenko wrote 13 lines
Hello Rainer, Wednesday, August 09, 2006, 1:19:52 PM, you wrote: RS> is there a document or sample code for accessing the timer interrupt and the RS> serial interrupt in DOS mode. RS> This does not work: [skip] You should use get_pm_interrupt and set_pm_interrupt from GO32 unit instead of DOS unit procedures. At least it was so in FPC 1.x, I didn't try to compile anything for DOS with 2.x.
Alexey Pavluchenko
to Rainer Stratmann

Hello Rainer,

Wednesday, August 09, 2006, 7:07:13 PM, you wrote:

RS> Hello Alexey,

RS> the program is changed now, but is has the same effect. RS> May be it has to do with the special role of the timer interrupt.

There is nothing really special about it. Int 1Ch is not even a hardware interrupt.

RS> Best regards
RS> Rainer

RS> program time;
RS> uses crt,dos,go32;
RS> var timervar:longint;
RS> procedure hardtime; interrupt;
RS> begin
RS>  inc(timervar);
RS> end;
RS> var
RS>  htimeivecbak : tseginfo;  // old Interrupt Vector
RS>  htimeivec    : tseginfo;  // new Interrupt Vector
RS> const int_vectime = $1c;
RS> procedure starttim;
RS> begin
RS>  get_pm_interrupt(int_vectime,htimeivecbak);
RS>  ;
RS>  htimeivec.segment:=get_ds;

This one should be get_cs, not get_ds. The procedure code must be executed from the code segment, not from the data segment. While physically the segments do overlap, selector values and access rights are different.

Best regards, Alexey
Rainer Stratmann
to Alexey Pavluchenko

Hello Alexey,

yes, it should be get_cs, I wonder why it not crashes with ds. Now it counts, but slowly, when running out of win98. When running in 'pure' DOS mode (when ending windows) it has also no effect. The timer interrupt normally counts 18.2 times per second. ???

Best regards
Rainer

Alexey Pavluchenko wrote 41 lines
Hello Rainer, Wednesday, August 09, 2006, 7:07:13 PM, you wrote: RS> Hello Alexey, RS> the program is changed now, but is has the same effect. RS> May be it has to do with the special role of the timer interrupt. There is nothing really special about it. Int 1Ch is not even a hardware interrupt. RS> Best regards RS> Rainer RS> program time; RS> uses crt,dos,go32; RS> var timervar:longint; RS> procedure hardtime; interrupt; RS> begin RS> inc(timervar); RS> end; RS> var RS> htimeivecbak : tseginfo; // old Interrupt Vector RS> htimeivec : tseginfo; // new Interrupt Vector RS> const int_vectime = $1c; RS> procedure starttim; RS> begin RS> get_pm_interrupt(int_vectime,htimeivecbak); RS> ; RS> htimeivec.segment:=get_ds; This one should be get_cs, not get_ds. The procedure code must be executed from the code segment, not from the data segment. While physically the segments do overlap, selector values and access rights are different.