Close

Time and date functions

A project log for L1VM

A tiny virtual machine with a 64 bit RISC CPU.

jay-tjay-t 02/28/2019 at 14:120 Comments

I added time and date functions via interrupt 0.

So programs can use this information to do something with it.

I wrote a little demo which shows "Hello world!" and the current time.

Here it is:

// bra(et - Hello world! and time!!
//
(main func)
	(set int64 1 zero 0)
	(set string 13 hello "Hello world!")
	(set string 2 colon ":")
	(set int64 1 hour 0)
	(set int64 1 min 0)
	(set int64 1 sec 0)
	(set int64 1 ten 10)
	(set int64 1 f 0)
	// print string
	(6 hello 0 0 intr0)
	// print newline
	(7 0 0 0 intr0)
	(17 hour min sec intr0)
	(((hour ten <) f =) f if)
		(4 zero 0 0 intr0)
	(endif)
	(4 hour 0 0 intr0)
	(6 colon 0 0 intr0)
	(((min ten <) f =) f if)
		(4 zero 0 0 intr0)
	(endif)
	(4 min 0 0 intr0)
	(6 colon 0 0 intr0)
	(((sec ten <) f =) f if)
		(4 zero 0 0 intr0)
	(endif)
	(4 sec 0 0 intr0)
	(7 0 0 0 intr0)
	(255 zero 0 0 intr0)
(funcend)

Discussions