Assembly LanguageI Arithmetic Operations 1 Read and Output i
Assembly Language–I (Arithmetic Operations)
1. Read and Output in the command line MARS window.
(a) Read three integers from the command line window
(b) Add the three integers
(c) Print the result in the command line window
Solution
.data
 prompt1: .asciiz \"\ \  Enter the first integer please:\"
 prompt2: .asciiz \"\ \  Enter the second integer please:\"
 prompt3: .asciiz \"\ \  Enter the third integer please:\"
 .text
 main:
 #t0           #to hold first integer
 #t1           #to hold second integer
 #t2           #to hold third integer
 #t3           #to hold sum of t$1 and $2 and $3
 #for first number
li $v0,4       #syscall to print string
    la $a0,prompt1 #addresss of strint to print
 syscall
li $v0, 5        # service 5 reads integer from console
 syscall
 
 mov $t0,$vo       #move the number to read into $t0
#for second number
 li $v0,4       #syscall to print string
    la $a0,prompt2 #addresss of strint to print
 syscall
 
 li $v0, 5        # service 5 reads integer from console
 syscall
 mov $t1,$v0
    add $t2,$t1,$t0   #compute sum of two integers
#for third number:
 li $v0,4       #syscall to print string
    la $a0,prompt3 #addresss of strint to print
 syscall
li $v0, 5       # service 5 reads integer from console
 syscall
 
 li $v0, 5        # service 5 reads integer from console
 syscall
 mov $t3,$v0
 add $t4,$t3,$t2   #compute sum of two integers with third integer
#print out sum of $t4
 li $v0, 4   #load syscall print into $v0
 move $a0,$t4   #load the number to print into $a0
 li, $v0,1
 la, $a0,result
 syscall
Done:
  
 --------------------------------------------------------------------------------------------


