_fline_internal_emulator.s 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. .xdef __fline_internal_emulator,__install_fline_emulator,__uninstall_fline_emulator,__fline_handler,__call_default_fline_handler,__current_fline_instruction__
  2. | This file requires cleanup code.
  3. .xdef __ref_all___complex_main
  4. .section _st130
  5. __install_fline_emulator:
  6. | Save old vector
  7. lea.l __ams_fline_vec__(%pc),%a0
  8. move.l 0x2C:w,(%a0)
  9. | Save %a2 since we may not destroy it when we return to the OS / launcher.
  10. pea (%a2)
  11. | Unprotect the vector table
  12. lea 0x600001,%a2
  13. moveq #2,%d0
  14. bclr.b %d0,(%a2)
  15. | Store new vector
  16. lea.l __fline_handler(%pc),%a0
  17. move.l %a0,0x2C:w
  18. | Protect the vector table
  19. bset.b %d0,(%a2)
  20. .section _st1030
  21. __uninstall_fline_emulator:
  22. | Unprotect the vector table
  23. moveq #2,%d0
  24. bclr.b %d0,(%a2)
  25. | Restore old vector
  26. move.l __ams_fline_vec__(%pc),0x2C:w
  27. | Protect the vector table
  28. bset.b %d0,(%a2)
  29. move.l (%sp)+,%a2
  30. .section _st10030
  31. __fline_handler:
  32. | Save %a1, in case we may not destroy it.
  33. pea.l (%a1)
  34. | Load the position of the F-Line instruction into %a1.
  35. move.l 6(%sp),%a1
  36. | Code to check against lower and upper bounds is inserted here.
  37. | If it fails, it jumps to __call_default_fline_handler.
  38. | Code to handle the instruction is inserted here.
  39. .section _st10039
  40. __call_default_fline_handler:
  41. | Restore %a1.
  42. move.l (%sp)+,%a1
  43. | Opcode of a jmp instruction.
  44. .word 0x4EF9
  45. | This is where the original F-Line handler is stored.
  46. __ams_fline_vec__:
  47. .long 0