1 #target WASI
7 Structure IOV Consists Of { CharacterPointer iov_base;
11 Integer32 iov_len;
12 }
13 EndStructure;
14
15 Function
16 fd_write(Integer32 file_descriptor, IOVPointer iovs, Integer32 iovs_len,
17 Integer32Pointer nwritten) Which Returns Integer32 Is External;
18
19 Function strlen(CharacterPointer str) Which Returns Integer32 Does {
20 Integer32 size : = 0;
21 While ValueAt(str + size) Loop { size += 1; }
22 EndWhile;
23 Return size;
24 }
25 EndFunction;
26
27 Integer32 stdout : = 1;
28
29 Function printString(CharacterPointer string) Which Returns Nothing Does {
30 InstantiateStructure IOV iov;
31 iov.iov_base : = string;
32 iov.iov_len : = strlen(string);
33 Integer32 tmp : = fd_write(stdout, AddressOf(iov),
34 1 ,
35 AddressOf(tmp));
36 }
37 EndFunction;
38
39 Function main() Which Returns Nothing Does {
40 printString(
41 "Hello world, I am writing this from from WASI!\n"); }
47 EndFunction;
48
49 asm("(export \"_start\" (func $main))");