Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rand: mov r1,-(sp)
- mov r2,-(sp)
- mov r3,-(sp)
- mov seed,r0
- mul #123,r0
- add #1073,r1 ;r1 holds the number : seed*123(octal)+1073(octal)
- mov (r5)+,r0 ; r0 now holds the number "n"
- modulo_loop: cmp r1,r0
- blos update_seed ;if the number in r1 is less than "n" end modulo loop
- sub r0,r1 ;subtract "n" from the current number
- br modulo_loop
- update_seed: mov r1,r0 ;put result in r0
- mov seed,r2
- mov seed,r3
- bic #125252,r2 ;r2 holds 1's only in even bits in which seed has 1's
- bic #052525,r3 ;r3 holds 1's only in odd bits in which seed has 1's
- tst r2
- bpl if_positive
- if_negative: sec
- br before_roll
- if_positive: clc
- br before_roll
- before_roll: rol r2
- rol r2
- bis r3,r2 ;put 1's in odd places where original seed had 1's
- add seed,r2
- add #1,r2
- mov r2,seed ;update seed according to specifications
- mov (sp)+,r3
- mov (sp)+,r2
- mov (sp)+,r1
- rts r5
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement