#include "sys.h"
#include "picorv32.h"

	// The linker ensures that section .init is first
	.section ".init.reset","ax"
	.globl _reset
_reset:
	rdtime t0		// Record timer at reset
	li sp,STACK_TOP		// Cheaper than using la sp,___stack_top
	.option push
	.option norelax		// Can't make gp references to set up gp...
	la gp, __global_pointer$
	.option pop
	addqxi gp,gp,0		// Set gp for interrupt code too
	sw t0, time_zero, t1
	j _start
	.type _reset, @function
	.size _reset, . - _reset

	.pushsection ".sdata","a"
	.balign 4
	.globl time_zero
time_zero:
	.long 0
	.type time_zero, @object
	.size time_zero, . - time_zero
	.popsection

	.section ".stack","aw",@nobits
	.balign 4
	.globl ___stack_bottom
___stack:
	.space STACK_SIZE
	.type ___stack, @object
	.size ___stack, STACK_SIZE

	.globl ___stack_top
___stack_top:
