-write_char:
-lodsb ; al = [ds:si], si += 1
-or al, al ; on null terminator,
-jz halt ; halt
-stosw ; [es:di] = ax, di += 2
-jmp write_char
+.write_cell: ; do {
+ call xs ; [XSS] = rand
+ mov al, DEAD ; al = DEAD (likely)
+
+ test word [XSS], 0b11
+
+ jnz .nz ; if ([XSS] % 4 == 0)
+ mov al, ALIVE ; al = ALIVE
+
+.nz:
+ stosb ; [es:(di++)] = al
+
+ loop .write_cell ; } while (--cx)
+
+ret
+
+; print_grid() - print GRID cells to screen -----------------------------------
+
+; (*) this function expects ds = 0 when called and sets es = 0 before
+; returning. this is simpler because in the rest of the program we want the
+; segment registers to be zeroed anyway.
+
+; clobbers ax, cx, di, si
+
+print_grid:
+
+les di, [farptr.vga_start] ; es:di -> VGA
+mov si, GRID ; ds:si -> GRID
+
+mov ah, PRINT_COLOR ; ah = color attribute
+
+mov cx, COLS * ROWS ; for each cell
+
+.print_cell: ; do {
+
+ lodsb ; al = [ds:(si++)]
+ stosw ; [es:di] = ax ; di += 2
+
+ loop .print_cell ; } while (--cx)
+
+mov es, cx ; es = 0
+ret
+
+; halt() - stop program execution ---------------------------------------------