#include <iregdef.h>
#include <idtcpu.h>
        .text
        .globl  Syscall
/* *************************************************************************
        Syscall Handler
		This code will handle all syscalls
		When a Syscall is made you need to add 4 bytes to EPC, but since EPC is read-only we add it to the stack where we store EPC
************************************************************************* */

Syscall: 
                lw      t0, 20(sp)		// Load EPC
                addi    t0, 4			// Add 4 to the return adress
                sw      t0, 20(sp)		// Save EPC

		beq	v0, 1, ReadClock	// If v0 contains 1 jump to ReadClock
		beq	v0, 2, SetClock		// If v0 contains 2 jump to SetClock
		j	DisMiss			// jump dismiss

ReadClock:	la	t1, Clock		// Load the Clock
		lw	v0, 0(t1)		// Load the value in Clock
		j	DisMiss			// Jump dismiss

SetClock:	la	t1, Clock		// Load the Clock
		sw	v1, 0(t1)		// Save the value in v1 to the Clock
		j	DisMiss			// Jump dismiss


