Advertisement
Guest User

Untitled

a guest
Jun 3rd, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. extern _printf
  2. extern _scanf
  3. extern _exit
  4. global _main
  5.  
  6. section .text
  7. _main:
  8.     push num
  9.     push format
  10.     call _scanf
  11.     add esp, 8
  12.  
  13.     mov eax, [num]
  14.     mov edx, 0
  15.     mov ebx, 5
  16.     cdq
  17.     idiv ebx
  18.     cmp edx, 0
  19.     je .qw
  20.  
  21. .ow:
  22.     mov eax, [num]
  23.     mov edx, 0
  24.     mov ebx, 2
  25.     div ebx
  26.     cmp edx, 0
  27.     jne .odd
  28.  
  29. .even:
  30.     push dword [num]
  31.     push format
  32.     call _printf
  33.     add esp, 8 
  34.     push msg1
  35.     call _printf
  36.     add esp, 4
  37.     jmp .end
  38. .odd:
  39.     push dword [num]
  40.     push format
  41.     call _printf
  42.     add esp, 8 
  43.     push msg2
  44.     call _printf
  45.     add esp, 4
  46. .end:
  47.     push dword 0
  48.     call _exit
  49.  
  50.  
  51. .qw:
  52.     push dword [num]
  53.     push format
  54.     call _printf
  55.     add esp, 8 
  56.     push msg3
  57.     call _printf
  58.     add esp, 4
  59.     jmp .ow
  60.  
  61.  
  62. section .data
  63. msg1: db ' is even', 0
  64. msg2: db ' is odd', 0
  65. msg3: db ' divable by 5', 13, 10, 0
  66. num: dd 0
  67. format: db "%d", 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement