/* *****

        Operative System for MIPS Written by Filip Ekberg at the Blekinge Institute Of Technology
        Contact: Filip@SmartIT.se

*** */

#include <iregdef.h>
#include <idtcpu.h>
        .text
        .globl  DisMiss
/* *************************************************************************
        Dismiss Error
		This will be called to dismiss an error and restore all registeries
		also it will jump to the position after the exception
************************************************************************* */

DisMiss:

	.set noreorder			// Do not allow the asm to re-order the code below
	lw	k0, 20(sp)		// Load the EPC from the stack and put it in k0
	nop

	// -- Restore destroyed registery
        lw      t0, 0(sp)
        lw      t1, 4(sp)
        lw      t2, 8(sp)
        lw      t3, 12(sp)
        lw      ra, 16(sp)
	// -- //

	addi	sp, 128			// Restore the Stack pointer
	
	jr	k0			// Jump to EPC
	rfe				// "Return from Exception
	.set reorder			// Enable re-order again
