Re: A92: PLEASE ! > HELP ! Interrupt & stack ! PLEH <


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

Re: A92: PLEASE ! > HELP ! Interrupt & stack ! PLEH <





  Ok, first off, these questions are very detailed and would require several
pages of explanation, however to spare bandwidth you may simply go to the
library or bookstore and acquire a reference on the 68000 chip.  It will answer
all the basics of interrupts, stacks, etc..
  Now for the stuff the manual might not get into:

>
> HERE IS MY QUESTION : I want to change the return adress. (after each
interrupt, it goes to a specified address). So can I do
> move.l 	#the_routine,(a7)	;put adr of new routine to go after the
interrupt
> move.l	old_int,-(a7)		;put the old interrupt adress
> rts				;to go there
> It should change the return adress, isn't it ?
> (for that I think it work, because it work when I make it with 'bsr' and I
trace it with db92)
>

  This code has the minor flaw that you are destroying the old return address,
and you will be unable to return to the interrupted function.  If this is what
you actually want (be ABSOLUTELY SURE first though), then it should work fine.
An optimized version would be:

Store_Old_Int:
    move.l    $64,jmp_old_int+2
    ...

myInterrupt:
    move.l    #$new_routine,(a7)
jmp_old_int:
    jmp       $10000001

   Remember, new_routine will be called as if it is a NORMAL function, NOT as
an interrupt.  Also, the stack may be disrupted since there is no way of
knowing when the interrupt occured!  If you were in a function which was
printing text, the interrupt could have caught in the middle of a ROM routine,
leaving unknown data on the stack.  BE ABSOLUTELY SURE the stack is correct
while this interrupt is installed.  Also, the status word of the interrupted
function will be in effect when the new_routine is called.  This may include
masked interrupts or condition register bits bieng set.  Be sure to fix any of
this too.

>
> BUT the stack pointer in the interrupt routine was in the supervisor stack,
and will change when It come back to the program (it will be in the user stack)
>
> >>> COULD SOMEONE TELL ME HOW I COULD DO TO HAVE A NEW STACK POINTER WHEN IT
COME BACK TO THE PROGRAM ??
>

   Ok, you want to adjust the user stack pointer from the interrupt routine?
 Or do you want to adjust the user stack pointer from the new_routine that will
be called?
   From inside the interrupt, use the Move to/from User Stack Pointer command:
       move.l Ax,USP
       move.l USP,Ax
   First get the USP, then adjust the Ax register, then move it back to the
USP.  When you return from the interrupt, the stack pointer will be adjusted.


--Bryan
bcturner@eos.ncsu.edu


References: