Guest User

Untitled

a guest
May 24th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; code c
  2. ;void calc_coord(int *x_axis, int *y_axis, double theta, int radius)
  3. ;{
  4. ;   *x_axis = (int)(250-radius*sin(theta));
  5. ;   *y_axis = (int)(250-radius*cos(theta));
  6. ;};
  7.  
  8. ;   section .bss
  9. ;   xax: resq 1     ;reserve 1 quad word for for result
  10. ;   yax: resq 1    
  11.    
  12.     section .text
  13.     global _asdf
  14.    
  15. _asdf:
  16.     ;prologue
  17.     push ebp
  18.     mov ebp, esp
  19.     ;stack frame:
  20.     ;[ebp]   [ebp+4][ebp+8][ebp+12][ebp+16][ebp+24]
  21.     ;[oldEBP][ret]  [*x_ax][*y_ax] [theta] [radius]
  22.  
  23.     fld qword [ebp+16]  ;load theta into st0
  24.     fsin                ;st0 = sin(theta)
  25.     fld qword [ebp+24] 
  26.     fmulp st1, st0      ;st0 = radius*sin(theta)  ;fmulp??
  27.     mov eax, 250
  28.     sub esp, 4
  29.     mov [esp], eax
  30.     fild dword [esp]
  31.     fsubp st1, st0      ;st0 = 250 - radius*sin(theta)
  32.     fist dword [ebp+8]
  33.    
  34.    
  35.     fld qword [ebp+16]  ;load theta into st0
  36.     fcos                ;st0 = cos(theta)
  37.     fld qword [ebp+24]  ;st0 = radius*cos(theta)
  38.     fmulp st1,st0
  39.     mov eax, 250
  40.     mov [esp], eax
  41.     fild dword [esp]
  42.     add esp, 4
  43.     fsubp st1, st0      ;st0 = 250 - radius*cos(theta)
  44.     fist dword [ebp+12]     ;store st0 in c
  45.    
  46.     ;epilogue
  47.     mov esp, ebp
  48.     pop ebp
  49.     ret
Add Comment
Please, Sign In to add comment