Micrornd - Pseudorandom numbers for 8-bit microcomputers

Micrornd - Pseudorandom numbers for 8-bit microcomputers

Robbert Haarman


Posted by inglorion
at 2019-05-26 05:04:10

Several years ago, I came up with the deadbeef random number generator - so named because it uses the constant 0xdeadbeef. It gained some popularity with people programming for 8-bit systems like AVR microcontrollers. Now that I have some experience programming for 8-bit CPUs like AVRs and the 6502, I decided to design a pseudorandom number generator specifically for those systems. The result is Micrornd.

Micrornd is not based on the deadbeef random number generator, but a comparison between the two may still be instructive. Deadbeef operates on 32-bit quantities and shifts bits 7 or 25 positions. This would require many instructions on a 6502 or AVR, so Micrornd instead performs simple 8-bit operations and a single bit shift. This makes Micrornd quite a bit smaller and faster than deadbeef_rand would be on these systems.

Valid XHTML 1.1! Valid CSS! Viewable with Any Browser