|Virtual Machine + Assembler - Created by HoboBen (No Votes)|
An open source Virtual Machine and Assembler for the Cobra programming language.
|The imaginatively named "vm" Virtual Machine is a typeless, procedural VM, with native support for functions and strings. Use the "vmAsm" assembler to assemble programs into a vmx (VM eXecutable) binary file that vm can run.|
This program is open source - see license-vm.txt and license-vmAsm.txt for licensing details.
Contains an example front-end with an example script ready-to-run!
|Posted : Friday, 02 July 2010, 09:11|
|Bugs & fixes:|
Fixed a bug where global arrays were accessed in the wrong direction (local ones were working). Here's the fix - replace the Vm_ResolveOpStackIndex function in vm.cps (line 300) with the following:
Additionally, HAPI funcs were buggy. Fix Vm_GetHapiFunc in vm.cps (line 456):
At approx line 1200, these instructions also need fixing:
Unfixed: Assembly scripts will not work properly if a function has both local variables (var) AND parameters (param). Either on its own will work. Workaround: use global variables for some function vars or params.
|Posted : Monday, 05 July 2010, 16:32|
|Working pacman example:|
Download (ready-to-run!) ~1.5 MB
The example is over 1000 lines of assembly and took four days. You'd be mad to actually use the VM this way, but as a "proof of concept" it's pretty good.
Host API functions:
; HapiDrawCell (x, y, cellState)
; HapiCreateSprite(), returns index
; HapiPositionSprite(index, x, y)
; HapiSetSpriteFrame(index, frame)
; HapiGetDelta(), returns delta as real
; HapiRnd(), returns random number between 0 and 1
; HapiGetTicks(), returns ticks as integer
; HapiKeyDown(key), returns 0 (false) or 1 (true)
; HapiDisplayStats(score, eaten)