Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. scale_number:
  2. push ebp ;; Pushing Base pointer (contains address of current activation frame
  3. ;; which is actually the return address of the caller) to the stack
  4.  
  5. mov ebp, esp ;; Overrides ebp value to Stack pointer's value which contains the
  6. ;; address of last used dword in the stack.
  7.  
  8. pushad ;; Push all significant registers (8 general purpose registers)
  9. ;; onto the stack (backup registers values)
  10.  
  11. mov ebx, [ebp + 12] ;; Upper bound
  12. sub dword ebx, [ebp + 8] ;; Substruct ebx with the Lower bound
  13. mov ecx, [ebp + 16] ;; get the pointer of the result contianer
  14.  
  15. finit
  16.  
  17. mov eax, dword [seed]
  18. mul ebx
  19. push eax
  20. fild dword [esp]
  21. add esp, 4
  22. push 0x0000FFFF
  23. fidiv dword [esp]
  24. add esp, 4
  25. fiadd dword [ebp + 8]
  26. fstp tword [ecx]
  27.  
  28. ffree
  29.  
  30. popad
  31. return_from_function ; macro for quiting the function
  32.  
  33. push dword var1
  34. push 100
  35. push 40
  36.  
  37. call scale_number
  38.  
  39. ;; Floating point tester TWORD
  40. sub esp, 10
  41. mov ebx, 0
  42. .loop4:
  43. mov eax, [var1 + ebx]
  44. mov [esp + ebx], eax
  45. inc ebx
  46. cmp ebx, 10
  47. jne .loop4
  48.  
  49. push format_fp ;; using "%f" , 10, 0 as the format_fp
  50. call printf
  51. add esp, 14
  52.  
  53. jmp exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement