Rickey Bowers Jr.
bitRAKE Studio
Monterey, CA, USA
Registered: Aug 2004
Posts: 3 |
Re: The MAA article
Originally posted by edpegg
I'm hoping to figure out the smallest possible self-contained program for Rule 30. In x86 it reduces to a couple bytes! :)
Put the rule value in all four bytes of a 32-bit register:
movzx eax, BYTE PTR [rule]
imul eax, 01010101h
Load bits from the line above:
mov edx, [edi]
Determine resulting bits with two instructions:
bt eax, edx
rcr ecx, 1
This last part is the important bit - let me explain more: all the 256 rules can be reduced to the single operation of testing the bit of the rule number coresponding to the three cells above. Example, for rule 30 (0001 1110 in binary) if the three cells above are 101 (5 in decimal) then the result is 0 (bit 5 is zero in the number 30. :)
There are many ways to optimize this algorithm further to compute billions of cells per second easily. I have a viewer wrote in assembly I might release soon. It wasn't wrote for size, but more speed to quickly move around in the basic rules.
A really small generator would be cool.
__________________
"Where nobody knows anything, there is no point in changing your mind." - Bertrand Russell
Last edited by Rickey Bowers Jr. on 08-20-2004 at 04:26 PM
Report this post to a moderator | IP: Logged
|