Reputation: 83
I've been studying assembly lately and i can't seem to understand how the exceptions work exactly. More specific, i get the message Exception 6 occurred and ignored. Can someone please explain what exactly does this mean? I am using qtspim.
Upvotes: 0
Views: 2538
Reputation: 846
Exceptions may be caused by hardware or software. An exception is like an unscheduled function call that jumps to a new address. The program may encounter an error condition such as an undefined instruction. The program then jumps to code in the operating system (OS), which may choose to terminate the program. Other causes of exceptions are division by zero, attempts to read some nonexistent memory, hardware malfunctions, debugger breakpoints, and arithmetic overflow.
The processor records the cause of an exception and the value of the PC
at the time the exception occurs. It then jumps to the exception handler function. The exception handler is code (usually in the OS) that examines the
cause of the exception and responds appropriately, It then returns to the program that
was executing before the exception took place.
In MIPS, the exception handler is always located at 0x80000180
. When an exception occurs, the processor always jumps to this instruction address, regardless of the cause.
The MIPS architecture uses a special-purpose register, called the Cause register, to record the cause of the exception.
MIPS uses another special-purpose register called the Exception
Program Counter (EPC
) to store the value of the PC
at the time an
exception takes place. The processor returns to the address in EPC
after
handling the exception. This is analogous to using $ra
to store the old
value of the PC during a jal
instruction.
Upvotes: 1