COMP 101 Intro. to
Computers & Computing

Winter 2025 Department of Computer Science Kalamazoo College



K Sub-MIPS Simulator

Runs a subset of the real MIPS assembly/machine code.

ToDo:


Assembly Lang Program
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Examples:


Main Memory (Many GB)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

K MIPS-ish Assembly Language Reference

Registers

R0 - R31     See official MIPS names for 32 registers

Arithmetic Instructions

Name Format Example
add add destReg, srcReg1, srcReg2 add R3, R1, R2     (R3 = R1 + R2)
sub sub destReg, srcReg1, srcReg2 sub R3, R1, R2     (R3 = R1 - R2)
addi addi destReg, srcReg, numericValue addi R3, R1, 100     (R3 = R1 + 100)

Logical Instructions

Name Format Example
and and destReg, srcReg1, srcReg2 and R3, R1, R2     (R3 = R1 bit-wise AND R2)
or or destReg, srcReg1, srcReg2 or R3, R1, R2     (R3 = R1 bit-wise OR R2)

Moving and Shifting Instructions

Name Format Example
init (in memory) init numericVal memAddr init 42 M28     (initialize M28 to 42; 42 → M28)
load (from memory) load valReg memAddr load R1, M28     (load value at M28 into R1; R1 ← M28)
store (to memory) store valReg memAddr store R1, M28     (store value in R1 out to M28; R1 → M28)
copy (reg to reg) copy srcReg destReg copy R1, R2     (copy value in R1 to R2)
sll (shift bits left) sll destReg, srcReg1, shiftAmount sll R3, R1, 4     (R3 = R1 shifted left 4 bits)
srl (shift bits right) srl destReg, srcReg1, shiftAmount srl R3, R1, 4     (R3 = R1 shifted right 4 bits)

Branch-Related Instructions

Name Format Example
beq (branch if equal) beq reg1, reg2, label beq R1, R2, EndLoop     (if R1 == R2, go to EndLoop label)
bne (branch if not eq) bne reg1, reg2, label bne R1, R2, EndLoop     (if R1 != R2, go to EndLoop label)
slt (set on less than) slt destReg, reg1, reg2 slt R3, R1, R2     (set R3 to 1 if R1 < R2)
jr (jump to addr in reg) jr targetAddrInReg jr R31     (jump to address in R31)
j (jump to label) j label j StartLoop     (go to instruction labelled StartLoop)

K HALT Instruction: Halts Running K Simulator

Name Format Example
HALT HALT   (or halt) HALT

 

View Assembly ←→ Machine Instruction Mappings (organized by format type)
View Full Register Table


Debugging or "Saved" Output:   

Type or paste your code here: