Close

Array variables access

A project log for L1VM

A tiny virtual machine with a 64 bit RISC CPU.

jay-tjay-t 06/01/2019 at 08:350 Comments

I added array variable access in the bracket compiler:

// array demo
//
(main func)
	(set int64 1 zero 0)
	(set int64 1 one 1)
	(set int64 1 offset 8)
	(set int64 1 x 23)
	(set int64 1 y 42)
	(set int64 1 a 0)
	(set int64 1 b 0)
	(set int64 2 z 0 0)
	// assign to array
	(x z [ zero ] =)
	(y z [ offset ] =)
	// get array variable
	(z [ zero ] a =)
	(z [ offset ] b =)
	(4 a 0 0 intr0)
	(7 0 0 0 intr0)
	(4 b 0 0 intr0)
	(7 0 0 0 intr0)
	(255 zero 0 0 intr0)
(funcend) 

All variable types are supported! The source code is on GitHub. There are some examples in the prog/ directory.

Discussions