Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .globl main
- .text
- main:
- li $v0, 4 #output the string
- la $a0, first_int
- syscall
- li $v0, 5 #read in the number
- syscall
- move $t0, $v0 #store first integer in t0
- li $v0, 4 #output the string
- la $a0, second_int
- syscall
- li $v0, 5 #read in the number
- syscall
- move $t1, $v0 #store first integer in t1
- add $t2, $t0, $t1 #add t0 and t1 and store it in t2
- li $v0, 4 #output the string
- la $a0, result
- syscall
- move $a0, $t2 #put the integer into a0
- li $v0, 1 #output the integer
- syscall
- li $v0, 10 #end the program
- syscall
- .data
- first_int:
- .asciiz "Please enter your first integer: "
- second_int:
- .asciiz "Please enter your second integer: "
- result:
- .asciiz "The sum of your integers is: "
- --------------------------------------------------------------------------------------------------------------
- .globl main
- .text
- main:
- li $v0, 4 #output the string
- la $a0, first_int #m
- syscall
- li $v0, 5 #read in the number
- syscall
- move $t0, $v0 #store first integer in t0, M
- li $v0, 4 #output the string
- la $a0, second_int #n
- syscall
- li $v0, 5 #read in the number
- syscall
- move $t1, $v0 #store second integer in t1, N
- add $s0, $t0, $t0 #add n+m
- sub $s1, $t0, $t1 #subtract m-n
- add $s2, $t0, 3 #subtract m+3
- sub $s3, $t1, 4 #add n-4
- mul $s4, $t0, $t1 #multiply mn
- div $s5, $t1, $t0 #divide n by m and get quotient
- rem $s6, $t1, $t0 #divide n by m and get the remainder
- #print out the line, then store the integer from the 's' registers to a0,
- #then print integer, then repeat
- li $v0, 4 #iteration 1
- la $a0, newline
- syscall
- move $a0, $s0
- li $v0, 1
- syscall
- li $v0, 4 #iteration 2
- la $a0, newline
- syscall
- move $a0, $s1
- li $v0, 1
- syscall
- li $v0, 4 #iteration 3
- la $a0, newline
- syscall
- move $a0, $s2
- li $v0, 1
- syscall
- li $v0, 4 #iteration 4
- la $a0, newline
- syscall
- move $a0, $s3
- li $v0, 1
- syscall
- li $v0, 4 #iteration 4
- la $a0, newline
- syscall
- move $a0, $s4
- li $v0, 1
- syscall
- li $v0, 4 #iteration 4
- la $a0, newline
- syscall
- move $a0, $s5
- li $v0, 1
- syscall
- li $v0, 4 #iteration 4
- la $a0, newline
- syscall
- move $a0, $s6
- li $v0, 1
- syscall
- li $v0, 10 #end the program
- syscall
- .data
- first_int:
- .asciiz "Please enter your first integer: "
- second_int:
- .asciiz "Please enter your second integer: "
- result:
- .asciiz "The sum of your integers is: "
- newline:
- .asciiz "\n"
Advertisement
Add Comment
Please, Sign In to add comment