Created
April 24, 2012 15:57
-
-
Save kipanshi/2480979 to your computer and use it in GitHub Desktop.
My fist MIPS Assembly programm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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