Skip to content

Commit

Permalink
layout
Browse files Browse the repository at this point in the history
  • Loading branch information
AjaniBilby committed Apr 18, 2024
1 parent a07b428 commit ed6a6d3
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions benchmark/rule-110/rule110.sa
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
external import {
fn fd_write(fd: i32, iovs: i32, iovs_len: i32, nwritten: i32): i32;
} from "wasix_32v1";

struct BoxInt {
value: i32;
}

fn print(str: i32): i32 {
let ptr: BoxInt = [ .value = 0 ];
fd_write(1, str, 1, ptr);

return ptr.value;
}

fn main(): i32 {
let board: linear#[bool, 30] = [ none ];

for (let i=0; i<30-2; i++) {
for (let j=0; j<30; j++) {
if board[j] print("*");
else print(" ");
}
print("\n");

let pattern = (board[0] << 1) | board[1];
for (let j=1; j<30-1; j++) {
pattern = ((pattern << 1) & 7) | board[j + 1];
board[j] = (110 >> pattern) & 1;
}
}

return 0;
}

0 comments on commit ed6a6d3

Please sign in to comment.