signal.s 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. .sect .text; .sect .rom; .sect .data; .sect .bss
  2. .define _signal
  3. .sect .text
  4. _signal:
  5. push bp
  6. mov bp,sp
  7. push si
  8. push di
  9. mov cx,6(bp)
  10. mov bx,4(bp)
  11. cmp bx,20
  12. jae 1f
  13. mov ax,bx
  14. add bx,bx
  15. push table(bx)
  16. mov table(bx),cx
  17. and cx,cx
  18. je 2f
  19. cmp cx,1
  20. je 2f
  21. add bx,bx
  22. lea cx,tbl(bx)
  23. 2:
  24. mov bx,ax
  25. mov ax,48
  26. call syscal
  27. pop bx
  28. jb 4f
  29. and ax,ax
  30. je 5f
  31. cmp ax,1
  32. jne 6f
  33. 5:
  34. jmp 7f
  35. 6:
  36. xchg ax,bx
  37. jmp 7f
  38. 1:
  39. mov ax,22
  40. 4:
  41. mov (_errno),ax
  42. mov ax,-1
  43. 7:
  44. pop di
  45. pop si
  46. pop bp
  47. ret
  48. ctch:
  49. push bp
  50. mov bp,sp
  51. push ax
  52. push bx
  53. push cx
  54. push dx
  55. push si
  56. push di
  57. mov ax,2(bp)
  58. sub ax,3
  59. sub ax,tbl
  60. shr ax,1
  61. mov bx,ax
  62. shr ax,1
  63. push ax
  64. call table(bx)
  65. pop di
  66. pop di
  67. pop si
  68. pop dx
  69. pop cx
  70. pop bx
  71. pop ax
  72. pop bp
  73. add sp,2
  74. pop (retadr)
  75. pop (dummy)
  76. popf
  77. jmp (retadr)
  78. .sect .bss
  79. retadr: .space 2
  80. dummy: .space 2
  81. .sect .text
  82. .align 2
  83. tbl:
  84. call ctch
  85. .align 2
  86. call ctch
  87. .align 2
  88. call ctch
  89. .align 2
  90. call ctch
  91. .align 2
  92. call ctch
  93. .align 2
  94. call ctch
  95. .align 2
  96. call ctch
  97. .align 2
  98. call ctch
  99. .align 2
  100. call ctch
  101. .align 2
  102. call ctch
  103. .align 2
  104. call ctch
  105. .align 2
  106. call ctch
  107. .align 2
  108. call ctch
  109. .align 2
  110. call ctch
  111. .align 2
  112. call ctch
  113. .align 2
  114. call ctch
  115. .align 2
  116. call ctch
  117. .align 2
  118. call ctch
  119. .align 2
  120. call ctch
  121. .align 2
  122. call ctch
  123. .align 2
  124. .sect .bss
  125. table:
  126. .space 40