Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. %include "io.inc"
  2.  
  3. section .data
  4.  
  5. section .bss
  6.     n resd 1
  7.  
  8. section .text
  9.  
  10. foo:
  11.     xor     ecx, ecx
  12. .loop:
  13.     cmp     eax, 0
  14.     je      .endLoop
  15.     mov     ebx, 1
  16.     and     ebx, eax
  17.     add     ecx, ebx
  18.     shr     eax, 1
  19.     mov     ebx, 1
  20.     and     ebx, eax
  21.     sub     ecx, ebx
  22.     shr     eax, 1
  23.     jmp     .loop
  24. .endLoop:
  25.     mov     eax, ecx
  26.     ret
  27.    
  28.  
  29. global CMAIN
  30. CMAIN:
  31.     mov     ebp, esp; for correct debugging
  32.     GET_UDEC 4, [n]
  33.     xor esi, esi
  34. .outerLoop:
  35.     cmp     esi, dword[n]
  36.     jge     .exitOuterLoop
  37.     GET_UDEC 4, eax
  38. .innerLoop:
  39.     cmp     eax, 3
  40.     jl      .exitInnerLoop
  41.     call    foo
  42.     jmp     .innerLoop
  43. .exitInnerLoop:
  44.     inc     esi
  45.     cmp     eax, 0
  46.     jne      .no
  47.     PRINT_STRING "YES"
  48.     NEWLINE
  49.     jmp     .outerLoop
  50. .no:
  51.     PRINT_STRING "NO"
  52.     NEWLINE
  53.     jmp     .outerLoop
  54. .exitOuterLoop:
  55.  
  56.     xor     eax, eax
  57.     ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement