daily pastebin goal
69%
SHARE
TWEET

Untitled

a guest Nov 16th, 2018 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.      set A, 16  ; A-number 1
  2.      set B, 87 ; B-number 2
  3.      set C, 1   ; C-current power of two to test
  4.      set push,0 ; flag to signal end of stack
  5. :loop
  6.      set X,A
  7.      and X,C    ; X contains 0 if not factor of C,else C
  8.  
  9.      ifn X,0    ;if a factor
  10.        set push,X ; add factor to stack
  11.      ifg C,A
  12.        set PC,muladd  ;done finding factors, multiply them and add
  13.      shl C,1        ;try next factor
  14.      set PC,loop ;loop
  15.  :eloop
  16.  
  17.  :muladd
  18.      set Y,0   ;Y=accumulator
  19.      :aloop
  20.            set Z,pop ;z=current factor
  21.            set I,B   ;i=multiply space
  22.            :muloop
  23.                   shr Z,1
  24.                   ife Z,0
  25.                     set PC,emuloop
  26.                   shl I,1
  27.                   set PC,muloop
  28.            :emuloop
  29.            add Y,I
  30.            ife peek,0
  31.              set pc,end
  32.            set pc,aloop
  33.  
  34.  
  35. :end
  36.     set pc,end
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