swtch.s
资源名称:c.rar [点击查看]
上传用户:shmaik
上传日期:2014-06-01
资源大小:45093k
文件大小:4k
源码类别:

VC书籍

开发平台:

C/C++

  1. #if alpha
  2. .globl _swtch
  3. .ent _swtch
  4. _swtch: lda $sp,-112($sp) # allocate _swtch's frame
  5. .frame $sp,112,$26
  6. .fmask 0x3f0000,-112
  7. stt $f21,0($sp) # save from's registers
  8. stt $f20,8($sp)
  9. stt $f19,16($sp)
  10. stt $f18,24($sp)
  11. stt $f17,32($sp)
  12. stt $f16,40($sp)
  13. .mask 0x400fe00,-64
  14. stq $26,48+0($sp)
  15. stq $15,48+8($sp)
  16. stq $14,48+16($sp)
  17. stq $13,48+24($sp)
  18. stq $12,48+32($sp)
  19. stq $11,48+40($sp)
  20. stq $10,48+48($sp)
  21. stq $9,48+56($sp)
  22. .prologue 0
  23. stq $sp,0($16) # save from's stack pointer
  24. ldq $sp,0($17) # restore to's stack pointer
  25. ldt $f21,0($sp) # restore to's registers
  26. ldt $f20,8($sp)
  27. ldt $f19,16($sp)
  28. ldt $f18,24($sp)
  29. ldt $f17,32($sp)
  30. ldt $f16,40($sp)
  31. ldq $26,48+0($sp)
  32. ldq $15,48+8($sp)
  33. ldq $14,48+16($sp)
  34. ldq $13,48+24($sp)
  35. ldq $12,48+32($sp)
  36. ldq $11,48+40($sp)
  37. ldq $10,48+48($sp)
  38. ldq $9,48+56($sp)
  39. lda $sp,112($sp) # deallocate frame
  40. ret $31,($26)
  41. .end _swtch
  42. .globl _start
  43. .ent _start
  44. _start: .frame $sp,0,$26
  45. .mask 0x0,0
  46. .prologue 0
  47. mov $14,$16 # register 14 holds args
  48. mov $15,$27 # register 15 holds apply
  49. jsr $26,($27) # call apply
  50. ldgp $26,0($26) # reload the global pointer
  51. mov $0,$16 # Thread_exit(apply(args))
  52. mov $13,$27 # register 13 has Thread_exit
  53. jsr $26,($27)
  54. call_pal 0
  55. .end _start
  56. .globl _ENDMONITOR
  57. _ENDMONITOR:
  58. #elif sparc
  59. .global __swtch
  60. .align 4
  61. .proc 4
  62. __swtch: save %sp,-(8+64),%sp
  63. st %fp,[%sp+64+0] ! save from's frame pointer
  64. st %i7,[%sp+64+4] ! save from's return address
  65. ta 3 ! flush from's registers
  66. st %sp,[%i0] ! save from's stack pointer
  67. ld [%i1],%sp ! load to's stack pointer
  68. ld [%sp+64+0],%fp ! restore to's frame pointer
  69. ld [%sp+64+4],%i7 ! restore to's return address
  70. ret ! continue execution of to
  71. restore
  72. .global __start
  73. .align 4
  74. .proc 4
  75. __start: ld [%sp+64+4],%o0
  76. ld [%sp+64],%o1
  77. call %o1; nop
  78. call _Thread_exit; nop
  79. unimp 0
  80. .global __ENDMONITOR
  81. __ENDMONITOR:
  82. #elif mips
  83. .text
  84. .globl _swtch
  85. .align 2
  86. .ent _swtch
  87. .set reorder
  88. _swtch: .frame $sp,88,$31
  89. subu $sp,88
  90. .fmask 0xfff00000,-48
  91. s.d $f20,0($sp)
  92. s.d $f22,8($sp)
  93. s.d $f24,16($sp)
  94. s.d $f26,24($sp)
  95. s.d $f28,32($sp)
  96. s.d $f30,40($sp)
  97. .mask 0xc0ff0000,-4
  98. sw $16,48+0($sp)
  99. sw $17,48+4($sp)
  100. sw $18,48+8($sp)
  101. sw $19,48+12($sp)
  102. sw $20,48+16($sp)
  103. sw $21,48+20($sp)
  104. sw $22,48+24($sp)
  105. sw $23,48+28($sp)
  106. sw $30,48+32($sp)
  107. sw $31,48+36($sp)
  108. sw $sp,0($4)
  109. lw $sp,0($5)
  110. l.d $f20,0($sp)
  111. l.d $f22,8($sp)
  112. l.d $f24,16($sp)
  113. l.d $f26,24($sp)
  114. l.d $f28,32($sp)
  115. l.d $f30,40($sp)
  116. lw $16,48+0($sp)
  117. lw $17,48+4($sp)
  118. lw $18,48+8($sp)
  119. lw $19,48+12($sp)
  120. lw $20,48+16($sp)
  121. lw $21,48+20($sp)
  122. lw $22,48+24($sp)
  123. lw $23,48+28($sp)
  124. lw $30,48+32($sp)
  125. lw $31,48+36($sp)
  126. addu $sp,88
  127. j $31
  128. .globl _start
  129. _start: move $4,$23 # register 23 holds args
  130. move $25,$30 # register 30 holds apply
  131. jal $25
  132. move $4,$2 # Thread_exit(apply(p))
  133. move $25,$21 # register 21 holds Thread_exit
  134. jal $25
  135. syscall
  136. .end _swtch
  137. .globl _ENDMONITOR
  138. _ENDMONITOR:
  139. #elif linux && i386
  140. .align 4
  141. .globl __swtch
  142. .globl _swtch
  143. __swtch:
  144. _swtch:
  145. subl $16,%esp
  146. movl %ebx,0(%esp)
  147. movl %esi,4(%esp)
  148. movl %edi,8(%esp)
  149. movl %ebp,12(%esp)
  150. movl 20(%esp),%eax
  151. movl %esp,0(%eax)
  152. movl 24(%esp),%eax
  153. movl 0(%eax),%esp
  154. movl 0(%esp),%ebx
  155. movl 4(%esp),%esi
  156. movl 8(%esp),%edi
  157. movl 12(%esp),%ebp
  158. addl $16, %esp
  159. ret
  160. .align 4
  161. .globl __thrstart
  162. .globl _thrstart
  163. __thrstart:
  164. _thrstart:
  165. pushl %edi
  166. call *%esi
  167. pushl %eax
  168. call Thread_exit
  169. .globl __ENDMONITOR
  170. .globl _ENDMONITOR
  171. __ENDMONITOR:
  172. _ENDMONITOR:
  173. #else
  174. Unsupported platform
  175. #endif