
	.incdir	"F:\git\goldmomo_endlos\assembler_files\ucore\hcore\"
	.include	"include/uctrl_port.i"

	org	hcoreStartPc
	
	nop
	nop
	nop
	nop
	nop
	
	gssr	hold,0
	cmpeq	last,0
	br.tc	stop
	nop
	nop
	nop
	nop
	nop
	
	move	r20,0		;counter

loop	
	
	;read	SW
	
	.execm	ucpSetParam(0,$8000)				;			param 0 = $8000
	.execm	ucpCallReturn(r10,upfCallSubUCtrlRead)		;call r10 = ucrlRead(			   )
	
	
	and	r20,r20,$f	;low 4 is counter
	nop
	lsl	hold,r10,4	;sw << 4
	or	r10,last,r20	;or counter
	
	;write to ledg

	.execm	ucpSetParam(0,$8001)				;			param 0 = $8001
	.execm	ucpSetParam(1,r10)				;			param 1 = r10
	.execm	ucpCallReturn(r11,upfCallSubUCtrlWrite)		;call r10 = ucrlWrite(			   )
	
	nop
	fead	r11,r11		;wait for r10 write finish
	
	br	loop
	add	r20,r20,1
	nop
	nop
	nop
	nop
	
stop	br	stop
	nop
	nop
	nop
	nop
	nop
	
	
	
	
	
	
	
	
	
	