add readme
This commit is contained in:
1 parent
16df0f8513
commit
00e323389b
1 file changed
+67
@@ -0,0 +1,67 @@
|
||||
# wasm-runtime
|
||||
|
||||
A WebAssembly runtime for KolibriOS, written in FASM.
|
||||
|
||||
Currently builds as a Linux binary for easier development and testing. The final target is KolibriOS native format.
|
||||
|
||||
## What it does right now
|
||||
|
||||
Parses a `.wasm` binary and prints out everything it finds — sections, types, imports, exports, and function signatures in a readable format:
|
||||
|
||||
```
|
||||
$ ./src/wasm test/wasm/add.wasm
|
||||
Valid wasm file
|
||||
File size: 41 bytes
|
||||
Section 1 (Type), size: 7 bytes
|
||||
type 0: (i32, i32) -> (i32)
|
||||
Section 3 (Function), size: 2 bytes
|
||||
func 0 -> type 0
|
||||
Section 7 (Export), size: 7 bytes
|
||||
export "add" -> func 0
|
||||
Section 10 (Code), size: 9 bytes
|
||||
body 0: 7 bytes
|
||||
Function index: 1 entries
|
||||
func 0 -> type 0 (local)
|
||||
Function signatures:
|
||||
i32 add(i32, i32)
|
||||
```
|
||||
|
||||
## What's implemented
|
||||
|
||||
- wasm binary header validation (magic number + version)
|
||||
- LEB128 decoding (unsigned and signed)
|
||||
- section enumeration (all 13 section types recognized)
|
||||
- type section parsing (function signatures with i32/i64/f32/f64)
|
||||
- import section parsing (functions, tables, memories, globals)
|
||||
- export section parsing
|
||||
- function section + code section parsing
|
||||
- unified function index (imports first, then locals, per spec)
|
||||
- human-readable function signature output
|
||||
|
||||
## Build
|
||||
|
||||
```
|
||||
fasm src/wasm.asm src/wasm
|
||||
chmod +x src/wasm
|
||||
```
|
||||
|
||||
## Test
|
||||
|
||||
```
|
||||
sh test/build_wasm.sh # compile .wat files to .wasm (needs wat2wasm)
|
||||
sh test/run_tests.sh # run from repo root
|
||||
```
|
||||
|
||||
## Structure
|
||||
|
||||
```
|
||||
src/
|
||||
wasm.asm main entry point
|
||||
leb128.inc LEB128 variable-length integer decoder
|
||||
sections.inc section parsers
|
||||
test/
|
||||
wat/ source .wat files
|
||||
wasm/ compiled .wasm binaries
|
||||
build_wasm.sh compiles wat -> wasm
|
||||
run_tests.sh test runner
|
||||
```
|
||||
Reference in new issue
Block a user