Little 4line code RNG.

From: Hermann Samso (stu49252_at_mail.uni-kiel.de)
Date: 01/14/04


Date: Wed, 14 Jan 2004 02:38:50 +0100

Copyright(c)2004 by Hermann Samso.
All Rights Reserved.

Good evening.

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 much random, and hasn't yet been
studied or benchmarked respectly.

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 advisings and/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 probably 7 or 23 are also good
values.

saludos,
        Hermann Samso

# Copyright(c)2004 by Hermann Samso.
# All Rights Reserved.
# RND1.s
# An easy way ?

RND1 move.l D,d0
        divu d,d0
        ror.l #8,d0
        move.l d0,D

dc.l D 2147483647 ;dividend
dc.w d 65533 ;divisor

 Hermann Samso <so_o2@mailcity.com>
 http://members.tripod.com/so_o2



Relevant Pages

  • Re: Little 4line code RNG.
    ... > First test at a RNG with a Motorola ... > and Miller algorithm from 1969, ... and MC68000 can only divide ... I chose 8 bits, ...
    (comp.theory)
  • Extrapolate divisor & dividend from quotient?
    ... I'm trying to settle a debate. ... an algorithm by which the divisor and dividend can be determined ... I suppose that I should say "*a* divisor ... that I should say that I remember "being shown" such an algorithm, ...
    (sci.math)
  • Re: Extrapolate divisor & dividend from quotient?
    ... an algorithm by which the divisor and dividend can be determined ... I suppose that I should say "*a* divisor ... numbers that may yield a given quotient when divided. ... that I should say that I remember "being shown" such an algorithm, ...
    (sci.math)
  • Re: Extrapolate divisor & dividend from quotient?
    ... an algorithm by which the divisor and dividend can be determined ... Maybe you are after the "procedure" to get a decimal fraction from a ... numbers that may yield a given quotient when divided. ... that I should say that I remember "being shown" such an algorithm, ...
    (sci.math)
  • Re: Extended-Precision Division
    ... reinvented the algorithm and proved that it works for all possible combinations of divisor and dividend. ... Every grade school child taking Algebra can tell you that X/(Y + ...
    (comp.lang.asm.x86)