Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set A, 16 ; A-number 1
- set B, 87 ; B-number 2
- set C, 1 ; C-current power of two to test
- set push,0 ; flag to signal end of stack
- :loop
- set X,A
- and X,C ; X contains 0 if not factor of C,else C
- ifn X,0 ;if a factor
- set push,X ; add factor to stack
- ifg C,A
- set PC,muladd ;done finding factors, multiply them and add
- shl C,1 ;try next factor
- set PC,loop ;loop
- :eloop
- :muladd
- set Y,0 ;Y=accumulator
- :aloop
- set Z,pop ;z=current factor
- set I,B ;i=multiply space
- :muloop
- shr Z,1
- ife Z,0
- set PC,emuloop
- shl I,1
- set PC,muloop
- :emuloop
- add Y,I
- ife peek,0
- set pc,end
- set pc,aloop
- :end
- set pc,end
Add Comment
Please, Sign In to add comment