intr.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. struct REGPACK
  2. {
  3. unsigned r_ax, r_bx, r_cx, r_dx;
  4. unsigned r_bp, r_si, r_di, r_ds, r_es, r_flags;
  5. };
  6. /* DANGER DANGER -- Self modifying code! */
  7. #asm
  8. .text
  9. save_sp:
  10. dw 0
  11. #endasm
  12. intr(intr, regs)
  13. int intr;
  14. struct REGPACK * regs;
  15. {
  16. #asm
  17. mov bx,sp
  18. push bp
  19. push si
  20. push di
  21. push es
  22. push ds
  23. mov ax,[bx+2]
  24. seg cs
  25. mov [intr_inst+1],al
  26. seg cs
  27. mov [save_sp],sp
  28. mov bx,[bx+4]
  29. mov ah,[bx+18] ! Flags low byte
  30. sahf
  31. mov ax,[bx]
  32. push [bx+2]
  33. mov cx,[bx+4]
  34. mov dx,[bx+6]
  35. mov bp,[bx+8]
  36. mov si,[bx+10]
  37. mov di,[bx+12]
  38. mov es,[bx+16]
  39. mov ds,[bx+14]
  40. pop bx
  41. intr_inst:
  42. int $FF ! Must be a real int .. consider protected mode.
  43. seg cs ! Could be SS as DS==SS
  44. mov sp,[save_sp]
  45. seg cs
  46. mov [save_sp],ds
  47. pop ds
  48. push [save_sp]
  49. push bx
  50. mov bx,sp
  51. mov bx,[bx+12]
  52. mov [bx],ax
  53. pop [bx+2]
  54. mov [bx+4],cx
  55. mov [bx+6],dx
  56. mov [bx+8],bp
  57. mov [bx+10],si
  58. mov [bx+12],di
  59. pop [bx+14]
  60. mov [bx+16],es
  61. pushf
  62. pop [bx+18]
  63. pop es
  64. pop di
  65. pop si
  66. pop bp
  67. #endasm
  68. }