assembly - MIPS Exception Printing NOT working -
mips exception handler code not working: in following code attempt print out addresses of instruction caused exception (register $14) , type of exception (register $13). have exhausted every possible route think of.
the error message gives:
"lw": few or incorrectly formatted operands. expected: lw $t1,-100($t2)
thank you!
mfc0 $k0,$14 # coprocessor 0 register $14 has address of trapping instruction lw $a0, $k0 # address of string print li $v0, 4 # print string service syscall mfc0 $k0,$13 # coprocessor 0 register $13 has type of exception lw $a0, $k0 # address of string print li $v0, 4 # print string service syscall
instead of:
lw <regdst>,<regsrc>
do:
move <regdst>,<regsrc>
move
pseudo-op [most likely] generate:
addu <regdst>,<regsrc>,$zero
or, done with:
addiu <regdst>,<regsrc>,0
side note: i've written full exception handler before, sure first instruction [more or less]:
move $k0,$at
and, epilog looks like:
move $at,$k0 eret
i establish stack frame normal function [saving other registers changed] , pop @ end
the reason mention this, exception handler must save every register change , restore original value on exit if it's going return base code (e.g. might trap , fix overflow exception).
this [especially] true handling breakpoints.