Skip to content

Instantly share code, notes, and snippets.

@arathunku
Created May 10, 2013 09:18
Show Gist options
  • Save arathunku/5553398 to your computer and use it in GitHub Desktop.
Save arathunku/5553398 to your computer and use it in GitHub Desktop.
Adding and substracting in misp
.text # code section
main:
li $v0, 4
la $a0, a
syscall
li $v0, 5
syscall
move $t0, $v0 #load value a to $t0
li $v0, 4
la $a0, b
syscall
li $v0, 5
syscall
move $t1, $v0 #load value a to $t1
li $v0, 4
la $a0, c
syscall
li $v0, 5
syscall
move $t2, $v0 #load value a to $t2
li $v0, 4
la $a0, d
syscall
li $v0, 5
syscall
move $t3, $v0 #load value a to $t3
add $t4, $t0, $t1 # $t4 = a + b
sub $t5, $t2, $t3 # $t5 = c-d
sub $t6, $t4, $t5 # $t6 = $t4-$t5
li $v0, 1 #syscall to print int
move $a0, $t6 #value to print
syscall
li $v0, 10 #exit
syscall
.data
a: .asciiz "Give a:"
b: .asciiz "Give b:"
c: .asciiz "Give c:"
d: .asciiz "Give d:"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment