Guest User

Untitled

a guest
May 25th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1.  
  2. FloatToStr proc
  3. Ten equ -2
  4. T equ -4
  5. push ax
  6. push cx
  7. push dx
  8.  
  9. push bp
  10. mov bp, sp
  11. push 10
  12. push 0
  13.  
  14. ;ST(0) = 12.345
  15. fld1 ;1 12.345
  16. fld st(1) ;12.345 1 12.345
  17. fprem ;0.345 1 12.345
  18.  
  19. fsub st(2), st ;ST(2) - целая часть
  20. fxch st(2) ;12 1 0.345
  21.  
  22. ;целая часть
  23. xor cx, cx
  24.  
  25. IntPart:
  26. fidiv word ptr [bp + Ten] ;1.2 1 0.345
  27. fxch st(1) ;1 1.2 0.345
  28. fld st(1) ;1.2 1 1.2 0.345 ...
  29.  
  30. fprem ;0.2 1 1.2 0.345
  31.  
  32. fsub st(2), st ;0.2 1 1 0.345
  33.  
  34. fimul word ptr [bp + Ten] ;2 1 1 0.345
  35. fistp word ptr [bp + T] ;1 1 0.345
  36. inc cx
  37.  
  38. push word ptr [bp + T]
  39. fxch st(1) ;1 1 0.345 ...
  40.  
  41. ftst
  42. fstsw ax
  43. sahf
  44. jnz IntPart
  45.  
  46. StoreInt:
  47. pop ax
  48. add al, '0'
  49. stosb
  50. loop StoreInt ; 0 1 0.345
  51.  
  52. ;дробная часть
  53. fstp st(0) ; 1 0.345
  54. fxch st(1) ; 0.345 1
  55. ftst
  56. fstsw ax
  57. sahf
  58. jz exit
  59.  
  60. mov al, '.'
  61. stosb
  62.  
  63. mov cx, 20
  64.  
  65. FractPart:
  66. fimul word ptr [bp + Ten] ; 3.45 1
  67. fxch st(1) ; 1 3.45
  68. fld st(1) ; 3.45 1 3.45
  69.  
  70. fprem ; 0.45 1 3.45
  71.  
  72. fsub st(2), st ; 0.45 1 3
  73. fxch st(2) ; 3 1 0.45
  74.  
  75. fistp word ptr [bp + T] ; 1 0.45
  76.  
  77. mov dl, [bp - 4]
  78. add dl, 30h
  79. mov al, dl
  80. stosb
  81.  
  82. fxch st(1) ; 0.45 1
  83. ftst
  84. fstsw ax
  85. sahf
  86.  
  87. loopnz FractPart ; 0 1 ...
  88.  
  89. mov al, '$'
  90. stosb
  91.  
  92.  
  93. exit: fstp st(0)
  94. fstp st(0)
  95.  
  96. add sp,4
  97. pop bp
  98. pop dx
  99. pop cx
  100. pop ax
  101. ret
  102. FloatToStr endp
Add Comment
Please, Sign In to add comment