]>
wirehaze git hosting - lifeboot.git/blob - lifeboot.asm
10 %
define DEAD
' ' ; char to represent a dead cell
11 %
define ALIVE
'#' ; char to represent an alive cell
12 %
define PRINT_COLOR
0x07 ; grey on black
14 %
define GRID
ORG + 512 ; current cell grid (80 * 25 bytes)
15 %
define NEXT_GRID GRID
+ COLS
* ROWS
; next cell grid (80 * 25 bytes)
16 %
define XSS NEXT_GRID
+ COLS
* ROWS
; xs() state
18 ; entry point -----------------------------------------------------------------
20 ; initialize segment registers
30 ; clear screen ----------------------------------------------------------------
42 mov ax, (PRINT_COLOR
<< 8) | DEAD
44 rep stosw ; fill cx words at es:di with ax
46 ; setup -----------------------------------------------------------------------
52 int 0x1a ; system time
53 mov [XSS
], dx ; cx:dx = number of clock ticks since midnight
61 mov dl, DEAD
; dl = DEAD (likely)
65 jnz .initgrid_nz
; if (ax % 4 == 0)
66 mov dl, ALIVE
; dl = ALIVE
69 mov [di + cx], dl ; grid[cx] = dl
71 loop .initgrid
; } while (--cx)
75 ; functions -------------------------------------------------------------------
77 ; xs() - xorshift pseudorandom number generator -------------------------------
80 ; ax = updated state ([XSS])
89 shl dx, 1 ; dx = xss << 1
90 xor ax, dx ; ax = xss ^ (xss << 1)
93 shr dx, 3 ; dx = xss' >> 3
94 xor ax, dx ; ax = xss' ^ (xss' >> 3)
97 shl dx, 10 ; dx = xss'' << 10
98 xor ax, dx ; ax = xss'' ^ (xss'' << 10)
103 ; errors ----------------------------------------------------------------------
108 ; print the error message string in si and halt
109 ; note: we assume es = VGA_SEG and ds = 0
114 ; es:di = video memory
115 ; ds:si = error message
117 ; ah = color attribute
120 lodsb ; al = [ds:si], si += 1
121 or al, al ; on null terminator,
123 stosw ; [es:di] = ax, di += 2
127 cli ; disable interrupts
131 ; data ------------------------------------------------------------------------
137 times 510 - ($ - $$) db 0 ; fill remaining bytes with zeroes
138 dw 0xaa55 ; mbr magic byte