Skip to content

Instantly share code, notes, and snippets.

@kipanshi
Created April 24, 2012 15:57
Show Gist options
  • Save kipanshi/2480979 to your computer and use it in GitHub Desktop.
Save kipanshi/2480979 to your computer and use it in GitHub Desktop.
My fist MIPS Assembly programm
# 1.s
#
# My first MIPS Assembly program
# This program let you input 2 numbers and output the result of addition
.data
prompt_msg: .asciiz "Enter two numbers to add:\n"
result_msg: .asciiz "Result: "
end_of_line: .asciiz "\n"
.text
main:
la $a0, prompt_msg # load the addr of ``prompt_msg`` to $a0
li $v0, 4 # print_string syscall
syscall
li $v0, 5 # read fist number
syscall
move $t0, $v0 # store in $t0
li $v0, 5 # read fist number
syscall
move $t1, $v0 # store in $t1
add $t2, $t0, $t1
la $a0, result_msg # load the addr of ``result_msg`` to $a0
li $v0, 4 # print_string syscall
syscall
move $a0, $t2 # move the number to print into $a0
li $v0, 1 # load syscall print_int into $v0
syscall
la $a0, end_of_line # print end of line
li $v0, 4
syscall
li $v0, 10 # exit
syscall
# End of 1.s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment