VM-proto
From Mindstab Wiki
VM-proto is a small language I wrote in the fall of 2004 as a learning experiment. It's a small compiler and virtual machine for a tiny asm like language that is register based. I used it to learn about some basic VM concepts and portability issues especially endian issues. It is endian safe has been tested on Linux on x86 and PPC; BSD on x86; and SunOS on Sparc. Objects compiled on any OS/architecture run identically on all other platforms.
Some benchmark info is provided in VM2. Benchmark summery was that it found primes at about the same speed as perl, and faster than python.
You can get the code and some test programs at ftp.mindstab.net/vm-proto or from git by
git clone git://git.mindstab.net/git/vm-proto
My big finale demo was a prime number finder, as shown below:
mov r1 100000
mov r2 3
mov r3 2
mov r4 4
@loop
mov r5 3
@calc
cmp r5 r3
jg @showPrime n
mov r6 r2
mod r6 r5
cmp r6 0
je @afterCalc n
add r5 2
jmp @calc n
@afterCalc
add r2 2
cmp r2 r4
jge @incSq n
@endLoop
cmp r2 r1
jg @end n
jmp @loop n
@showPrime
disp r2 n
jmp @afterCalc n
@incSq
add r3 1
mov r4 r3
mul r4 r4
jmp @endLoop n
@end
