1. Exception Interrupts and Stack
A MIPS program for Final Project
11712805 HUANG Chaoxing
11811112 PANG Ziyue
2. 2022/4/6 2
Stack
Last In First Out (LIFO) list
A memory unit with an address register
Organized as a collection of a finite number of
memory words or registers.
Initially, SP is cleared to 0, EMTY is set to 1, and
FULL is cleared to 0
The top item is read from the stack into DR .
3. 2022/4/6 3
Example Code
SP ← SP + 1 Increment stack pointer
M[SP] ← DR Write item on top of the stack
If (SP = 0) then (FULL ←1) Check if stack is full
EMTY ← 0 Mark the stack not empty
DR ← M[SP] Read item from the top of stack
SP ← SP - 1 Decrement stack pointer
If (SP = 0) then (EMTY ← 1) Check if stack is empty
FULL ← 0 Mark the stack not full
4. 2022/4/6 4
Exceptions and interrupts
There are four similar things in MIPS32:
They all offer a mechanism to jump from user code space to kernel
space, in order to access the hardware or recover from error.
Exceptions Interrupt
Trap Syscall
6. 2022/4/6 6
Interrupt
"Interrupt because of external trigger"
Include keyboard input, monitor refresh, timer counter etc.
Normally due to the physical events, trigger by hardware.
7. 2022/4/6 7
Trap
"Interrupt because of programmer wanted to "
Trigger by instructions, teq(trap if equal ), tlt (trap if less than), etc.
Normally use for debugging in programming, or setup some event for
kernel.
8. 2022/4/6 8
Syscall
"Interrupt because of using service from operation
system
Trigger by instruction syscall.
Use for using service from operation system, io etc.