crsandu

5-A

Sep 6th, 2018
868
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .586
  2. .model flat, C
  3.  
  4. includelib msvcrt.lib
  5. extern exit:    proc
  6. extern printf:  proc
  7. extern scanf:   proc
  8.  
  9. public start
  10.  
  11. .data
  12.     numar_obtinut   dq  ?
  13.     numar_introdus  dd  ?
  14.     mesaj_out   db  "Introduceti o valoare: ", 0
  15.     mesaj_in    db  "%d", 0
  16.     float_f     db  "Valoarea obtinuta este: %.3f", 0
  17.  
  18. .code
  19.     square  proc
  20.         mov EBP, ESP
  21.        
  22.         FLD1
  23.        
  24.         FILD    DWORD PTR [EBP + 4]
  25.         FIMUL   DWORD PTR [EBP + 4] ; <=> val^2
  26.        
  27.         FDIV ; impartim valorile
  28.         ret
  29.     square endp
  30.  
  31.     start:
  32.         push offset mesaj_out
  33.         call printf
  34.         add ESP, 04h
  35.        
  36.         push offset numar_introdus
  37.         push offset mesaj_in
  38.         call scanf
  39.         add ESP, 08h
  40.        
  41.        
  42.         push numar_introdus
  43.         call square
  44.         add ESP, 04h
  45.        
  46.        
  47.         MOV EBP, ESP ; - ca sa pot afisa double
  48.         FSTP QWORD PTR [EBP]
  49.        
  50.         push offset float_f
  51.         call printf
  52.        
  53.         push 0
  54.         call exit
  55. end start
Advertisement