Skip to content

Latest commit

 

History

History
65 lines (47 loc) · 1.96 KB

README.md

File metadata and controls

65 lines (47 loc) · 1.96 KB

@thi.ng/cspvm

Experimental, polyglot, work-in-progeess stack VM implementations around native cooperative multitasking and CSP channels to communicate and syncrhonize between tasks.

Op code table

Multiple (very incomplete) versions/experiments are in:

Zig

Source - most recent developments...

# currently requires Zig v0.12.x

# run tests/example
zig build test

# [default] (info): task size 240
# [default] (info): tasklist: dual-list.FixedBufferDualList(14,u8){ .active = 0, .available = 1, .slots = { 255, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 255 } }
# [default] (debug): task: 0
# [default] (debug): ip: 1000 op: vm.Op.push16 ds: {  } rs: {  }
# [default] (debug): ip: 1003 op: vm.Op.call ds: { 16, 32 } rs: {  }
# [default] (debug): ip: 1009 op: vm.Op.push ds: { 16, 32 } rs: { 6, 16 }
# [default] (debug): ip: 100b op: vm.Op.jump ds: { 16, 32, 48 } rs: { 6, 16 }
# [default] (debug): ip: 1010 op: vm.Op.push ds: { 16, 32, 48 } rs: { 6, 16 }
# [default] (debug): ip: 1012 op: vm.Op.trap ds: { 16, 32, 48, 64 } rs: { 6, 16 }
# [default] (info): trap task 16 #85
# 
# [default] (debug): ip: 1014 op: vm.Op.add16 ds: { 16, 32, 48, 64 } rs: { 6, 16 }
# [default] (debug): ip: 1015 op: vm.Op.ret ds: { 64, 96 } rs: { 6, 16 }
# [default] (debug): ip: 1006 op: vm.Op.push ds: { 64, 96 } rs: {  }
# [default] (debug): ip: 1008 op: vm.Op.halt ds: { 64, 96, 80 } rs: {  }
# [default] (debug): task 0 halted
# [default] (info): ds: { 64, 96, 80 } rs: {  }

# build optimized WASM binary & WAT disassembly
scripts/build-zig.sh

WebAssembly

Source - VM implementation in handwritten WASM

scripts/build-wasm.sh

TypeScript

Source - Initial implementation & tests

yarn install

yarn test

License

© 2022 - 2024 Karsten Schmidt // Apache Software License 2.0