\ cpu-specific part for the runtimer
only forth also definitions  decimal

10000000 constant nsec/tick	\ 100hz tickerV

variable ticker
code interrupt-code
	r0	sp		push
	r0	'body ticker	pcr ldr
	r0	1		incr
	r0	'body ticker	pcr str
	r0	sp		pop
	pc	lk		s mov end-code

\ install ticker in the TICKERV
code install-ticker
	r0	h# 1c #		mov	\ vector-id for tickerV
	r1	'body interrupt-code adr
	r2	0 #		mov
		h# 47		swix c; install-ticker

\ remove-ticker stops ticker and removes the rma
code remove-ticker
	r0	h# 1c #		mov	\ id for tickerV
	r1  'body interrupt-code adr
	r2	0 #		mov
		h# 20		swix c;	\ release tickerV

code time)	\ (r ret_to  data #time -- ) points to the following code
	here /token + a,
	r1 r2 ip 3	rp ia!	ldm  \ r1:#time, r2:next-ip
	r0	'body ticker	pcr ldr
	r0	r0	r1	sub  \ r0:used time
	r3 r4	2 	r2 db!	ldm  \ r3:calls r4:time
	r3	1		incr
	r4	r4	r0	add							  
	r3 r4 2 r2 ia!		stm c;

code (time	\ (r ret_to -- ret_to  next-ip #time 'timer> )
	r1	'body ticker	pcr ldr
	r0	'body time)	adr
	ip	2 cells		incr
	r0 r1 ip 3	rp db!	stm c;


only forth also definitions
