[fpc-devel]Calling previous INTroutine

startx startx at geocities.com
Sat Dec 9 13:44:26 CET 2000


Aleksey V. Vaneev wrote:
>   I've encountered a problem with calling previous interrupt routine
>   in my handler. I'm doing this under go32v2. I install handler with

This works well for me, try:


// ------------ start of interrupt code
procedure datasegment; assembler;
asm
  dw 0
end;

Procedure IRQ0_Service;
begin
  asm
    pusha
    push ds
    push es
    push esi
    push edi
    mov   ebx,offset datasegment
    mov   ax,cs:[ebx]			// read right DS from code
    mov   ds,ax
    mov   es,ax
  end;

	// do whatever you want here

  // call old handler if needed
  Inc(IRQ0_OldCount,IRQ0_Counter);
  if IRQ0_OldCount<IRQ0_Counter then begin	// overflow
    asm
      pushf
      lcall [Oldint08]
    end
  end else Port[$20] := $20;

  // exit code
  asm
    pop  edi
    pop  esi
    pop  es
    pop  ds
    popa
    leave
    iret
  end
end;

procedure Int00End;
begin
end;


  // later... setting up things
  asm
    mov  ax,ds
    mov  ebx,offset datasegment
    mov  word ptr [ebx],ax
  end;

  // all data must be locked. Below I lock a contiguous area of vars
  lock_data(DATA_Buffer,longint(@EndDSInt)-longint(@DATA_Buffer));

  // lock all used code (the old handler has not to be locked)
  lock_code(@DataSegment,longint(@Int00End)-longint(@DataSegment));

  Get_pm_interrupt(8,OldInt08);
  Disable;
  myinterr.segment := get_cs;
  myinterr.offset  := @Irq0_Service;
  set_pm_interrupt(8,myinterr);

  // reprogram the counter
  Port[$43] := $36;     // command to set new count
  Port[$40] := Lo(IRQ0_Counter);	// a new value
  Port[$40] := Hi(IRQ0_Counter);
  Port[$43] := 0;
  Enable;

Regards.

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com





More information about the fpc-devel mailing list