Advertisement
miki_brill

Untitled

Dec 27th, 2014
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. rand: mov r1,-(sp)
  2. mov r2,-(sp)
  3. mov r3,-(sp)
  4. mov seed,r0
  5. mul #123,r0
  6. add #1073,r1 ;r1 holds the number : seed*123(octal)+1073(octal)
  7. mov (r5)+,r0 ; r0 now holds the number "n"
  8. modulo_loop: cmp r1,r0
  9. blos update_seed ;if the number in r1 is less than "n" end modulo loop
  10. sub r0,r1 ;subtract "n" from the current number
  11. br modulo_loop
  12. update_seed: mov r1,r0 ;put result in r0
  13. mov seed,r2
  14. mov seed,r3
  15. bic #125252,r2 ;r2 holds 1's only in even bits in which seed has 1's
  16. bic #052525,r3 ;r3 holds 1's only in odd bits in which seed has 1's
  17. tst r2
  18. bpl if_positive
  19. if_negative: sec
  20. br before_roll
  21. if_positive: clc
  22. br before_roll
  23. before_roll: rol r2
  24. rol r2
  25. bis r3,r2 ;put 1's in odd places where original seed had 1's
  26. add seed,r2
  27. add #1,r2
  28. mov r2,seed ;update seed according to specifications
  29. mov (sp)+,r3
  30. mov (sp)+,r2
  31. mov (sp)+,r1
  32. rts r5
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement