Niel Slaughter

simple assembly "illegal instruction" exception handler

Discussion created by Niel Slaughter on Mar 25, 2009
Latest reply on Mar 26, 2009 by Niel Slaughter

Any one have a simple assembly "illegal instruction" exception handler that allows the program to continue after skipping over the illegal instruction?  Here is what I have so far (it executes the routine but the routine doesn't work):

 

 DEBUG_EXC_HANDLER:
        
        move.l #0x00000001,%D0 || put 1 in D0
        add.l %D0,%D3          || add D0 to D3 and put the result in D3

                                      ||(simple counter so I can see what's happening)       
        nop
        nop
        
        move.l (%A7)+,%D7  || pop status off stack
        move.l (%A7)+,%D7  || pop pc off stack

      
        move.l #0x00000002,%D1
        move.l %D7,%D0
        add.l %D1,%D0          || add D1 to D0 and put the result in D0
        move.l %D0,-(%A7)      || set top of stack to be error pc+2
        
        nop
        nop
        
        rte
        
        nop
        nop

 

|| end

 

 

With this handler, I get a "format error" exception (different exception) right after the rte.  Clearly I am not manipulating the stack correctly.  Any ideas?  Is it even possible to recover?

 

Thanks,

 

Niel

Outcomes