Skip to content

Instantly share code, notes, and snippets.

@bhavik-knight
Last active April 10, 2021 05:00
Show Gist options
  • Save bhavik-knight/49ab556a0445be899f075a1127a93c9a to your computer and use it in GitHub Desktop.
Save bhavik-knight/49ab556a0445be899f075a1127a93c9a to your computer and use it in GitHub Desktop.
#################################################
# Name: Bhavik Bhagat #
# Email: x2020coq@stfx.ca #
# Student ID: 202002911 #
# Assignment2: crosscheck 2.16.4 #
#################################################
.data
endl: .asciiz "\n"
.text
.globl main
main:
# Evaluate the expression.
# Put the final result in a2 to prepare for the syscall.
# li $t0, 1052672 # Put 0x0010 1000 in a register (Part A)
li $t0, 2147487744 # Put 0x8000 1000 in a register (Part B)
slt $t2, $0, $t0 # ($0 < $t0) ? 1 : 0
bne $t2, $0, else # if $t2!= 0 then else
j done
else:
addi $t2, $t2, 2 # $t2 += 2
done:
move $a0, $t2 # move value of $t2 in $a0 to print
# Print the integer result in a0
li $v0, 1 # Load the system call number
syscall
# Print endl.
la $a0, endl # Load the address of the string
li $v0, 4 # Load the system call number
syscall
# Return.
li $v0, 0 # Load return value in v0.
jr $ra # Return.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment