Random_Routine.s 374 B

123456789101112131415161718192021222324252627
  1. Get_Random_Number
  2. * D0 - Lower Bound, D1 - Upper Bound, number returned in d0
  3. mult equ 34564
  4. inc equ 7682
  5. seed equ 12032
  6. mod equ 65535
  7. move.l d2,-(sp)
  8. sub.w d0,d1
  9. addq.w #1,d1
  10. move.w old_seed,d2
  11. mulu.w #mult,d2
  12. add.l #inc,d2
  13. divu.w #mod,d2
  14. swap d2
  15. move.w d2,old_seed
  16. mulu.w d1,d2
  17. divu.w #mod,d2
  18. add.w d2,d0
  19. move.l (sp)+,d2
  20. rts
  21. old_seed dc.w seed