daily pastebin goal
30%
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. ;trying to find the smallest integer such that the numbers 1 through k are all even divisors
  3.  
  4. section .text
  5.     global _start
  6.  
  7. _start:
  8.     mov ecx,20  ;let's define our 'k'
  9.     mov ebx,1   ;might as well start looking at 1
  10.  
  11. next_candidate_number:
  12.     inc ebx ;go ahead and increment ebx
  13.  
  14.     mov esi,0   ;i know dividing by 1 is a waste of time, it's just prettier this way
  15.  
  16. next_divisor:
  17.     inc esi ;this'll set it to 1 in the first iteration before we die of a lack of definition
  18.  
  19.     cmp esi,ecx ;if our divisor is greater than our target, we can bail
  20.     ja  yay_done
  21.  
  22.     mov eax,ebx ;get ready to divide
  23.     xor edx,edx ;
  24.     div esi ;
  25.  
  26.     cmp edx,0   ;see if there's a remainder
  27.     jne next_candidate_number   ;if there is one, try the next number because this one sucks
  28.    
  29.     jmp next_divisor
  30. yay_done:
  31.  
  32.     mov eax,1
  33.     ;mov    ebx,nothing because it's already there!
  34.     int 0x80
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top