[virtmach] Test, Hello

thaddaeus.frogley@creaturelabs.com thaddaeus.frogley@creaturelabs.com
Thu, 4 May 2000 17:01:25 +0100


> I think that you have an impossible task, 

Pa.  Nothing is impossible!

I just thought I'd let you all know, that the VM just ran its first program.
Not the 'program' is written in 'machine code' and is embedded into the
source code of my test app, as I have no 'compiler' yet.  It counts to ten,
and back down to zero.  There are many more opcodes implemented than are
shown here, but this was the first test run that used program flow control.

Its really quite cool.  I have it running in a noddy 'debugger' that just
prints a program listing by talking to the map object (default map object
just dis-assembles).  I was going to include a screen shot of it in action,
but I thought that that would be a bit cheeky!  :)

//code block
VM2::Instruction i[256] = { 
	{ 0 },			//
	{ 12,  6,  1 },		//0 : STACK D[6],1		;push zero
	{ 16,  1,  0,  0 },	//1 : ADDI  D[1],S[0],S[0]
;S[0]=S[0]+D[0]
	{ 55,  0,  2,  1 },	//2 : JLI   S[0],D[2],D[1]	;if
(S[0]<D[2]) goto D[1]
	{ 20,  1,  0,  0 },	//3 : SUBI  D[1],S[0],S[0]
;S[0]=S[0]-D[0]
	{ 52,  0,  3 },		//4 : JNZ   S[0],D[3]		;if  (!S[0])
goto D[3]
	{ 11, -1  },		//5 : STACK -1			;pop
	{  0  }			//6 : NOP
};

//data block
int32 d[256] = {
	0, 1, 10, 3
};

Sorry to interrupt your busy work with this non-event, but frankly I'm quite
excited about it.  :)

Oh well... best get back to work and implement the indirection operations...

Thad