This is a RISC instruction set for MIPS processors.

Online Assembler

https://1whatleytay.github.io/saturn

Boilerplate

.data
    # TODO: What are the following 5 lines doing?
    promptA: .asciiz "Enter an int A: "
    promptB: .asciiz "Enter an int B: "
    promptC: .asciiz "Enter an int C: "
    resultAdd: .asciiz "A + B = "
    resultSub: .asciiz "A - B = "
    newline: .asciiz "\n"
.globl main
.text
    main:
    # Syscall 4, printing the value of promptA to the screen
    li $v0, 4
    la $a0, promptA
    syscall
    # Read an integer into $t0
    li $v0, 5
    syscall
    move $t0, $v0
    # Print promptB
    li $v0, 4
    la $a0, promptB
    syscall
    # Get number and store into $t1
    li $v0, 5
    syscall
    
    move $t1, $v0
    # Store the sum of t1 and t0 into t3
    add $t2, $t1, $t0
    # store the subtraction of t0 from t1 into t3
    sub $t3, $t0, $t1
    # print the add string
    li $v0, 4
    la $a0, resultAdd
    syscall
    # print the value of the add
    li $v0, 1
    move $a0, $t2
    syscall
    # print new line
    li $v0, 4
    la $a0, newline
    syscall
    # print the subtract string
    li $v0, 4
    la $a0, resultSub
    syscall
    # print the subtracted value
    move $a0, $t3
    li $v0, 1
    syscall
    # print newline
    li $v0, 4
    la $a0, newline
    syscall
    # end syscall
    li $v0, 10
    syscall

Instructions

Arithmetic Instructions

Logical Instructions

Shift Instructions

Data Movement Instructions

Load Upper Immediate

Loads the Immediate into the upper half of the register

Arithmetic and Logical Pseudo Instructions

Labels

Section Labels

Denoted with labelname:

Variable Labels

Denoted as: label .type values(s)

Branches

Branch PseudoInstructions

Using slt and branch pseudo instructions

Jumps

Comparison Instructions

  • slt : ā€˜set less than’
  • Stores one if the comparison is true, stores zero otherwise.

RAM Interactions

These instructions are all I-Type

  • You are accessing addresses by offsets i
  • b for byte
  • h for half-Word
  • w for Word
  • l for load
  • s for store
Load and Move Pseudo-Instructions

  • la : Load address
  • li : Load immediate