The game of life in 177 bytes

Assembly for x86 family processors

Moderators: Daniel Pitts, Phang

The game of life in 177 bytes

Postby Daniel Pitts » Thu Nov 24, 2005 11:22 am

It could probably be a little smaller, but I didn't have time to optimize it.
Press ESC to exit, or any other key to re-randomize the initial state.
For some reason, if you re-randomize more than 7 times, it'll crash. Ohwell.
Code: Select all
debug life.com
a
MOV   AX,0013
INT   10
MOV   AX,SS
ADD   AX,3000
MOV   DS,AX
ADD   AX,1000
MOV   ES,AX
XOR   SI,SI
MOV   CX,FA00
MOV   AX,CAFE
MOV   DX,BABE
MOV   BX,AX
XOR   AX,DX
ROR   DX,1
SUB   DX,AX
ROL   AX,1
XOR   BX,AX
ADD   BX,DX
ROR   BX,1
ADD   AX,0007
SUB   DX,00F0
ADD   BX,AX
AND   BL,01
MOV   [SI],BL
INC   SI
LOOP   011C
MOV   CX,FA00
XOR   SI,SI
XOR   DI,DI
MOV   AL,[SI+FEBF]
ADD   AL,[SI+FEC0]
ADD   AL,[SI+FEC1]
ADD   AL,[SI-01]
ADD   AL,[SI+01]
ADD   AL,[SI+013F]
ADD   AL,[SI+0140]
ADD   AL,[SI+0141]
OR   AL,[SI]
STOSB   
INC   SI
LOOP   0144
XCHG   CX,SI
PUSH   DS
MOV   AX,A000
PUSH   AX
PUSH   ES
POP   DS
POP   ES
MOV   DL,03
XOR   DI,DI
CMP   [SI],DL
MOV   [SI],AL
JNZ   017E
INC   BYTE PTR [SI]
MOVSB   
LOOP   0176
POP   ES
MOV   DX,03DA
IN   AL,DX
TEST   AL,08
JZ   0185
IN   AL,DX
TEST   AL,08
JNZ   018A
MOV   AH,01
INT   16
JZ   013D
MOV   AH,00
INT   16
CMP   AL,1B
JZ   01AA
CS:   
INC   WORD PTR [0117]
CS:   
INC   WORD PTR [0119]
JMP   0111
MOV   AX,0003
INT   10
INT   20

r cx
b1
w
q
life.com
There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. - C.A.R. Hoare
Daniel Pitts
Site Admin
 
Posts: 41
Joined: Wed Feb 23, 2005 12:18 pm
Location: Walnut Creek, California

Return to 80x86 Assembly

Who is online

Users browsing this forum: No registered users and 1 guest

cron