Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,37 @@
(module $lowercase
(import "wasi_unstable" "fd_write"
(func $fd_write (param i32 i32 i32 i32) (result i32))
)
(memory 1)
(export "memory" (memory 0))
(func $main (export "_start")
(local $i i32)
(i32.store (i32.const 0) (i32.const 8)) ;; offset to start of string
(i32.store (i32.const 4) (i32.const 27)) ;; string length
(set_local $i (i32.const 0))
(loop
;; mem[i+8] = i+97
(i32.store (i32.add (get_local $i) (i32.const 8)) (i32.add (get_local $i) (i32.const 97)))
;; i = i+1
(set_local $i (i32.add (get_local $i) (i32.const 1)))
;; if i < 26 then loop
(br_if 0 (i32.lt_s (get_local $i) (i32.const 26)))
)
;; append a newline
(i32.store (i32.add (get_local $i) (i32.const 8)) (i32.const 10))
;; write to stdout
(call $fd_write
(i32.const 1) ;; output stream to write to (1 == stdout)
(i32.const 0) ;; memory location containing string offset and length
(i32.const 1) ;; number of strings to write
(i32.const 40) ;; location in memory to write number of bytes written
)
drop
)
)