exstmisc.asm
上传用户:xiaoan1112
上传日期:2013-04-11
资源大小:19621k
文件大小:8k
源码类别:

操作系统开发

开发平台:

Visual C++

  1. page 49,132
  2. TITLE exstmisc.asm - misc. statement executors
  3. ;***
  4. ;exstmisc.asm - statement executors for QBI
  5. ;
  6. ; Copyright <C> 1986, Microsoft Corporation
  7. ;
  8. ;Purpose:
  9. ;
  10. ;
  11. ;****************************************************************************
  12. .xlist
  13. include version.inc
  14. EXSTMISC_ASM = ON
  15. IncludeOnce architec
  16. IncludeOnce context
  17. IncludeOnce executor
  18. IncludeOnce extort
  19. IncludeOnce exint
  20. IncludeOnce opstmt
  21. IncludeOnce opmin
  22. IncludeOnce opcontrl
  23. IncludeOnce opintrsc
  24. IncludeOnce opaftqb4
  25. IncludeOnce qbimsgs
  26. IncludeOnce rtinterp
  27. .list
  28. sBegin DATA
  29. sEnd DATA
  30. assumes es, NOTHING
  31. assumes ss, DATA
  32. EXTRN B$SERR:FAR
  33. sBegin CODE
  34. assumes cs, CODE
  35.     extrn   I4ToU2:near
  36. ;==============================================================================
  37. ; Error-related Statements
  38. ;==============================================================================
  39. MakeExe exStError,opStError
  40. ;note that error code is on stack here - - -
  41. CALLRT B$SERR,DispMov ;Never returns. DispMov variant used
  42. ;just so non-RELEASE case won't have
  43. ;non-RELEASE static data screwed up.
  44. ;Note that calling via ExToRt ensures
  45. ;that grs.GRS_oTxCur is set up for
  46. ;B$IONERR
  47. ;==============================================================================
  48. ; Sound-related Statements
  49. ;==============================================================================
  50. MakeExe exStBeep0,opStBeep
  51.     CALLRT  B$BEEP,Disp
  52. MakeExe exStPlay,opStPlay
  53. CALLRT B$SPLY,Disp
  54. MakeExe exStSound,opStSound
  55. ;Added with [11]
  56. sub sp,4 ;Make room for argument
  57. mov bx,sp
  58. fstp dword ptr DGROUP:[bx] ;Copy to local stack
  59. fwait
  60. ;End of [11]
  61. CALLRT B$SOND,Disp
  62. ;==============================================================================
  63. ; Heap-related Statements
  64. ;==============================================================================
  65. MakeExe exStDefSeg0,opStDefSeg0
  66. CALLRT B$DSG0,Disp
  67. MakeExe exStDefSeg1,opStDefSeg1
  68. call I4toU2 ;coerce I4 addr on stack to a U2
  69. CALLRT B$DSEG,Disp
  70. MakeExe exStPoke,opStPoke
  71. pop bx ;preserve value to be poked
  72. call I4toU2 ;coerce I4 addr on stack to a U2
  73. push bx ;(I4toU2 preserves bx)
  74. CALLRT B$POKE,Disp
  75. ;==============================================================================
  76. ; Math-related Statements
  77. ;==============================================================================
  78. MakeExe exStRandomize0,opStRandomize0
  79. CALLRT B$RNZ0,Disp
  80. MakeExe exStRandomize1,opStRandomize1
  81. ;Added with [11]
  82. sub sp,8 ;Make room for argument
  83. mov bx,sp
  84. fstp qword ptr DGROUP:[bx] ;Copy to local stack
  85. fwait
  86. ;End of [11]
  87. CALLRT B$RNZP,Disp
  88. ;==============================================================================
  89. ; READ/DATA Support
  90. ;==============================================================================
  91. ;NOTE: The actual READ executors are exactly the same as the INPUT executors,
  92. ;NOTE: so they share code in exio.asm
  93. ;NOTE: The otxFirst field is a pointer to the link field in the first DATA
  94. ;NOTE: statement in the module. The otxCur field, however, is a pointer to
  95. ;NOTE: the exStData pcode - - - this inconsistency is required by the scanner,
  96. ;NOTE: which treats otxFirst as an otx head-of-chain, and otxCur as a 'normal'
  97. ;NOTE: otx - - - each of which is updated differently for Edit & CONTinue.
  98. ;NOTE: The oLineCur initialization value is 6 bytes to account for the fact
  99. ;NOTE: that otxCur points to the exStData pcode.
  100. MakeExe exStRestore0,opStRestore0
  101. xor cx,cx ;remember this is exStRestore0
  102. jmp short Restore_Common
  103. MakeExe exStRestore1,opStRestore1
  104. DbAssertRel ax,nz,0,CODE,<exStRestore1 finds AX == 0>
  105. xchg ax,cx ;cx != 0 indicates exStRestore1
  106. LODSWTX ;ax = oTx. We want the next READ
  107. ;  to use the first piece of 
  108. ;  data in the first DATA stmt
  109. ;  found subsequent to this oTx
  110. Restore_Common:
  111. call GetDataSeg ;set up bx and es (preserves ax)
  112. mov di,PTRRS[bx.MRS_data_otxFirst] ; oTx of link field of first DATA
  113. ;  statement
  114. mov es,dx
  115. jcxz Restore_Common1 ;brif exStRestore0
  116. Walk_Data_Stmts:
  117. cmp ax,di
  118. jbe Restore_Common1 ;brif di contains oTx we want to
  119. ;  restore to
  120. DbAssertRel di,nz,UNDEFINED,CODE,<exStRestore1 error2>
  121. ;if di == UNDEFINED, the above branch should have been taken
  122. mov di,es:[di] ;move to next DATA stmt, if any
  123. jmp short Walk_Data_Stmts
  124. Restore_Common1: ;di = oTx to the link field
  125. ;  of a DATA statement
  126. inc di
  127. .errnz UNDEFINED - 0FFFFH
  128. jz Restore_Common2 ;brif no DATA statements
  129. sub di,5 ;di = oTx to exStData
  130. GETRS_SEG  es
  131. mov PTRRS[bx.MRS_data_otxCur],di
  132. mov PTRRS[bx.MRS_data_oLineCur],6 ; offset into current DATA stmt
  133. Restore_Common2:
  134. jmp DispMov ;NOTE: just using the 'Mov'
  135. ;NOTE: varient of 'Disp' so that
  136. ;NOTE: DI & ES will get reloaded
  137. ;Helper routine for B$IRDPTR and B$IRDPTRUPD, below - - - returns
  138. ;  the segment part of the address of mrsCur in ES. Note that DATA statements
  139. ;  are NEVER found at proc level, because QBI moves all DATA statements to
  140. ;  module level at text insertion.
  141. ;Output:
  142. ; dx = segment of current mrs table
  143. ; bx = pMrsCur
  144. ; es = segment of the global Rs table
  145. ;Preserves: ax, cx
  146. GetDataSeg  PROC NEAR
  147. mov bx,[grs.GRS_oMrsCur]
  148. RS_BASE add,bx
  149. GETRS_SEG  es
  150. GETSEG dx,PTRRS[bx.MRS_txd.TXD_bdlText_seg] ;[4][2]
  151. ret
  152. GetDataSeg  ENDP
  153. ;***
  154. ;B$IRDPTR - call back to give far ptr to runtime for next data item to read
  155. ;Input:
  156. ; none
  157. ;Output: 
  158. ; far ptr to data item in DS:SI
  159. ;Destroys:
  160. ; ES
  161. ;Exceptions:
  162. ; Runtime error if no more data to be read
  163. ;*******************************************************************************
  164. PUBLIC B$IRDPTR
  165. B$IRDPTR PROC FAR
  166. mov bx,[grs.GRS_oMrsCur]
  167. RS_BASE add,bx
  168. GETRS_SEG es ; es:bx points to mrsCur
  169. mov si,PTRRS[bx.MRS_data_otxCur]
  170. inc si
  171. .errnz UNDEFINED - 0FFFFH
  172. jz Out_Of_Data
  173. dec si
  174. add si,PTRRS[bx.MRS_data_oLineCur] ; ax now oTx of next item to read
  175. call GetDataSeg ; returns seg in dx
  176. push dx
  177. pop ds
  178. RET
  179. Out_Of_Data:
  180. mov al,ER_OD ;Out of Data error
  181. call RtErrorNoSi ;never returns - runtime error
  182. B$IRDPTR ENDP
  183. ;***
  184. ;B$IRDPTRUPD - call back to allow us to update data ptr after a READ occurs
  185. ;Input:
  186. ; AL = 0 if last item was just read in current DATA statement, non-zero
  187. ; otherwise
  188. ; BX = Number of bytes 'eaten' by the latest READ.
  189. ;Output:
  190. ; current mrs (in the global Rs table) updated with correct data pointer
  191. ;Destroys:
  192. ; ES
  193. ;*******************************************************************************
  194. PUBLIC B$IRDPTRUPD
  195. B$IRDPTRUPD PROC FAR
  196. xchg ax,cx ;remember if @ end of DATA stmt
  197. xchg ax,bx
  198. mov bx,[grs.GRS_oMrsCur]
  199. RS_BASE add,bx
  200. GETRS_SEG  es
  201. add PTRRS[bx.MRS_data_oLineCur],ax ; assume not end of data stmt
  202. or cl,cl
  203. jnz RTPTRUPD_Exit ;brif not end of DATA stmt
  204. call GetDataSeg ;seg address is in dx, Rs seg in es
  205. mov ax,bx
  206. mov bx,PTRRS[bx.MRS_data_otxCur]
  207. DbAssertRel bx,nz,UNDEFINED,CODE,<B$IRDPTRUPD error in exstmisc.asm>
  208. mov es,dx ; mrs text seg
  209. mov dx,es:[bx+4] ;dx = pointer to link field of
  210. ; next DATA stmt or UNDEFINED
  211. inc dx
  212. .errnz UNDEFINED - 0FFFFH
  213. jnz Not_EndOf_Data ;brif not end of data
  214. mov dl,4 ;so sub dx,5 will set dx = FFFF
  215. Not_EndOf_Data:
  216. xchg ax,bx
  217. sub dx,5 ;dx = UNDEFINED or pointer to
  218. ;  an exStData pcode
  219. GETRS_SEG es
  220. mov PTRRS[bx.MRS_data_otxCur],dx
  221. mov PTRRS[bx.MRS_data_oLineCur],6
  222. RTPTRUPD_Exit:
  223. RET
  224. B$IRDPTRUPD ENDP
  225. ;==============================================================================
  226. ; SWAP
  227. ;==============================================================================
  228. .errnz SizeD
  229. MakeExe exStSwap2,opStSwap
  230. inc si
  231. inc si
  232. CALLRT B$SWP2,Disp
  233. MakeExe exStSwap4,opStSwap
  234. inc si
  235. inc si
  236. CALLRT B$SWP4,Disp
  237. MakeExe exStSwap8,opStSwap
  238. inc si
  239. inc si
  240. CALLRT B$SWP8,Disp
  241. MakeExe exStSwapSD,opStSwap
  242. inc si
  243. inc si
  244. pop ax
  245. pop bx
  246. xor cx,cx
  247. push ds
  248. push bx
  249. push cx
  250. push ds
  251. push ax
  252. push cx
  253. CALLRT B$SWPN,Disp
  254. MakeExe exStSwapTyp,opStSwap
  255. LODSWTX ;Get size to swap
  256. pop dx
  257. pop bx
  258. push ax ;Add length to arg on stack
  259. push bx
  260. push dx
  261. push ax
  262. CALLRT B$SWPN,Disp
  263. ;seg_code = segment address for the CODE segment
  264. ;It can be referenced from any module as follows:
  265. ; EXTRN seg_code:abs
  266. ; mov ax,SEG seg_code
  267. PUBLIC seg_code
  268. seg_code EQU SEG B$IRDPTRUPD
  269. sEnd CODE
  270. end