emuMainALib.s
上传用户:baixin
上传日期:2008-03-13
资源大小:4795k
文件大小:35k
开发平台:

MultiPlatform

  1. /* Copyright 1991-2001 Wind River Systems, Inc. */
  2. /*
  3. modification history
  4. --------------------
  5. 01f,28aug01,hdn  replaced .align with .balign
  6.  replaced FUNC with GTEXT/GDATA macros for global symbols.
  7.  added FUNC / FUNC_LABEL
  8.  assembly syntax has become more stringent for
  9.  indirect call instructions. '*' prefix now needed.
  10. 01e,12feb97,hdn  fixed a bug in fxchs. (SPR#7920)
  11. 01d,24oct96,yp   stuck in a # in USSC mailing addr so cpp will work 
  12. 01c,26sep95,hdn  implemented USSW's latest emumain.s.
  13. 01b,06sep95,hdn  changed .comm to .lcomm to make them contiguous.
  14. 01a,24jan95,hdn  original US Software version.
  15. */
  16. #* * * * * * * * * *
  17. #       Filename:   EMUMAIN.ASM
  18. #
  19. #       Copyright (C) 1990,1991 By
  20. #       # United States Software Corporation
  21. #       # 14215 N.W. Science Park Drive
  22. #       # Portland, Oregon 97229
  23. #
  24. #       This software is furnished under a license and may be used
  25. #       and copied only in accordance with the terms of such license
  26. #       and with the inclusion of the above copyright notice.
  27. #       This software or any other copies thereof may not be provided
  28. #       or otherwise made available to any other person.  No title to
  29. #       and ownership of the software is hereby transferred.
  30. #
  31. #       The information in this software is subject to change without
  32. #       notice and should not be construed as a commitment by United
  33. #       States Software Corporation.
  34. #
  35. #       Version:        See VSNLOG.TXT
  36. #       Released:       1 March 1991
  37. #
  38. #* * * * * * * * * *
  39. #define _ASMLANGUAGE
  40. #include "vxWorks.h"
  41. #include "asm.h"
  42. .data
  43. .globl FUNC(copyright_wind_river)
  44. .long FUNC(copyright_wind_river)
  45. .include "emuIncALib.s"
  46. .text
  47. .globl emuret,exret
  48. #        extrn   witoep:near,eptowi:near,sitoep:near,eptosi:near
  49. #        extrn   litoep:near,eptoli:near,pdtoep:near,eptopd:near
  50. #        extrn   fptoep:near,eptofp:near,dptoep:near,eptodp:near
  51. #        extrn   eptoep:near
  52. #        extrn   getqn:near
  53. #        extrn   epadd:near,epsub:near,epsubr:near,epmul:near
  54. #        extrn   epdiv:near,epdivr:near,eprem:near
  55. #        extrn   epcomp:near,epcomu:near,epexam:near,eptown:near,epsqrt:near
  56. #        extrn   rounde:near,roundx:near,exproc:near
  57. #        extrn   xtract:near,scale:near
  58. #        extrn   epf2xm1:near,epsin:near,epcos:near,eptan:near
  59. #        extrn   eplog:near,eplog1:near,epatan:near
  60. #        extrn   reduct:near
  61. #        extrn   exir_no:abs
  62. #        extrn   ENIRS:abs
  63. #DGROUP  GROUP   hwseg
  64. #CGROUP  GROUP   emuseg
  65. #hwseg   segment RW page public 'DATA'
  66. #        assume  ds:DGROUP, es:DGROUP, ss:DGROUP
  67. .globl h_ctrl,h_stat,s_iptr,s_memp
  68. .lcomm s_stk,256
  69. .lcomm s_fpsp,4
  70. .lcomm s_iptr,4
  71. .lcomm s_memp,4
  72. .lcomm h_ctrl,4
  73. .lcomm h_stat,4
  74. .lcomm h_tag,4
  75. #hwseg   ends
  76. #emuseg  segment public USE32 'CODE'
  77. #        assume  cs:CGROUP
  78. # address tables for floating-point instructions
  79. instab: .long faddfp,fmulfp,fcomfp,fcompfp,fsubfp,fsubrfp,fdivfp,fdivrfp
  80. .long fldfp,NONE_,fstf,fstpf,fldenv_,fldcwc,fstenv_,fstcwc
  81. .long faddsi,fmulsi,fcomsi,fcompsi,fsubsi,fsubrsi,fdivsi,fdivrsi
  82. .long fldsi,NONE_,fisti,fistpi,NONE_,flde,NONE_,fstpe
  83. .long fadddp,fmuldp,fcomdp,fcompdp,fsubdp,fsubrdp,fdivdp,fdivrdp
  84. .long flddp,NONE_,fstd,fstpd,frstor_,NONE_,fsave_,fstsw_
  85. .long faddwi,fmulwi,fcomwi,fcompwi,fsubwi,fsubrwi,fdivwi,fdivrwi
  86. .long fldwi,NONE_,fistw,fistpw,fbldp,fildl,fbstpp,fistpl
  87. instas: .long fadds,fmuls,fcoms,fcomps,fsubs,fsubrs,fdivs,fdivrs
  88. .long flds,fxchs,fnop_,fstps,is1,is8,is2,is3
  89. .long NONE_,NONE_,NONE_,NONE_,NONE_,fucompps,NONE_,NONE_
  90. .long NONE_,NONE_,NONE_,NONE_,is5,NONE_,NONE_,NONE_
  91. .long faddx,fmulx,NONE_,NONE_,fsubx,fsubrx,fdivx,fdivrx
  92. .long ffree_,NONE_,fsts,fstps,fucoms,fucomps,NONE_,NONE_
  93. .long faddpx,fmulpx,NONE_,fcompps,fsubpx,fsubrpx,fdivrpx,fdivpx
  94. .long NONE_,NONE_,NONE_,NONE_,fstswax_,NONE_,NONE_,NONE_
  95. .balign 16,0x90
  96. .globl GTEXT(emuInit)
  97. FUNC_LABEL(emuInit)
  98. fninit
  99. ret
  100. .balign 16,0x90
  101. .globl GTEXT(emu387)
  102. FUNC_LABEL(emu387)
  103. #       test    byte ptr [esp+9],2 ;enable interrupts, unless they were
  104. .word ENIRS
  105. .byte 0x24,0x09,0x02
  106. jz emu3 #   disabled initially
  107. sti
  108. emu3: pusha #save all general registers
  109. subl $s_len,%esp #reserve a frame on the stack
  110. movl %esp,%ebp
  111. cld
  112. addl $12,s_sp(%ebp)
  113. movl s_ip(%ebp),%esi #address of FP instruction -> esi
  114. emu86:
  115. .byte 0x2e #from cs: but assembler seems defective
  116. lodsw #pick up the instruction
  117. cmpb $0x0d8,%al
  118. jc emu84
  119. emu11: movl %eax,%edx #build 6-bit instruction index -> edx
  120. shlb $2,%dh
  121. rolw $3,%dx
  122. andl $0x3f,%edx
  123. movb %ah,%bl #build R/M code
  124. andl $7,%ebx #   and leave in bl for the following
  125. cmpb $0x0c0,%ah #MOD 3 uses no memory addressing
  126. jnc emu50
  127. xorl %edi,%edi #handle possible s-i-b
  128. cmpb $4,%bl
  129. jnz emu26
  130. .byte 0x2e #from cs: 
  131. lodsb
  132. movb %al,%bl
  133. andb $7,%bl
  134. shldl $31,%eax,%edi
  135. andl $7*4,%edi
  136. subl $4*4,%edi
  137. jz emu26
  138. movb %al,%cl #scaled index
  139. shrb $6,%cl
  140. negl %edi
  141. movl s_di+28-16(%ebp,%edi),%edi
  142. shll %cl,%edi
  143. emu26: addb %ah,%ah #take displacement -> ax
  144. js emu24 #   MOD 01 reg+d8
  145. jc emu25 #   MOD 10 reg+d32
  146. cmpb $5,%bl #   MOD 00 reg; reg5 = d32
  147. jnz emu27
  148. .byte 0x2e #from cs:
  149. lodsl
  150. jmp emu42
  151. emu27: xorl %eax,%eax
  152. jmp emu29
  153. emu25:
  154. .byte 0x2e #from cs:
  155. lodsl
  156. jmp emu29
  157. emu24:
  158. .byte 0x2e #from cs: 
  159. lodsb
  160. movsbl %al,%eax
  161. emu29: negl %ebx #add the base register
  162. addl s_di+28(%ebp,%ebx,4),%eax
  163. emu42: addl %edi,%eax #possible scaled index
  164. xchgl %esi,s_ip(%ebp) #update return address
  165. call *%cs:instab(,%edx,4) #call instruction handler
  166. emu51: movl s_ip(%ebp),%esi #if next instruction is ESC, repeat
  167. .byte 0x2e #from cs: but assembler seems defective
  168. lodsw
  169. xorb $0x0d8,%al
  170. cmpb $8,%al
  171. jc emu11
  172. addl $s_len,%esp #free the stack frame
  173. popa #restore registers
  174. emuret: iret
  175. emu50: xchgl %esi,s_ip(%ebp) #update return address
  176. call *%cs:instas(,%edx,4) #call instruction handler
  177. jmp emu51
  178. exret: addl $s_len,%esp #exception return
  179. popa
  180. .byte 0x0cd,EXIRNO #INT exception interrupt
  181. iret
  182. emu84: decl %esi #illegal prefix, skip
  183. jmp emu86
  184. #emu387  endp
  185. intrn:
  186. flddp: #push from memory
  187. andb $0x0fd,h_stat+1
  188. call dptoep
  189. #STPUSHP
  190. movl s_fpsp,%ebx
  191. subb $32,%bl
  192. cmpb $3,s_stk+10(%ebx)
  193. jnz stackof
  194. movl %ebx,s_fpsp
  195. addl $s_stk,%ebx
  196. movl %eax,(%ebx)
  197. movl %edx,4(%ebx)
  198. movl %ecx,8(%ebx)
  199. ret
  200. fstd: #fetch as double-precision
  201. #SAVEIX
  202. movl %eax,s_memp
  203. xchgl %esi,%eax
  204. movl %eax,s_iptr
  205. #STTOP   
  206. movl s_fpsp,%edi
  207. addl $s_stk,%edi
  208. #GETEP   
  209. movl (%edi),%eax
  210. movl 4(%edi),%edx
  211. movl 8(%edi),%ecx
  212. call eptodp
  213. movl %eax,(%esi)
  214. movl %edx,4(%esi)
  215. ret
  216. fstpd: #fetch as double-precision, pop
  217. #SAVEIX
  218. movl %eax,s_memp
  219. xchgl %esi,%eax
  220. movl %eax,s_iptr
  221. #STTOP   
  222. movl s_fpsp,%edi
  223. addl $s_stk,%edi
  224. #GETEP   
  225. movl (%edi),%eax
  226. movl 4(%edi),%edx
  227. movl 8(%edi),%ecx
  228. call eptodp
  229. movl %eax,(%esi)
  230. movl %edx,4(%esi)
  231. #STPOPq
  232. movb $3,10(%edi)
  233. addb $32,s_fpsp
  234. ret
  235. fadddp: #ST = ST + memory
  236. call dptoep
  237. #STTOP   
  238. movl s_fpsp,%edi
  239. addl $s_stk,%edi
  240. call epadd
  241. jmp rounde
  242. fsubdp: #ST = ST - memory
  243. call dptoep
  244. #STTOP   
  245. movl s_fpsp,%edi
  246. addl $s_stk,%edi
  247. call epsubr
  248. jmp rounde
  249. fmuldp: #ST = ST * memory
  250. call dptoep
  251. #STTOP   
  252. movl s_fpsp,%edi
  253. addl $s_stk,%edi
  254. call epmul
  255. jmp rounde
  256. fdivdp: #ST = ST / memory
  257. call dptoep
  258. #STTOP   
  259. movl s_fpsp,%edi
  260. addl $s_stk,%edi
  261. call epdivr
  262. jmp rounde
  263. fsubrdp: #ST = memory - ST
  264. call dptoep
  265. #STTOP   
  266. movl s_fpsp,%edi
  267. addl $s_stk,%edi
  268. call epsub
  269. jmp rounde
  270. fdivrdp: #ST = memory / ST
  271. call dptoep
  272. #STTOP   
  273. movl s_fpsp,%edi
  274. addl $s_stk,%edi
  275. call epdiv
  276. jmp rounde
  277. fsqrt_: #square-root of ST
  278. #STTOP   
  279. movl s_fpsp,%edi
  280. addl $s_stk,%edi
  281. #GETEP   
  282. movl (%edi),%eax
  283. movl 4(%edi),%edx
  284. movl 8(%edi),%ecx
  285. call epsqrt
  286. jmp rounde
  287. fcomdp: #ST - memory -> codes
  288. orb $0x45,h_stat+1
  289. call dptoep
  290. #STTOP   
  291. movl s_fpsp,%edi
  292. addl $s_stk,%edi
  293. jmp epcomp
  294. fcompdp: #ST - memory -> codes, pop
  295. orb $0x45,h_stat+1
  296. call dptoep
  297. #STTOP   
  298. movl s_fpsp,%edi
  299. addl $s_stk,%edi
  300. call epcomp
  301. #STPOPq
  302. movb $3,10(%edi)
  303. addb $32,s_fpsp
  304. ret
  305. faddfp: #ST = ST + memory
  306. call fptoep
  307. #STTOP   
  308. movl s_fpsp,%edi
  309. addl $s_stk,%edi
  310. call epadd
  311. jmp rounde
  312. faddwi: #ST = ST + memory
  313. call witoep
  314. jmp .+7
  315. faddsi: #ST = ST + memory
  316. call sitoep
  317. #STTOP   
  318. movl s_fpsp,%edi
  319. addl $s_stk,%edi
  320. call epadd
  321. jmp rounde
  322. fmulfp: #ST = ST * memory
  323. call fptoep
  324. #STTOP   
  325. movl s_fpsp,%edi
  326. addl $s_stk,%edi
  327. call epmul
  328. jmp rounde
  329. fmulwi: #ST = ST * memory
  330. call witoep
  331. jmp .+7
  332. fmulsi: #ST = ST * memory
  333. call sitoep
  334. #STTOP   
  335. movl s_fpsp,%edi
  336. addl $s_stk,%edi
  337. call epmul
  338. jmp rounde
  339. fcomfp: #ST - memory -> codes
  340. orb $0x45,h_stat+1
  341. call fptoep
  342. #STTOP   
  343. movl s_fpsp,%edi
  344. addl $s_stk,%edi
  345. jmp epcomp
  346. fcomsi: #ST - memory -> codes
  347. call sitoep
  348. #STTOP   
  349. movl s_fpsp,%edi
  350. addl $s_stk,%edi
  351. jmp epcomp
  352. fcomwi: #ST - memory -> codes
  353. call witoep
  354. #STTOP   
  355. movl s_fpsp,%edi
  356. addl $s_stk,%edi
  357. jmp epcomp
  358. fcompfp: #ST - memory -> codes, pop
  359. orb $0x45,h_stat+1
  360. call fptoep
  361. #STTOP   
  362. movl s_fpsp,%edi
  363. addl $s_stk,%edi
  364. call epcomp
  365. #STPOPq
  366. movb $3,10(%edi)
  367. addb $32,s_fpsp
  368. ret
  369. fcompwi: #ST - memory -> codes, pop
  370. call witoep
  371. jmp .+7
  372. fcompsi: #ST - memory -> codes, pop
  373. call sitoep
  374. #STTOP   
  375. movl s_fpsp,%edi
  376. addl $s_stk,%edi
  377. call epcomp
  378. #STPOPq
  379. movb $3,10(%edi)
  380. addb $32,s_fpsp
  381. ret
  382. fsubfp: #ST = ST - memory
  383. call fptoep
  384. #STTOP   
  385. movl s_fpsp,%edi
  386. addl $s_stk,%edi
  387. call epsubr
  388. jmp rounde
  389. fsubwi: #ST = ST - memory
  390. call witoep
  391. jmp .+7
  392. fsubsi: #ST = ST - memory
  393. call sitoep
  394. #STTOP   
  395. movl s_fpsp,%edi
  396. addl $s_stk,%edi
  397. call epsubr
  398. jmp rounde
  399. fsubrfp: #ST = memory - ST
  400. call fptoep
  401. #STTOP   
  402. movl s_fpsp,%edi
  403. addl $s_stk,%edi
  404. call epsub
  405. jmp rounde
  406. fsubrwi: #ST = memory - ST
  407. call witoep
  408. jmp .+7
  409. fsubrsi: #ST = memory - ST
  410. call sitoep
  411. #STTOP   
  412. movl s_fpsp,%edi
  413. addl $s_stk,%edi
  414. call epsub
  415. jmp rounde
  416. fdivfp: #ST = ST / memory
  417. call fptoep
  418. #STTOP   
  419. movl s_fpsp,%edi
  420. addl $s_stk,%edi
  421. call epdivr
  422. jmp rounde
  423. fdivwi: #ST = ST / memory
  424. call witoep
  425. jmp .+7
  426. fdivsi: #ST = ST / memory
  427. call sitoep
  428. #STTOP   
  429. movl s_fpsp,%edi
  430. addl $s_stk,%edi
  431. call epdivr
  432. jmp rounde
  433. fdivrfp: #ST = memory / ST
  434. call fptoep
  435. #STTOP   
  436. movl s_fpsp,%edi
  437. addl $s_stk,%edi
  438. call epdiv
  439. jmp rounde
  440. fdivrwi: #ST = memory / ST
  441. call witoep
  442. jmp .+7
  443. fdivrsi: #ST = memory / ST
  444. call sitoep
  445. #STTOP   
  446. movl s_fpsp,%edi
  447. addl $s_stk,%edi
  448. call epdiv
  449. jmp rounde
  450. fadds: #ST = ST + ST(i)
  451. #SAVEIN
  452. movl %esi,s_iptr
  453. #GETEPS  ebx
  454. movl s_fpsp,%eax
  455. movl %eax,%edi
  456. addl $s_stk,%edi
  457. shll $5,%ebx
  458. addb %bl,%al
  459. addl $s_stk,%eax
  460. movl 8(%eax),%ecx
  461. movl 4(%eax),%edx
  462. movl (%eax),%eax
  463. call epadd
  464. jmp rounde
  465. fmuls: #ST = ST * ST(i)
  466. #SAVEIN
  467. movl %esi,s_iptr
  468. #GETEPS  ebx
  469. movl s_fpsp,%eax
  470. movl %eax,%edi
  471. addl $s_stk,%edi
  472. shll $5,%ebx
  473. addb %bl,%al
  474. addl $s_stk,%eax
  475. movl 8(%eax),%ecx
  476. movl 4(%eax),%edx
  477. movl (%eax),%eax
  478. call epmul
  479. jmp rounde
  480. fcoms: #ST - ST(i) -> codes
  481. #SAVEIN
  482. movl %esi,s_iptr
  483. #GETEPS  ebx
  484. movl s_fpsp,%eax
  485. movl %eax,%edi
  486. addl $s_stk,%edi
  487. shll $5,%ebx
  488. addb %bl,%al
  489. addl $s_stk,%eax
  490. movl 8(%eax),%ecx
  491. movl 4(%eax),%edx
  492. movl (%eax),%eax
  493. jmp epcomp
  494. fcomps: #ST - ST(i) -> codes, pop
  495. #SAVEIN
  496. movl %esi,s_iptr
  497. #GETEPS  ebx
  498. movl s_fpsp,%eax
  499. movl %eax,%edi
  500. addl $s_stk,%edi
  501. shll $5,%ebx
  502. addb %bl,%al
  503. addl $s_stk,%eax
  504. movl 8(%eax),%ecx
  505. movl 4(%eax),%edx
  506. movl (%eax),%eax
  507. call epcomp
  508. #STPOPq
  509. movb $3,10(%edi)
  510. addb $32,s_fpsp
  511. ret
  512. fsubs: #ST = ST - ST(i)
  513. #SAVEIN
  514. movl %esi,s_iptr
  515. #GETEPS  ebx
  516. movl s_fpsp,%eax
  517. movl %eax,%edi
  518. addl $s_stk,%edi
  519. shll $5,%ebx
  520. addb %bl,%al
  521. addl $s_stk,%eax
  522. movl 8(%eax),%ecx
  523. movl 4(%eax),%edx
  524. movl (%eax),%eax
  525. call epsubr
  526. jmp rounde
  527. fsubrs: #ST = ST(i) - ST
  528. #SAVEIN
  529. movl %esi,s_iptr
  530. #GETEPS  ebx
  531. movl s_fpsp,%eax
  532. movl %eax,%edi
  533. addl $s_stk,%edi
  534. shll $5,%ebx
  535. addb %bl,%al
  536. addl $s_stk,%eax
  537. movl 8(%eax),%ecx
  538. movl 4(%eax),%edx
  539. movl (%eax),%eax
  540. call epsub
  541. jmp rounde
  542. fdivs: #ST = ST / ST(i)
  543. #SAVEIN
  544. movl %esi,s_iptr
  545. #GETEPS  ebx
  546. movl s_fpsp,%eax
  547. movl %eax,%edi
  548. addl $s_stk,%edi
  549. shll $5,%ebx
  550. addb %bl,%al
  551. addl $s_stk,%eax
  552. movl 8(%eax),%ecx
  553. movl 4(%eax),%edx
  554. movl (%eax),%eax
  555. call epdivr
  556. jmp rounde
  557. fdivrs: #ST = ST(i) / ST
  558. #SAVEIN
  559. movl %esi,s_iptr
  560. #GETEPS  ebx
  561. movl s_fpsp,%eax
  562. movl %eax,%edi
  563. addl $s_stk,%edi
  564. shll $5,%ebx
  565. addb %bl,%al
  566. addl $s_stk,%eax
  567. movl 8(%eax),%ecx
  568. movl 4(%eax),%edx
  569. movl (%eax),%eax
  570. call epdiv
  571. jmp rounde
  572. fldfp: #push from memory
  573. andb $0x0fd,h_stat+1
  574. call fptoep
  575. #STPUSHP
  576. movl s_fpsp,%ebx
  577. subb $32,%bl
  578. cmpb $3,s_stk+10(%ebx)
  579. jnz stackof
  580. movl %ebx,s_fpsp
  581. addl $s_stk,%ebx
  582. movl %eax,(%ebx)
  583. movl %edx,4(%ebx)
  584. movl %ecx,8(%ebx)
  585. ret
  586. fldsi: #push from memory
  587. andb $0x0fd,h_stat+1
  588. call sitoep
  589. #STPUSHP
  590. movl s_fpsp,%ebx
  591. subb $32,%bl
  592. cmpb $3,s_stk+10(%ebx)
  593. jnz stackof
  594. movl %ebx,s_fpsp
  595. addl $s_stk,%ebx
  596. movl %eax,(%ebx)
  597. movl %edx,4(%ebx)
  598. movl %ecx,8(%ebx)
  599. ret
  600. fldwi: #push from memory
  601. andb $0x0fd,h_stat+1
  602. call witoep
  603. #STPUSHP
  604. movl s_fpsp,%ebx
  605. subb $32,%bl
  606. cmpb $3,s_stk+10(%ebx)
  607. jnz stackof
  608. movl %ebx,s_fpsp
  609. addl $s_stk,%ebx
  610. movl %eax,(%ebx)
  611. movl %edx,4(%ebx)
  612. movl %ecx,8(%ebx)
  613. ret
  614. fstf: #fetch as single-precision
  615. #SAVEIX
  616. movl %eax,s_memp
  617. xchgl %esi,%eax
  618. movl %eax,s_iptr
  619. #STTOP   
  620. movl s_fpsp,%edi
  621. addl $s_stk,%edi
  622. #GETEP   
  623. movl (%edi),%eax
  624. movl 4(%edi),%edx
  625. movl 8(%edi),%ecx
  626. call eptofp
  627. movl %eax,(%esi)
  628. ret
  629. fstpf: #pop as single-precision 
  630. #SAVEIX
  631. movl %eax,s_memp
  632. xchgl %esi,%eax
  633. movl %eax,s_iptr
  634. #STTOP   
  635. movl s_fpsp,%edi
  636. addl $s_stk,%edi
  637. #GETEP   
  638. movl (%edi),%eax
  639. movl 4(%edi),%edx
  640. movl 8(%edi),%ecx
  641. call eptofp
  642. movl %eax,(%esi)
  643. #STPOPq
  644. movb $3,10(%edi)
  645. addb $32,s_fpsp
  646. ret
  647. fldcwc: #load control word
  648. movw (%eax),%ax
  649. andw $0x1f7f,%ax
  650. orb $0x40,%al
  651. movw %ax,h_ctrl
  652. ret
  653. fstcwc: #store control word
  654. movl %eax,%edi
  655. movw h_ctrl,%ax
  656. stosw
  657. ret
  658. flds: #ST = ST(i)
  659. #SAVEIN
  660. movl %esi,s_iptr
  661. andb $0x0fd,h_stat+1
  662. #STIX    ebx
  663. movl s_fpsp,%eax
  664. shll $5,%ebx
  665. addb %bl,%al
  666. addl $s_stk,%eax
  667. xchgl %edi,%eax
  668. #GETEP   
  669. movl (%edi),%eax
  670. movl 4(%edi),%edx
  671. movl 8(%edi),%ecx
  672. #STPUSHP
  673. movl s_fpsp,%ebx
  674. subb $32,%bl
  675. cmpb $3,s_stk+10(%ebx)
  676. jnz stackof
  677. movl %ebx,s_fpsp
  678. addl $s_stk,%ebx
  679. movl %eax,(%ebx)
  680. movl %edx,4(%ebx)
  681. movl %ecx,8(%ebx)
  682. ret
  683. fxchs: #exchange ST and ST(i)
  684. #SAVEIN
  685. movl %esi,s_iptr
  686. andb $0x0fd,h_stat+1
  687. movl s_fpsp,%eax
  688. addl $s_stk,%eax
  689. movl (%eax),%edi
  690. movl 4(%eax),%edx
  691. movl 8(%eax),%ecx
  692. subl $s_stk,%eax
  693. shll $5,%ebx
  694. addb %bl,%al
  695. addl $s_stk,%eax
  696. xchgl %edi,(%eax)
  697. xchgl %edx,4(%eax)
  698. xchgl %ecx,8(%eax)
  699. subl $s_stk,%eax
  700. subb %bl,%al
  701. addl $s_stk,%eax
  702. movl %edi,(%eax)
  703. movl %edx,4(%eax)
  704. movl %ecx,8(%eax)
  705. ret
  706. fnop_: #no operation
  707. #SAVEIN
  708. movl %esi,s_iptr
  709. ret
  710. fstps: #ST(i) = ST and pop
  711. #SAVEIN
  712. movl %esi,s_iptr
  713. andb $0x0fd,h_stat+1
  714. movl s_fpsp,%eax
  715. addl $s_stk,%eax
  716. movl %eax,%edi
  717. movl (%eax),%esi
  718. movl 4(%eax),%edx
  719. movl 8(%eax),%ecx
  720. shll $5,%ebx
  721. subl $s_stk,%eax
  722. addb %bl,%al
  723. addl $s_stk,%eax
  724. movl %esi,(%eax)
  725. movl %edx,4(%eax)
  726. movl %ecx,8(%eax)
  727. #STPOPq
  728. movb $3,10(%edi)
  729. addb $32,s_fpsp
  730. ret
  731. fucoms: #ST - ST(i) -> codes
  732. #SAVEIN
  733. movl %esi,s_iptr
  734. #GETEPS  ebx
  735. movl s_fpsp,%eax
  736. movl %eax,%edi
  737. addl $s_stk,%edi
  738. shll $5,%ebx
  739. addb %bl,%al
  740. addl $s_stk,%eax
  741. movl 8(%eax),%ecx
  742. movl 4(%eax),%edx
  743. movl (%eax),%eax
  744. jmp epcomu
  745. fucomps: #ST - ST(i) -> codes, pop
  746. #SAVEIN
  747. movl %esi,s_iptr
  748. #GETEPS  ebx
  749. movl s_fpsp,%eax
  750. movl %eax,%edi
  751. addl $s_stk,%edi
  752. shll $5,%ebx
  753. addb %bl,%al
  754. addl $s_stk,%eax
  755. movl 8(%eax),%ecx
  756. movl 4(%eax),%edx
  757. movl (%eax),%eax
  758. call epcomu
  759. #STPOPq
  760. movb $3,10(%edi)
  761. addb $32,s_fpsp
  762. ret
  763. is1t: .long fchs_,fabs_,NONE_,NONE_,ftst_,fxam_,NONE_,NONE_
  764. is1:
  765. #SAVEIN
  766. movl %esi,s_iptr
  767. jmp *%cs:is1t(,%ebx,4)
  768. fchs_: #ST = -ST
  769. andb $0x0fd,h_stat+1
  770. #STTOP   
  771. movl s_fpsp,%edi
  772. addl $s_stk,%edi
  773. xorb $0x80,11(%edi)
  774. ret
  775. fabs_: #ST = |ST|
  776. andb $0x0fd,h_stat+1
  777. #STTOP   
  778. movl s_fpsp,%edi
  779. addl $s_stk,%edi
  780. andb $0x7f,11(%edi)
  781. ret
  782. ftst_: #set codes according to ST
  783. #STTOP   
  784. movl s_fpsp,%edi
  785. addl $s_stk,%edi
  786. movl $0x00010000,%ecx
  787. xorl %eax,%eax
  788. xorl %edx,%edx
  789. jmp epcomp
  790. fxam_: #set codes according to ST
  791. andb $0x0b8,h_stat+1
  792. movl s_fpsp,%edi
  793. addl $s_stk,%edi
  794. cmpb $3,10(%edi)
  795. jz fxa9
  796. #GETEP   
  797. movl (%edi),%eax
  798. movl 4(%edi),%edx
  799. movl 8(%edi),%ecx
  800. call epexam
  801. orb %al,h_stat+1
  802. fxa9: ret
  803. is8t: .long ld1,ldl2t,ldl2e,ldpi,ldlg2,ldln2,ldz,NONE_ 
  804. is8:
  805. #SAVEIN
  806. movl %esi,s_iptr
  807. andb $0x0fd,h_stat+1
  808. call *%cs:is8t(,%ebx,4)
  809. #STPUSHP
  810. movl s_fpsp,%ebx
  811. subb $32,%bl
  812. cmpb $3,s_stk+10(%ebx)
  813. jnz stackof
  814. movl %ebx,s_fpsp
  815. addl $s_stk,%ebx
  816. movl %eax,(%ebx)
  817. movl %edx,4(%ebx)
  818. movl %ecx,8(%ebx)
  819. ret
  820. ld1: #load 1
  821. xorl %eax,%eax
  822. movl $0x80000000,%edx
  823. movl $0x00003fff,%ecx
  824. ret
  825. ldl2t: #load log2(10)
  826. movl $0xcd1b8afe,%eax
  827. movl $0xd49a784b,%edx
  828. movl $0x00004000,%ecx
  829. movb h_ctrl+1,%bh
  830. andb $0x0c,%bh
  831. cmpb $0x08,%bh
  832. jnz ldc3
  833. incl %eax
  834. ldc3: ret
  835. ldl2e: #load log2(e)
  836. movl $0x5c17f0bb,%eax
  837. movl $0xb8aa3b29,%edx
  838. movl $0x00003fff,%ecx
  839. testb $0x04,h_ctrl+1
  840. jnz ldc5
  841. incl %eax
  842. ldc5: ret
  843. ldpi: #load pi
  844. movl $0x2168c234,%eax
  845. movl $0xc90fdaa2,%edx
  846. movl $0x00004000,%ecx
  847. testb $0x04,h_ctrl+1
  848. jnz ldp5
  849. incl %eax
  850. ldp5: ret
  851. ldlg2: #load log10(2)
  852. movl $0xfbcff798,%eax
  853. movl $0x9a209a84,%edx
  854. movl $0x00003ffd,%ecx
  855. testb $0x04,h_ctrl+1
  856. jnz ldc9
  857. incl %eax
  858. ldc9: ret
  859. ldln2: #load ln(2)
  860. movl $0xd1cf79ab,%eax
  861. movl $0xb17217f7,%edx
  862. movl $0x00003ffe,%ecx
  863. testb $0x04,h_ctrl+1
  864. jnz ldc11
  865. incl %eax
  866. ldc11: ret
  867. ldz: #load 0
  868. xorl %eax,%eax
  869. xorl %edx,%edx
  870. movl $0x00010000,%ecx
  871. ret
  872. is2t: .long f2xm1_,fyl2x_,fptan_,fpatan_,fxtract_,fprem_,fdecstp_,fincstp_ 
  873. is2:
  874. #SAVEIN
  875. movl %esi,s_iptr
  876. jmp *%cs:is2t(,%ebx,4)
  877. f2xm1_: #ST = (2^ST) - 1
  878. #STTOP   
  879. movl s_fpsp,%edi
  880. addl $s_stk,%edi
  881. #GETEP   
  882. movl (%edi),%eax
  883. movl 4(%edi),%edx
  884. movl 8(%edi),%ecx
  885. call epf2xm1
  886. #PUTEP   
  887. movl %eax,(%edi)
  888. movl %edx,4(%edi)
  889. movl %ecx,8(%edi)
  890. ret
  891. fyl2x_: #calculate log2(ST) * ST(1), pop once
  892. #STTOP   
  893. movl s_fpsp,%edi
  894. addl $s_stk,%edi
  895. #GETEP   
  896. movl (%edi),%eax
  897. movl 4(%edi),%edx
  898. movl 8(%edi),%ecx
  899. call eplog
  900. #STPOPq
  901. movb $3,10(%edi)
  902. addb $32,s_fpsp
  903. #STTOP   
  904. movl s_fpsp,%edi
  905. addl $s_stk,%edi
  906. call epmul
  907. jmp rounde
  908. fptan_: #make ST into tan(ST)
  909. #STTOP   
  910. movl s_fpsp,%edi
  911. addl $s_stk,%edi
  912. #GETEP   
  913. movl (%edi),%eax
  914. movl 4(%edi),%edx
  915. movl 8(%edi),%ecx
  916. call reduct
  917. movl %edi,%esi
  918. #STPUSH
  919. xchgl %edi,%ebx
  920. movl s_fpsp,%ebx
  921. subb $32,%bl
  922. xchgl %edi,%ebx
  923. cmpb $3,s_stk+10(%edi)
  924. jz LL1
  925. call stackof
  926. LL1: movl %edi,s_fpsp
  927. addl $s_stk,%edi
  928. pushl %edi
  929. movl %esi,%edi
  930. testl $0x30000,%ecx
  931. jnz tan11
  932. call eptan
  933. tan5: #PUTEP   
  934. movl %eax,(%edi)
  935. movl %edx,4(%edi)
  936. movl %ecx,8(%edi)
  937. movl $tBIAS,%ecx
  938. movl $0x80000000,%edx
  939. xorl %eax,%eax
  940. tan6: popl %edi
  941. #PUTEP   
  942. movl %eax,(%edi)
  943. movl %edx,4(%edi)
  944. movl %ecx,8(%edi)
  945. ret
  946. tan11: testl $0x50000,%ecx
  947. jnz tan5
  948. #PUTEP   
  949. movl %eax,(%edi)
  950. movl %edx,4(%edi)
  951. movl %ecx,8(%edi)
  952. call getqn
  953. jmp tan6
  954. fpatan_: #arctangent of ST(1)/ST, pop stack
  955. #STTOP   
  956. movl s_fpsp,%edi
  957. addl $s_stk,%edi
  958. #GETEP   
  959. movl (%edi),%eax
  960. movl 4(%edi),%edx
  961. movl 8(%edi),%ecx
  962. #STIX1
  963. movl s_fpsp,%ebx
  964. addb $32,%bl
  965. addl $s_stk,%ebx
  966. xchgl %edi,%ebx
  967. call epatan
  968. #PUTEP   
  969. movl %eax,(%edi)
  970. movl %edx,4(%edi)
  971. movl %ecx,8(%edi)
  972. #STPOP
  973. movl s_fpsp,%eax
  974. addl $s_stk,%eax
  975. movb $3,10(%eax)
  976. addb $32,s_fpsp
  977. ret
  978. fxtract_: #extract exponent and mantissa
  979. andb $0x0fd,h_stat+1
  980. #STTOP   
  981. movl s_fpsp,%edi
  982. addl $s_stk,%edi
  983. #GETEP   
  984. movl (%edi),%eax
  985. movl 4(%edi),%edx
  986. movl 8(%edi),%ecx
  987. call xtract
  988. #STPUSHP
  989. movl s_fpsp,%ebx
  990. subb $32,%bl
  991. cmpb $3,s_stk+10(%ebx)
  992. jnz stackof
  993. movl %ebx,s_fpsp
  994. addl $s_stk,%ebx
  995. movl %eax,(%ebx)
  996. movl %edx,4(%ebx)
  997. movl %ecx,8(%ebx)
  998. ret
  999. fdecstp_: #decrement stack pointer
  1000. subb $32,s_fpsp
  1001. ret
  1002. fincstp_: #increment stack pointer
  1003. addb $32,s_fpsp
  1004. ret
  1005. is3t: .long fprem_,fyl2xp1_,fsqrt_,fsincos_,frndint_,fscale_,fsin_,fcos_ 
  1006. is3:
  1007. #SAVEIN
  1008. movl %esi,s_iptr
  1009. jmp *%cs:is3t(,%ebx,4)
  1010. fprem_: # ST = ST / ST(1) Intel/IEEE remainder
  1011. #STIX1q
  1012. movl s_fpsp,%eax
  1013. addb $32,%al
  1014. addl $s_stk,%eax
  1015. xchgl %edi,%eax
  1016. #GETEP   
  1017. movl (%edi),%eax
  1018. movl 4(%edi),%edx
  1019. movl 8(%edi),%ecx
  1020. #STTOP   
  1021. movl s_fpsp,%edi
  1022. addl $s_stk,%edi
  1023. call eprem
  1024. #PUTEP   
  1025. movl %eax,(%edi)
  1026. movl %edx,4(%edi)
  1027. movl %ecx,8(%edi)
  1028. ret
  1029. fyl2xp1_: #calculate log2(ST+1) * ST(1), pop once
  1030. #STTOP   
  1031. movl s_fpsp,%edi
  1032. addl $s_stk,%edi
  1033. #GETEP   
  1034. movl (%edi),%eax
  1035. movl 4(%edi),%edx
  1036. movl 8(%edi),%ecx
  1037. call eplog1
  1038. #STPOPq
  1039. movb $3,10(%edi)
  1040. addb $32,s_fpsp
  1041. #STTOP   
  1042. movl s_fpsp,%edi
  1043. addl $s_stk,%edi
  1044. call epmul
  1045. jmp rounde
  1046. frndint_: #round ST to integer
  1047. #STTOP   
  1048. movl s_fpsp,%edi
  1049. addl $s_stk,%edi
  1050. #GETEP   
  1051. movl (%edi),%eax
  1052. movl 4(%edi),%edx
  1053. movl 8(%edi),%ecx
  1054. call eptown
  1055. #PUTEP   
  1056. movl %eax,(%edi)
  1057. movl %edx,4(%edi)
  1058. movl %ecx,8(%edi)
  1059. ret
  1060. fscale_: #add ST(1) to exponent of ST
  1061. movl s_fpsp,%eax
  1062. addl $s_stk,%eax
  1063. movl %eax,%edi
  1064. subl $s_stk,%eax
  1065. addb $32,%al
  1066. addl $s_stk,%eax
  1067. movl 8(%eax),%ecx
  1068. movl 4(%eax),%edx
  1069. movl (%eax),%eax
  1070. call scale
  1071. jmp roundx
  1072. fucompps: #ST - ST(1) -> codes, pop twice
  1073. #SAVEIN
  1074. movl %esi,s_iptr
  1075. #STIX1q
  1076. movl s_fpsp,%eax
  1077. addb $32,%al
  1078. addl $s_stk,%eax
  1079. xchgl %edi,%eax
  1080. #GETEP   
  1081. movl (%edi),%eax
  1082. movl 4(%edi),%edx
  1083. movl 8(%edi),%ecx
  1084. #STTOP   
  1085. movl s_fpsp,%edi
  1086. addl $s_stk,%edi
  1087. call epcomu
  1088. movl %edi,%eax
  1089. movb $3,10(%eax)
  1090. subl $s_stk,%eax
  1091. addb $32,%al
  1092. addl $s_stk,%eax
  1093. movb $3,10(%eax)
  1094. addb $64,s_fpsp
  1095. ret
  1096. fisti: #fetch into 32-bit integer
  1097. #SAVEIX
  1098. movl %eax,s_memp
  1099. xchgl %esi,%eax
  1100. movl %eax,s_iptr
  1101. #STTOP   
  1102. movl s_fpsp,%edi
  1103. addl $s_stk,%edi
  1104. #GETEP   
  1105. movl (%edi),%eax
  1106. movl 4(%edi),%edx
  1107. movl 8(%edi),%ecx
  1108. call eptosi
  1109. movl %eax,(%esi)
  1110. ret
  1111. fistpi: #pop into 32-bit integer
  1112. #SAVEIX
  1113. movl %eax,s_memp
  1114. xchgl %esi,%eax
  1115. movl %eax,s_iptr
  1116. #STTOP   
  1117. movl s_fpsp,%edi
  1118. addl $s_stk,%edi
  1119. #GETEP   
  1120. movl (%edi),%eax
  1121. movl 4(%edi),%edx
  1122. movl 8(%edi),%ecx
  1123. call eptosi
  1124. movl %eax,(%esi)
  1125. #STPOPq
  1126. movb $3,10(%edi)
  1127. addb $32,s_fpsp
  1128. ret
  1129. flde: #push EP from memory
  1130. #SAVEII
  1131. movl %esi,s_iptr
  1132. movl %eax,s_memp
  1133. andb $0x0fd,h_stat+1
  1134. call eptoep
  1135. #STPUSHP
  1136. movl s_fpsp,%ebx
  1137. subb $32,%bl
  1138. cmpb $3,s_stk+10(%ebx)
  1139. jnz stackof
  1140. movl %ebx,s_fpsp
  1141. addl $s_stk,%ebx
  1142. movl %eax,(%ebx)
  1143. movl %edx,4(%ebx)
  1144. movl %ecx,8(%ebx)
  1145. ret
  1146. fstpe: #fetch as extended-precision
  1147. #SAVEIX
  1148. movl %eax,s_memp
  1149. xchgl %esi,%eax
  1150. movl %eax,s_iptr
  1151. andb $0x0fd,h_stat+1
  1152. #STTOP   
  1153. movl s_fpsp,%edi
  1154. addl $s_stk,%edi
  1155. #GETEP   
  1156. movl (%edi),%eax
  1157. movl 4(%edi),%edx
  1158. movl 8(%edi),%ecx
  1159. shldl $16,%ecx,%ebx
  1160. cmpb $3,%bl
  1161. jnz stpe5
  1162. call getqn
  1163. stpe5: movl %eax,(%esi)
  1164. movl %edx,4(%esi)
  1165. addl %ecx,%ecx
  1166. rcrw $1,%cx
  1167. movw %cx,8(%esi)
  1168. #STPOPq
  1169. movb $3,10(%edi)
  1170. addb $32,s_fpsp
  1171. ret
  1172. is5t: .long NONE_,NONE_,fclex_,finit_,NONE_,NONE_,NONE_,NONE_ 
  1173. is5: jmp *%cs:is5t(,%ebx,4)
  1174. fclex_: #clear error status flags
  1175. andw $0x7f00,h_stat
  1176. ret
  1177. faddx: #ST(i) = ST + ST(i)
  1178. #SAVEIN
  1179. movl %esi,s_iptr
  1180. #GETEPX  ebx
  1181. movl s_fpsp,%eax
  1182. addl $s_stk,%eax
  1183. movl (%eax),%edi
  1184. movl 4(%eax),%edx
  1185. movl 8(%eax),%ecx
  1186. subl $s_stk,%eax
  1187. shll $5,%ebx
  1188. addb %bl,%al
  1189. addl $s_stk,%eax
  1190. xchgl %edi,%eax
  1191. call epadd
  1192. jmp rounde
  1193. fmulx: #ST(i) = ST * ST(i)
  1194. #SAVEIN
  1195. movl %esi,s_iptr
  1196. #GETEPX  ebx
  1197. movl s_fpsp,%eax
  1198. addl $s_stk,%eax
  1199. movl (%eax),%edi
  1200. movl 4(%eax),%edx
  1201. movl 8(%eax),%ecx
  1202. subl $s_stk,%eax
  1203. shll $5,%ebx
  1204. addb %bl,%al
  1205. addl $s_stk,%eax
  1206. xchgl %edi,%eax
  1207. call epmul
  1208. jmp rounde
  1209. fsubx: #ST(i) = ST - ST(i)
  1210. #SAVEIN
  1211. movl %esi,s_iptr
  1212. #GETEPX  ebx
  1213. movl s_fpsp,%eax
  1214. addl $s_stk,%eax
  1215. movl (%eax),%edi
  1216. movl 4(%eax),%edx
  1217. movl 8(%eax),%ecx
  1218. subl $s_stk,%eax
  1219. shll $5,%ebx
  1220. addb %bl,%al
  1221. addl $s_stk,%eax
  1222. xchgl %edi,%eax
  1223. call epsub
  1224. jmp rounde
  1225. fsubrx: #ST(i) = ST(i) - ST
  1226. #SAVEIN
  1227. movl %esi,s_iptr
  1228. #GETEPX  ebx
  1229. movl s_fpsp,%eax
  1230. addl $s_stk,%eax
  1231. movl (%eax),%edi
  1232. movl 4(%eax),%edx
  1233. movl 8(%eax),%ecx
  1234. subl $s_stk,%eax
  1235. shll $5,%ebx
  1236. addb %bl,%al
  1237. addl $s_stk,%eax
  1238. xchgl %edi,%eax
  1239. call epsubr
  1240. jmp rounde
  1241. fdivx: #ST(i) = ST / ST(i)
  1242. #SAVEIN
  1243. movl %esi,s_iptr
  1244. #GETEPX  ebx
  1245. movl s_fpsp,%eax
  1246. addl $s_stk,%eax
  1247. movl (%eax),%edi
  1248. movl 4(%eax),%edx
  1249. movl 8(%eax),%ecx
  1250. subl $s_stk,%eax
  1251. shll $5,%ebx
  1252. addb %bl,%al
  1253. addl $s_stk,%eax
  1254. xchgl %edi,%eax
  1255. call epdiv
  1256. jmp rounde
  1257. fdivrx: #ST(i) = ST(i) / ST
  1258. #SAVEIN
  1259. movl %esi,s_iptr
  1260. #GETEPX  ebx
  1261. movl s_fpsp,%eax
  1262. addl $s_stk,%eax
  1263. movl (%eax),%edi
  1264. movl 4(%eax),%edx
  1265. movl 8(%eax),%ecx
  1266. subl $s_stk,%eax
  1267. shll $5,%ebx
  1268. addb %bl,%al
  1269. addl $s_stk,%eax
  1270. xchgl %edi,%eax
  1271. call epdivr
  1272. jmp rounde
  1273. fldenv_: #load environment
  1274. frstor_: #restore the HW status
  1275. movl %eax,%esi
  1276. movl $h_ctrl,%edi
  1277. movl $3,%ecx
  1278. .byte 0x36 #from ss: 
  1279. repz
  1280. movsl
  1281. .byte 0x36 #from ss: 
  1282. lodsl #instruction pointer
  1283. movl %eax,s_iptr
  1284. addl $4,%esi
  1285. .byte 0x36 #from ss: 
  1286. lodsl #operand pointer
  1287. movl %eax,s_memp
  1288. addl $4,%esi
  1289. movb h_stat+1,%al
  1290. shlb $2,%al
  1291. andl $0x0e0,%eax
  1292. movl %eax,s_fpsp
  1293. cmpb $0x2c,%dl
  1294. jnz rst5
  1295. movl s_fpsp,%edi
  1296. addl $s_stk,%edi
  1297. movl $8,%ecx
  1298. lds2: movl %esi,%eax
  1299. pushl %ecx
  1300. call eptoep
  1301. #PUTEP
  1302. movl %eax,(%edi)
  1303. movl %edx,4(%edi)
  1304. movl %ecx,8(%edi)
  1305. popl %ecx
  1306. addl $10,%esi
  1307. movl %edi,%eax
  1308. subl $s_stk,%eax
  1309. addb $32,%al
  1310. addl $s_stk,%eax
  1311. movl %eax,%edi
  1312. loop lds2
  1313. rst5: movw h_ctrl,%ax
  1314. notl %eax
  1315. andw h_stat,%ax
  1316. testb $0x3f,%al
  1317. jz rst7
  1318. orw $0x8080,h_stat
  1319. rst7: movl $8,%ecx #prepare to loop over all 8 tags
  1320. movw h_tag,%ax
  1321. movl $s_stk+0x0e0,%edi
  1322. ltt3: rolw $2,%ax
  1323. movb %al,%dl
  1324. andb $3,%dl
  1325. movb %dl,10(%edi)
  1326. subl $32,%edi
  1327. loop ltt3
  1328. ret
  1329. fstenv_: #store environment
  1330. fsave_: #save HW block
  1331. pushl %es #flat model assumes target is stack
  1332. movw %ss,%cx
  1333. movw %cx,%es
  1334. pushl %eax
  1335. movl $8,%ecx #prepare to loop over all 8 tags
  1336. movl $s_stk,%edi
  1337. stt3: movb 10(%edi),%bl #concatenate tags       
  1338. shrdw $2,%bx,%ax
  1339. addl $32,%edi
  1340. loop stt3
  1341. movw %ax,h_tag #store new tags
  1342. popl %edi
  1343. call stfpsp
  1344. movl $h_ctrl,%esi
  1345. movsl
  1346. movsl
  1347. movsl
  1348. movl s_iptr,%eax #instruction pointer
  1349. stosl
  1350. orl %eax,%eax
  1351. jz stp5
  1352. movw %cs,%ax
  1353. stp5: stosl
  1354. movl s_memp,%eax #operand pointer
  1355. stosl
  1356. orl %eax,%eax
  1357. jz stp7
  1358. movw %es,%ax
  1359. stp7: stosl
  1360. popl %es
  1361. cmpb $0x2e,%dl
  1362. jnz sts9
  1363. movl $8,%ecx
  1364. movl s_fpsp,%eax
  1365. sts2: addl $s_stk,%eax
  1366. movl (%eax),%esi
  1367. movl 4(%eax),%edx
  1368. movl 8(%eax),%ebx
  1369. subl $s_stk,%eax
  1370. movl %esi,(%edi)
  1371. movl %edx,4(%edi)
  1372. addl %ebx,%ebx
  1373. rcrw $1,%bx
  1374. movw %bx,8(%edi)
  1375. addl $10,%edi
  1376. addb $32,%al
  1377. loop sts2
  1378. finit_: #initialize hardware block
  1379. xorl %eax,%eax
  1380. movl $0x037f,h_ctrl
  1381. movl %eax,h_stat
  1382. movl $0xffff,h_tag
  1383. movl %eax,s_iptr
  1384. movl %eax,s_memp
  1385. movl $s_stk,%eax
  1386. movl $0,s_fpsp
  1387. movl $8,%ecx
  1388. fin4: movb $3,10(%eax)
  1389. addl $32,%eax
  1390. loop fin4
  1391. sts9: ret
  1392. .globl fstsw_
  1393. fstsw_: #fetch HW status word
  1394. movl %eax,%edi
  1395. call stfpsp
  1396. movw h_stat,%ax
  1397. stosw
  1398. ret
  1399. ffree_: #change tag to empty
  1400. #SAVEIN
  1401. movl %esi,s_iptr
  1402. #STIX    ebx
  1403. movl s_fpsp,%eax
  1404. shll $5,%ebx
  1405. addb %bl,%al
  1406. addl $s_stk,%eax
  1407. xchgl %edi,%eax
  1408. movb $3,10(%edi)
  1409. ret
  1410. fsts: #ST(i) = ST 
  1411. #SAVEIN
  1412. movl %esi,s_iptr
  1413. #GETEPX  ebx
  1414. movl s_fpsp,%eax
  1415. addl $s_stk,%eax
  1416. movl (%eax),%edi
  1417. movl 4(%eax),%edx
  1418. movl 8(%eax),%ecx
  1419. subl $s_stk,%eax
  1420. shll $5,%ebx
  1421. addb %bl,%al
  1422. addl $s_stk,%eax
  1423. xchgl %edi,%eax
  1424. #PUTEP   
  1425. movl %eax,(%edi)
  1426. movl %edx,4(%edi)
  1427. movl %ecx,8(%edi)
  1428. ret
  1429. faddpx: #ST(i) = ST + ST(i) and pop
  1430. #SAVEIN
  1431. movl %esi,s_iptr
  1432. #GETEPX  ebx
  1433. movl s_fpsp,%eax
  1434. addl $s_stk,%eax
  1435. movl (%eax),%edi
  1436. movl 4(%eax),%edx
  1437. movl 8(%eax),%ecx
  1438. subl $s_stk,%eax
  1439. shll $5,%ebx
  1440. addb %bl,%al
  1441. addl $s_stk,%eax
  1442. xchgl %edi,%eax
  1443. call epadd
  1444. call rounde
  1445. #STPOP
  1446. movl s_fpsp,%eax
  1447. addl $s_stk,%eax
  1448. movb $3,10(%eax)
  1449. addb $32,s_fpsp
  1450. ret
  1451. fmulpx: #ST(i) = ST * ST(i) and pop
  1452. #SAVEIN
  1453. movl %esi,s_iptr
  1454. #GETEPX  ebx
  1455. movl s_fpsp,%eax
  1456. addl $s_stk,%eax
  1457. movl (%eax),%edi
  1458. movl 4(%eax),%edx
  1459. movl 8(%eax),%ecx
  1460. subl $s_stk,%eax
  1461. shll $5,%ebx
  1462. addb %bl,%al
  1463. addl $s_stk,%eax
  1464. xchgl %edi,%eax
  1465. call epmul
  1466. call rounde
  1467. #STPOP
  1468. movl s_fpsp,%eax
  1469. addl $s_stk,%eax
  1470. movb $3,10(%eax)
  1471. addb $32,s_fpsp
  1472. ret
  1473. fcompps: #ST - ST(1) -> codes, pop twice
  1474. #SAVEIN
  1475. movl %esi,s_iptr
  1476. #STIX1q
  1477. movl s_fpsp,%eax
  1478. addb $32,%al
  1479. addl $s_stk,%eax
  1480. xchgl %edi,%eax
  1481. #GETEP   
  1482. movl (%edi),%eax
  1483. movl 4(%edi),%edx
  1484. movl 8(%edi),%ecx
  1485. #STTOP   
  1486. movl s_fpsp,%edi
  1487. addl $s_stk,%edi
  1488. call epcomp
  1489. movl %edi,%eax
  1490. movb $3,10(%eax)
  1491. subl $s_stk,%eax
  1492. addb $32,%al
  1493. addl $s_stk,%eax
  1494. movb $3,10(%eax)
  1495. addb $64,s_fpsp
  1496. ret
  1497. fsubpx: #ST(i) = ST - ST(i) and pop
  1498. #SAVEIN
  1499. movl %esi,s_iptr
  1500. #GETEPX  ebx
  1501. movl s_fpsp,%eax
  1502. addl $s_stk,%eax
  1503. movl (%eax),%edi
  1504. movl 4(%eax),%edx
  1505. movl 8(%eax),%ecx
  1506. subl $s_stk,%eax
  1507. shll $5,%ebx
  1508. addb %bl,%al
  1509. addl $s_stk,%eax
  1510. xchgl %edi,%eax
  1511. call epsub
  1512. call rounde
  1513. #STPOP
  1514. movl s_fpsp,%eax
  1515. addl $s_stk,%eax
  1516. movb $3,10(%eax)
  1517. addb $32,s_fpsp
  1518. ret
  1519. fsubrpx: #ST(i) = ST(i) - ST and pop
  1520. #SAVEIN
  1521. movl %esi,s_iptr
  1522. #GETEPX  ebx
  1523. movl s_fpsp,%eax
  1524. addl $s_stk,%eax
  1525. movl (%eax),%edi
  1526. movl 4(%eax),%edx
  1527. movl 8(%eax),%ecx
  1528. subl $s_stk,%eax
  1529. shll $5,%ebx
  1530. addb %bl,%al
  1531. addl $s_stk,%eax
  1532. xchgl %edi,%eax
  1533. call epsubr
  1534. call rounde
  1535. #STPOP
  1536. movl s_fpsp,%eax
  1537. addl $s_stk,%eax
  1538. movb $3,10(%eax)
  1539. addb $32,s_fpsp
  1540. ret
  1541. fdivpx: #ST(i) = ST/ST(i) and pop
  1542. #SAVEIN
  1543. movl %esi,s_iptr
  1544. #GETEPX  ebx
  1545. movl s_fpsp,%eax
  1546. addl $s_stk,%eax
  1547. movl (%eax),%edi
  1548. movl 4(%eax),%edx
  1549. movl 8(%eax),%ecx
  1550. subl $s_stk,%eax
  1551. shll $5,%ebx
  1552. addb %bl,%al
  1553. addl $s_stk,%eax
  1554. xchgl %edi,%eax
  1555. call epdivr
  1556. call rounde
  1557. #STPOP
  1558. movl s_fpsp,%eax
  1559. addl $s_stk,%eax
  1560. movb $3,10(%eax)
  1561. addb $32,s_fpsp
  1562. ret
  1563. fdivrpx: #ST(i) = ST(i)/ST and pop
  1564. #SAVEIN
  1565. movl %esi,s_iptr
  1566. #GETEPX  ebx
  1567. movl s_fpsp,%eax
  1568. addl $s_stk,%eax
  1569. movl (%eax),%edi
  1570. movl 4(%eax),%edx
  1571. movl 8(%eax),%ecx
  1572. subl $s_stk,%eax
  1573. shll $5,%ebx
  1574. addb %bl,%al
  1575. addl $s_stk,%eax
  1576. xchgl %edi,%eax
  1577. call epdiv
  1578. call rounde
  1579. #STPOP
  1580. movl s_fpsp,%eax
  1581. addl $s_stk,%eax
  1582. movb $3,10(%eax)
  1583. addb $32,s_fpsp
  1584. ret
  1585. fistw: #fetch 16-bit integer
  1586. #SAVEIX
  1587. movl %eax,s_memp
  1588. xchgl %esi,%eax
  1589. movl %eax,s_iptr
  1590. #STTOP   
  1591. movl s_fpsp,%edi
  1592. addl $s_stk,%edi
  1593. #GETEP   
  1594. movl (%edi),%eax
  1595. movl 4(%edi),%edx
  1596. movl 8(%edi),%ecx
  1597. call eptowi
  1598. movw %ax,(%esi)
  1599. ret
  1600. fistpw: #fetch 16-bit integer, pop
  1601. #SAVEIX
  1602. movl %eax,s_memp
  1603. xchgl %esi,%eax
  1604. movl %eax,s_iptr
  1605. #STTOP   
  1606. movl s_fpsp,%edi
  1607. addl $s_stk,%edi
  1608. #GETEP   
  1609. movl (%edi),%eax
  1610. movl 4(%edi),%edx
  1611. movl 8(%edi),%ecx
  1612. call eptowi
  1613. movw %ax,(%esi)
  1614. #STPOPq
  1615. movb $3,10(%edi)
  1616. addb $32,s_fpsp
  1617. ret
  1618. fbldp: #push 10-byte packed-decimal integer
  1619. #SAVEII
  1620. movl %esi,s_iptr
  1621. movl %eax,s_memp
  1622. andb $0x0fd,h_stat+1
  1623. call pdtoep
  1624. #STPUSHP
  1625. movl s_fpsp,%ebx
  1626. subb $32,%bl
  1627. cmpb $3,s_stk+10(%ebx)
  1628. jnz stackof
  1629. movl %ebx,s_fpsp
  1630. addl $s_stk,%ebx
  1631. movl %eax,(%ebx)
  1632. movl %edx,4(%ebx)
  1633. movl %ecx,8(%ebx)
  1634. ret
  1635. fildl: #push 64-bit integer
  1636. andb $0x0fd,h_stat+1
  1637. call litoep
  1638. #STPUSHP
  1639. movl s_fpsp,%ebx
  1640. subb $32,%bl
  1641. cmpb $3,s_stk+10(%ebx)
  1642. jnz stackof
  1643. movl %ebx,s_fpsp
  1644. addl $s_stk,%ebx
  1645. movl %eax,(%ebx)
  1646. movl %edx,4(%ebx)
  1647. movl %ecx,8(%ebx)
  1648. ret
  1649. fbstpp: #pop into 10-byte packed-decimal integer
  1650. #SAVEII
  1651. movl %esi,s_iptr
  1652. movl %eax,s_memp
  1653. #STTOP   
  1654. movl s_fpsp,%edi
  1655. addl $s_stk,%edi
  1656. #GETEP   
  1657. movl (%edi),%eax
  1658. movl 4(%edi),%edx
  1659. movl 8(%edi),%ecx
  1660. movl s_memp,%edi
  1661. call eptopd
  1662. #STPOP
  1663. movl s_fpsp,%eax
  1664. addl $s_stk,%eax
  1665. movb $3,10(%eax)
  1666. addb $32,s_fpsp
  1667. ret
  1668. fistpl: #pop into 64-bit integer
  1669. #SAVEIX
  1670. movl %eax,s_memp
  1671. xchgl %esi,%eax
  1672. movl %eax,s_iptr
  1673. #STTOP   
  1674. movl s_fpsp,%edi
  1675. addl $s_stk,%edi
  1676. #GETEP   
  1677. movl (%edi),%eax
  1678. movl 4(%edi),%edx
  1679. movl 8(%edi),%ecx
  1680. call eptoli
  1681. movl %eax,(%esi)
  1682. movl %edx,4(%esi)
  1683. #STPOPq
  1684. movb $3,10(%edi)
  1685. addb $32,s_fpsp
  1686. ret
  1687. fstswax_: #status word -> ax
  1688. call stfpsp
  1689. movw h_stat,%ax
  1690. movw %ax,s_ax(%ebp)
  1691. ret
  1692. fsincos_: #make ST into sin(ST), push cos(ST)
  1693. #STTOP   
  1694. movl s_fpsp,%edi
  1695. addl $s_stk,%edi
  1696. #GETEP   
  1697. movl (%edi),%eax
  1698. movl 4(%edi),%edx
  1699. movl 8(%edi),%ecx
  1700. call reduct
  1701. pushl %edi
  1702. #STPUSH
  1703. xchgl %edi,%ebx
  1704. movl s_fpsp,%ebx
  1705. subb $32,%bl
  1706. xchgl %edi,%ebx
  1707. cmpb $3,s_stk+10(%edi)
  1708. jz LL2
  1709. call stackof
  1710. LL2: movl %edi,s_fpsp
  1711. addl $s_stk,%edi
  1712. #PUTEP   
  1713. movl %eax,(%edi)
  1714. movl %edx,4(%edi)
  1715. movl %ecx,8(%edi)
  1716. popl %edi
  1717. testl $0x30000,%ecx
  1718. jnz sco11
  1719. pushl %ebx
  1720. call epsin
  1721. popl %ebx
  1722. #PUTEP   
  1723. movl %eax,(%edi)
  1724. movl %edx,4(%edi)
  1725. movl %ecx,8(%edi)
  1726. #STTOP   
  1727. movl s_fpsp,%edi
  1728. addl $s_stk,%edi
  1729. #GETEP   
  1730. movl (%edi),%eax
  1731. movl 4(%edi),%edx
  1732. movl 8(%edi),%ecx
  1733. call epcos
  1734. sco9: #PUTEP   
  1735. movl %eax,(%edi)
  1736. movl %edx,4(%edi)
  1737. movl %ecx,8(%edi)
  1738. ret
  1739. sco11: testl $0x50000,%ecx
  1740. jz sco9
  1741. #PUTEP
  1742. movl %eax,(%edi)
  1743. movl %edx,4(%edi)
  1744. movl %ecx,8(%edi)
  1745. movl $0x3fff,%ecx
  1746. movl $0x80000000,%edx
  1747. xorl %eax,%eax
  1748. #STTOP
  1749. movl s_fpsp,%edi
  1750. addl $s_stk,%edi
  1751. jmp sco9
  1752. fsin_: #make ST into sin(ST)
  1753. #STTOP   
  1754. movl s_fpsp,%edi
  1755. addl $s_stk,%edi
  1756. #GETEP   
  1757. movl (%edi),%eax
  1758. movl 4(%edi),%edx
  1759. movl 8(%edi),%ecx
  1760. call reduct
  1761. testl $0x30000,%ecx
  1762. jnz sin9
  1763. call epsin
  1764. sin9: #PUTEP   
  1765. movl %eax,(%edi)
  1766. movl %edx,4(%edi)
  1767. movl %ecx,8(%edi)
  1768. ret
  1769. fcos_: #make ST into cos(ST)
  1770. #STTOP   
  1771. movl s_fpsp,%edi
  1772. addl $s_stk,%edi
  1773. #GETEP   
  1774. movl (%edi),%eax
  1775. movl 4(%edi),%edx
  1776. movl 8(%edi),%ecx
  1777. call reduct
  1778. testl $0x30000,%ecx
  1779. jnz cos11
  1780. call epcos
  1781. cos9: #PUTEP   
  1782. movl %eax,(%edi)
  1783. movl %edx,4(%edi)
  1784. movl %ecx,8(%edi)
  1785. ret
  1786. cos11: testl $0x50000,%ecx
  1787. jz cos9
  1788. movl $0x3fff,%ecx
  1789. movl $0x80000000,%edx
  1790. xorl %eax,%eax
  1791. jmp cos9
  1792. NONE_:
  1793. #SAVEIN
  1794. movl %esi,s_iptr
  1795. ret
  1796. # stack overflow handler
  1797. stackof:
  1798. orw $stacko,h_stat #stack overflow
  1799. call exproc
  1800. orb $2,h_stat+1
  1801. movl $0x80027fff,%ecx
  1802. movl $0xc0000000,%edx
  1803. xorl %eax,%eax
  1804. subb $32,s_fpsp
  1805. movl s_fpsp,%ebx
  1806. addl $s_stk,%ebx
  1807. movl %eax,(%ebx)
  1808. movl %edx,4(%ebx)
  1809. movl %ecx,8(%ebx)
  1810. ret
  1811. # store floating-point stack pointer into the status word
  1812. stfpsp:
  1813. movb s_fpsp,%al
  1814. shrb $2,%al
  1815. movb h_stat+1,%ah
  1816. andb $0x0c7,%ah
  1817. orb %ah,%al
  1818. movb %al,h_stat+1
  1819. ret
  1820. #intrn   endp
  1821. #emuseg  ends
  1822. #        END