Skip to content

Instantly share code, notes, and snippets.

@learosema
Last active September 16, 2021 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save learosema/19f47b52eec89d27b497 to your computer and use it in GitHub Desktop.
Save learosema/19f47b52eec89d27b497 to your computer and use it in GitHub Desktop.
Rule 90 cellular automaton in x86 assembler.

One-dimensional cellular automaton written in x86 assembler for DOSBox, using the rule 90 algorithm. The algorithm was published 1983 by Stephen Wolfram.

##Compiling and running this gist

  1. Get DOSBox
  2. Get FreeDOS DEBUG
  3. Compile: debug < RULE90.ASM
  4. Run: RULE90.COM
  5. Customize it! For example, you can choose another rule in line 35

##License

            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
                    Version 2, December 2004

 Copyright (C) 2015 Lea Rosema

 Everyone is permitted to copy and distribute verbatim or modified
 copies of this license document, and changing it is allowed as long
 as the name is changed.

          DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

  0. You just DO WHAT THE FUCK YOU WANT TO.

##See also

  1. Rule 90
  2. Cellular automaton
  3. Stephen Wolfram
  4. JavaScript version
a
mov ax,13
int 10
mov di,a000
mov es,di
mov di,f820
es:
mov byte ptr [di],0f
'---111---
mov di,f8c1
mov cx,13e
'---117---
es:
mov al,byte ptr [di-141]
and al,1
shl al,2
es:
mov bl,byte ptr [di-140]
and bl,1
shl bl,1
or al,bl
es:
mov bl,byte ptr [di-13f]
and bl,1
or al,bl
mov bl,1
'---139---
test al,al
jz 143
'---13d---
shl bl,1
dec al
jnz 13d
'---143---
mov bh,5a
and bh,bl
jz 14b
mov bh,0f
'---14b---
es:
mov byte ptr [di],bh
inc di
dec cx
jnz 117
mov di,a000
mov es,di
mov ds,di
mov cx,f8c0
mov si,140
mov di,0
rep movsb
mov dx,3da
in al,dx
test al,8
jnz 167
in al,dx
test al,8
jz 16C
jmp 111
rcx
73
nrule90.com
w
q
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment