Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/wapython
Path: blob/main/core/kernel/src/test/hello.c
1067 views
1
/*
2
This is "Hello World" for CoWasm.
3
4
To build and run under WaCalc:
5
6
make run-hello.wasm
7
8
The resulting program is VERY SMALL (235 bytes):
9
10
~/cowasm/packages/kernel$ ls -l build/test/hello.wasm
11
-rwxr-xr-x 1 wstein staff 235 Oct 30 08:02 build/test/hello.wasm
12
13
~/cowasm/packages/kernel$ wasm2wat build/test/hello.wasm
14
(module
15
(type (;0;) (func (param i32) (result i32)))
16
(type (;1;) (func))
17
(type (;2;) (func (param i32 i32) (result i32)))
18
(import "env" "memory" (memory (;0;) 1))
19
(import "env" "__memory_base" (global (;0;) i32))
20
(import "env" "__table_base" (global (;1;) i32))
21
(import "env" "puts" (func (;0;) (type 0)))
22
(func (;1;) (type 1))
23
(func (;2;) (type 1))
24
(func (;3;) (type 2) (param i32 i32) (result i32)
25
global.get 0
26
i32.const 0
27
i32.add
28
call 0
29
drop
30
i32.const 0)
31
(export "__wasm_call_ctors" (func 1))
32
(export "__wasm_apply_data_relocs" (func 2))
33
(export "__main_argc_argv" (func 3))
34
(data (;0;) (global.get 0) "Hello from CoWasm!\00"))
35
36
*/
37
38
#include <stdio.h>
39
40
int main(int argc, char** argv) {
41
printf("Hello from CoWasm!\n");
42
return 0;
43
}
44
45