Advertisement
dllbridge

FASM ver

Nov 29th, 2020
1,635
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. format  PE console
  3. entry   start
  4. include 'win32ax.inc'
  5. include 'api\kernel32.inc'
  6.  
  7. section '.data' data readable writeable
  8.  
  9.            x     db  45
  10.            y     db  50
  11.            r_1   dw  ?       ; = 47
  12.            r_2   dw  ?       ; = 75
  13.  
  14. section '.code' code readable executable
  15.  
  16. start:    mov  eax, 0
  17.  
  18.           mov  al, [x]
  19.           mov  bl, [y]
  20.           add  al, bl        ; 1) 45 + 50 = 95
  21.           shr  al, 1         ; 2) 95 / 2  = 47 = r_1
  22.           mov  [r_1], ax
  23.           ;------------------------
  24.           mov  eax, 0
  25.           mov  ebx, 0
  26.           mov  al, [x]
  27.           mov  bl, [y]
  28.           mul  bx            ; 3) 50 * 45 = 2250
  29.           mov  bx, 30
  30.           idiv bx            ; 4) 2250/30 = 75 = r_2
  31.           ;------------------------
  32.  
  33.           add ax, [r_1]      ; 5) (r_1 + r_2) = (47 + 75) = 122 (answer)
  34.           cinvoke  printf, <"(x + y)/2 + (y * x)/30 =  %d", 10, 0>, eax
  35.  
  36.           ;------------------------
  37.           cinvoke  scanf, <"%d", 10, 0>, 76313
  38.           invoke   ExitProcess, 0
  39.  
  40.  
  41. section '.idata' import data readable
  42. library kernel32, 'kernel32.dll',\
  43.         msvcrt, 'msvcrt.dll'
  44.  
  45. import msvcrt,\
  46.        printf, 'printf',\
  47.        scanf, 'scanf'
  48.  
  49.                              
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement