Re: A92: Re: Thanks David


[Prev][Next][Index][Thread]

Re: A92: Re: Thanks David




Executing the old interrupt function (in 'int_1') may not be necessary
and would slow the whole thing down (you know that the calc gets a lot
slower when you're pressing a key).
But if it is necessary to trigger the old interrupt, the following
code may be smaller  (this is not my idea, someone wrote that idea on
the list, a long time ago)

int_1:	...

old_int1_minus2:	jmp	$123456	; trigger original interrupt vector
					; (this address is modified by the initialization code)

 ; INITIALIZATION
     move.w  #$0700,d0                ; Change SR (Status Register)
     trap    #1                       ;
     move.l  $64,old_int1_minus2+2     ; Store old interrupt vector
     bclr.b  #2,$600001               ; Disable write protection
     move.l  #int_1,$64               ; Replace with our interrupt
     bset.b  #2,$600001               ; Enable write protection
     trap    #1                       ; Restore SR
 
 . . .
 
 ; CLEAN UP
     move.w  #$0700,d0                ; Change SR
     trap    #1                       ;
     bclr.b  #2,$600001               ; Disable write protection
     move.l  #old_int1_minus2+2,$64            ; Restore the old
interrupt
     bset.b  #2,$600001               ; Enable write protection
     trap    #1                       ; Restore SR



Aaron Hill schrieb:
> 
> > I tried your idea of disabling the interrupts before reading the keypresses.
> >   It works perfectly.  Thanks for the help.  Also, At one point I tried to
> > create a custom interrupt for handling the keypresses (so it would all be
> > done automatically)  but it failed.  I couldn't get the old interrupt out
> > and the new one in.  It kept crashing and stuff.  Maybe you have something
> > that could help me here.  If anyone has any ideas to help please send them.
> 
> The interrupt vector table is protected from writing.  You have to disable
> the protection first before you right to the table.  Then reenable it when
> you're done.  Unfortunately you will also need to mask out the particular
> interrupt you are modifiying.  This cannot be done as Fargo programs are all
> run in user mode.  Ellsworth wrote a "function" to help you and it is tied
> in as a TRAP vector.  This piece of code will disable the protection, mess
> with the interrupts, and reenable the protection.
> 
> ; INITIALIZATION
>     move.w  #$0700,d0                ; Change SR (Status Register)
>     trap    #1                       ;
>     move.l  $64,old_int_1            ; Store old interrupt vector
>     bclr.b  #2,$600001               ; Disable write protection
>     move.l  #int_1,$64               ; Replace with our interrupt
>     bset.b  #2,$600001               ; Enable write protection
>     trap    #1                       ; Restore SR
> 
> . . .
> 
> ; CLEAN UP
>     move.w  #$0700,d0                ; Change SR
>     trap    #1                       ;
>     bclr.b  #2,$600001               ; Disable write protection
>     move.l  #old_int1,$64            ; Restore the old interrupt
>     bset.b  #2,$600001               ; Enable write protection
>     trap    #1                       ; Restore SR
> 
> . . .
> 
> ; INTERRUPT CODE
> int_1:
>     ; some code here
>     move.l  old_int_1,-(sp)          ; Also execute the old interrupt
>     rts
> 
> . . .
> 
> ; DATA SECTION
> old_int_1    dc.l    0
> 
> The %fargo%\doc\traps.txt file explains the interrupts.  It also explains how
> to use the TRAP #1 function.  This should help you get some interrupt-based
> programs working.  Enjoy.
> 
> ====
> Aaron Hill (Redmond, Wash.)
> Electronic Mail: serac@lightmail.com
> IRC Nickname: serac (on EF-Net)
> ActiveWorlds Citizenship: serac


References: