-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|466|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
SoCoder -> Showcase Home -> Apps and Utilities

HoboBen
Created : 29 June 2010
Edited : 30 June 2010
System : Windows
Language : Cobra

Virtual Machine + Assembler

An open source Virtual Machine and Assembler for the Cobra programming language.

1.6mb zip
VM Updates
Screenshots
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!

Comments


Friday, 02 July 2010, 10:11
HoboBen
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.
Monday, 05 July 2010, 17:32
HoboBen
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)
; HapiFreeSprite(index)
; 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)