URL
https://opencores.org/ocsvn/mips32r1/mips32r1/trunk
Subversion Repositories mips32r1
[/] [mips32r1/] [trunk/] [Software/] [demos/] [XD3_I2C/] [src/] [os/] [exceptions.asm] - Rev 2
Compare with Previous | Blame | View Log
################################################################################ TITLE: Exception Vectors# AUTHOR: Grant Ayers (ayers@cs.utah.edu)# DATE: 23 May 2012# FILENAME: exceptions.asm# PROJECT: University of Utah XUM Single Core# DESCRIPTION:# Provides the exception vectors which jump to# exception-handling routines.################################################################################.text.balign 4.set noreorder.set noatexc_save:# Save all registers except k0 k1 sp raaddiu $sp, $sp, -112sw $1, 0($sp)sw $2, 4($sp)sw $3, 8($sp)sw $4, 12($sp)sw $5, 16($sp)sw $6, 20($sp)sw $7, 24($sp)sw $8, 28($sp)sw $9, 32($sp)sw $10, 36($sp)sw $11, 40($sp)sw $12, 44($sp)sw $13, 48($sp)sw $14, 52($sp)sw $15, 56($sp)sw $16, 60($sp)sw $17, 64($sp)sw $18, 68($sp)sw $19, 72($sp)sw $20, 76($sp)sw $21, 80($sp)sw $22, 84($sp)sw $23, 88($sp)sw $24, 92($sp)sw $25, 96($sp)sw $28, 100($sp)jr $rasw $30, 104($sp)exc_restore:# Restore all registers except k0 k1 sp ralw $1, 0($sp)lw $2, 4($sp)lw $3, 8($sp)lw $4, 12($sp)lw $5, 16($sp)lw $6, 20($sp)lw $7, 24($sp)lw $8, 28($sp)lw $9, 32($sp)lw $10, 36($sp)lw $11, 40($sp)lw $12, 44($sp)lw $13, 48($sp)lw $14, 52($sp)lw $15, 56($sp)lw $16, 60($sp)lw $17, 64($sp)lw $18, 68($sp)lw $19, 72($sp)lw $20, 76($sp)lw $21, 80($sp)lw $22, 84($sp)lw $23, 88($sp)lw $24, 92($sp)lw $25, 96($sp)lw $28, 100($sp)lw $30, 104($sp)jr $raaddiu $sp, $sp, 112.global mips32_general_exception.ent mips32_general_exceptionmips32_general_exception:or $26, $0, $rajal exc_savenopmfc0 $27, $13, 0 # Read Cause which has ExcCode bitssrl $27, $27, 2 # Extract exception code to $k1andi $27, $27, 0x001fla $ra, $end_exception # Jump to the appropriate handleraddiu $t0, $0, 4addiu $t1, $0, 5addiu $t2, $0, 8addiu $t3, $0, 9beq $t0, $27, mips32_handler_AdELaddiu $t0, $0, 10beq $t1, $27, mips32_handler_AdESaddiu $t1, $0, 11beq $t2, $27, mips32_handler_Sysaddiu $t2, $0, 12beq $t3, $27, mips32_handler_Bpaddiu $t3, $0, 13beq $t0, $27, mips32_handler_RInopbeq $t1, $27, mips32_handler_CpUnopbeq $t2, $27, mips32_handler_Ovnopbeq $t3, $27, mips32_handler_Trnop$end_exception:jal exc_restorexor $27, $0, $0or $ra, $0, $26xor $26, $0, $0eret.end mips32_general_exception### "Special" Interrupt Vector: Cause_IV must be set..ent mips32_interrupt_exception.global mips32_interrupt_exceptionmips32_interrupt_exception:mfc0 $26, $12, 0 # Status register for IM bitsmfc0 $27, $13, 0 # Cause register for IP bitsand $26, $26, $27 # Extract pending, unmasked interruptssrl $26, $26, 8andi $26, $26, 0x00ffaddu $27, $0, $rajal exc_saveclz $26, $26la $ra, $end_interrupt # All C functions will return hereaddiu $t0, $0, 24addiu $t1, $0, 25addiu $t2, $0, 26beq $26, $t0, mips32_handler_HwInt5addiu $t0, $0, 27beq $26, $t1, mips32_handler_HwInt4addiu $t1, $0, 28beq $26, $t2, mips32_handler_HwInt3addiu $t2, $0, 29beq $26, $t0, mips32_handler_HwInt2addiu $t0, $0, 30beq $26, $t1, mips32_handler_HwInt1addiu $t1, $0, 31beq $26, $t2, mips32_handler_HwInt0nopbeq $26, $t0, mips32_handler_SwInt1nopbeq $26, $t1, mips32_handler_SwInt0nop$end_interrupt:jal exc_restoremfc0 $26, $9, 0 # Clear HwInt5 if applicableor $ra, $0, $27eret.end mips32_interrupt_exception
