# Micro-Life

Problem #213

Tags: assembly challenge games

This task has a Challenge attached.
You may View Stats or read a Help on Challenges.

Glider on a toroidal board

This problem was suggested by our colleague Andrey 'GlideThestral' - thanks a lot for idea!

There was a problem about Game of Life. Now let us implement it for Intel-4004 CPU emulator, in assembly language. We suggest you have already played with other assembly problems and do know how to use emulator etc.

As the small CPU have limited amount of code and data memory, let us describe simplified version of the game:

• we play on `8*8` field;
• only single step needs to be calculated;
• the field has the topology of toroidal chess-board - as if its opposite sides are glued together.

To explain this by example let us consider the `glider` moving through such board:

``````- - - - - X - -        - - - - - - - -        - - - - - - - -        - - X X X - - -
- - - - - - X -        - - - - - - - -        - - - - - - - -        - - - - - - - -
- - - - X X X -        - - - - - - - X        - - - - - - - -        - - - - - - - -
- - - - - - - -        X - - - - - - -        - - - - - - - -        - - - - - - - -
- - - - - - - -        X - - - - - X X        - - - - - - - -        - - - - - - - -
- - - - - - - -        - - - - - - - -        - - X - - - - -        - - - - - - - -
- - - - - - - -        - - - - - - - -        - - - X - - - -        - - - X - - - -
- - - - - - - -        - - - - - - - -        - X X X - - - -        - - - - X - - -
step 0                 step 8                 step 20                step 24
``````

Such topology allows us to avoid colliding of configurations with the edges - i.e. to pretend the board is quasi-infinite (though large configurations will usually collide with themselves).

Challenge
The goal is to create the fastest program to process `1` step of the Life Game.
As always, we check not the specific answer, but your code in Asm-4004. It will be executed against some secret input (the same for all users). It should not take more than `50000` cycles - and program should not exceed `256` bytes. New version of emulator allows calculation of cycles (they are printed along with registers) - or simply shown in interface of our online emulator.

Two-byte instructions take two clock cycles. Single-byte instructions take one clock cycle - except for `fin` which also takes two.

Input there are `8` lines of `8` characters each - either `0` for empty cell or `1` for occupied one. Lines are separated by single newline character (there is trailing newline also). So at all input consists of `72` characters.
Answer should also give the same lines, but they could be separated by any character you prefer (e.g. newline, dot, dash).

Example:

``````input data:
01000000
10100110
01100111
00111001
00000001
00001000
00001000
01100000

10000000
10100100
00000000
01111101
00001000
00000000
00010000
01100000
``````
You need to login to get test data and submit solution.