MIPS Exceptions

Introduction In the MIPS architecture, an exception is a general label for interrupts and errors that require the processor to temporarily abandon sequential execution. An interrupt is an asynchronous request from an external device (e.g., timer, network), while a trap is a synchronous request from software (e.g., a system call). Errors detected inside the CPU (e.g., illegal instructions, misaligned accesses) are also treated as exceptions. When an exception occurs, the CPU saves the current program counter (PC) and status in dedicated registers, enters kernel mode, and jumps to an exception handler. ...

2025-10-17 · 5 min · 1033 words · ssdxx

Language and Performance

1. Introduction Is C always faster than other programming languages? Well, the performance of a program is ultimately determined by the machine instructions the CPU executes and how efficiently they use the underlying hardware. A high-level programming language is an abstraction, and the way it’s translated down to the processor’s Instruction Set Architecture (ISA), like MIPS or ARM64, is the primary factor behind its performance. Direct Compilation (C): A language like C is a relatively “thin” abstraction over the hardware. The C compiler’s job is to translate the code directly into a sequence of machine instructions for a specific ISA. A C statement like is_prime[j] = 0; can be compiled into a very small number of assembly instructions, similar to a sw (store word) instruction in MIPS that writes a value to a calculated memory address. This direct translation allows for maximum speed because there is no intermediary at runtime. ...

2025-10-17 · 4 min · 841 words · ssdxx

Logisim

Useful Component in Logisim for the Simulation I/O To input or get the output from the circuit, we need to have I/O, and Logisim provides a component called Pin. It has some properties, for example, the Output? property will change the pin between the input mod and the output mod, and the Data Bits property can give us an easy way to input/output multiple bits. But since one wire can only contain one bit 1/0, when we want to get multiple bits from a pin, we need another component called Splitter. Similar to pin, the splitter also has properties to control the behavior. ...

2025-10-17 · 4 min · 798 words · ssdxx

MIPS Assembly and Simulator

The Complete Assembly Code Structure The first thing I’ve noticed about the assembly code file is the structure. Based on the comments, there are two parts of code segment and data segment. Code segment: .text .align # align number (not necessary) .globl [func name] (not necessary) [func name]: # something Data segment: .data [declaration of the data schema] name: type value Pseudoinstructions about Load Data Besides the lw instruction that we’ve learned in class, the simple assembly code uses li and la. After searching, I learned that these are some pseudoinstructions for loading. ...

2025-10-17 · 3 min · 524 words · ssdxx