Little 4line code RNG.
From: Hermann Samso (stu49252_at_mail.uni-kiel.de)
Date: 01/14/04
- Next message: Daniel.: "Re: Is Binary BrainF*** Turing-complete?"
- Previous message: H. Enderton: "Re: primitive recursive functions"
- Next in thread: Thomas Richter: "Re: Little 4line code RNG."
- Reply: Thomas Richter: "Re: Little 4line code RNG."
- Reply: Paul E. Black: "Re: Little 4line code RNG."
- Reply: CybercafeUser: "Re: Little 4line code RNG."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Daniel.: "Re: Is Binary BrainF*** Turing-complete?"
- Previous message: H. Enderton: "Re: primitive recursive functions"
- Next in thread: Thomas Richter: "Re: Little 4line code RNG."
- Reply: Thomas Richter: "Re: Little 4line code RNG."
- Reply: Paul E. Black: "Re: Little 4line code RNG."
- Reply: CybercafeUser: "Re: Little 4line code RNG."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|