home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / utility / emulator / transuti.lzh / privhndlr.asm < prev    next >
Encoding:
Assembly Source File  |  1991-01-27  |  1.2 KB  |  45 lines

  1.     far    code
  2.     far    data
  3.     public    _PrivHndlr
  4. PrivVect    equ    $20    ; Address of Privlege error vector
  5. ;
  6. ;    This installs a handler for privilege violations
  7. ;    caused when a 68010 executes a "move sr,ea" instruction
  8. ;    in user mode.
  9. ;
  10. ;    It was inspired by Scott Turner's "DeciGEL" program.
  11. ;
  12. ;
  13. ;    code to handle move sr,ea instructions. this actually modifies 
  14. ;    code in place to a MOVE CCR,ea instruction, thus it is NO GOOD 
  15. ;    at all for code in ROM. (So big deal, eh?)
  16. ;
  17. _PrivHndlr:
  18.     movem.l    D0/A0,-(SP)        ; Save registers
  19.     move.l    10(SP),A0        ; Pointer to opcode
  20.     move.w    (A0),D0            ; Pickup opcode
  21.     andi.w    #$ffc0,D0        ; Mask out EA field
  22.     cmpi.w    #$40C0,D0        ; Is it a MOVE SR,ea?
  23.     bne    ReallyIllegal
  24.     bset    #1,(A0)            ; Convert it to MOVE CCR,ea
  25.     movem.l    (sp)+,d0/a0        ; restore regs
  26.     rte                ; Rerun new opcode
  27.  
  28. ReallyIllegal:
  29.     movem.l    (sp)+,d0/a0        ; restore regs
  30. Prev:
  31.     jmp    $FC0000            ; To previous handler, patched on
  32.                     ; installation of new handler
  33.  
  34. ;
  35. ;    This is where we branch to start up Transformer
  36. Emu_Start:
  37.     lea    Prev+2(pc),a0        ;save pointer to old handler
  38.     move.l    PrivVect,(a0)
  39.     lea    _PrivHndlr(pc),a0    ;install new vector
  40.     move.l    a0,PrivVect
  41. ;
  42. ;    We fall through to the beginning of the Transformer here
  43. ;
  44.     end
  45.