All Rights Reserved.
HSJ-RNG-20040204.txt
First test at a RNG with a Motorola
MC68000 processor.
First try was to code the Lewis, Goodman
and Miller algorithm from 1969, but then
realized that a long division opcode was
necessary, and MC68000 can only divide
by words.
So I gave up, and tried desperately with
a 32bit long dividend described in above
mentioned algorithm and a 16 bit number
as divisor, I chose 65533 that is nearly
the whole of 16bits.
The algorithm here described is probably
not too much random, and hasn't yet been
studied or benchmarked.
Anyways I found the results good enough
to be included in my last "retro scene
demo intro" for Atari ST. So, I have
decided to include it here, and maybe
get some advises or proofs.
The code I present here is in assembler
and can be easily compiled. It is only
4 instructions long!
It bases on the machine code of the
MC68000 which delivers remainder in the
high word, quotient in the low word of
a long word as result of an unsigned
division.
The only step inbetween is to rotate
this results around in the long word
by a fixed amount. I chose 8 bits,
but maybe 7 or 23 are also good values.
Greetings,
SOLO (BITS)
Code: Select all
# Copyright(c)2004-2011 by Herman Samso J..
# SoLo (BITS).
# http://thebitsclub.tripod.com
# All Rights Reserved.
# RND1.s
# An easy way ?
RND1
move.l Dend,d0
divu dsor,d0
ror.l #8,d0
move.l d0,Dend
Dend
dc.l 2147483647 ;dividend
dsor
dc.w 65533 ;divisor






