In: Computer Science
Assembly Language Coding
Using MARS (MIPS)
1)Write a program that prints your name in a Triangle. (NAME = John Doe)
2)Write a Program that intializes X to 10, Y to 20 and Z to -50, adds X and Y and Z and prints the following
the value of each variable, for example value of x is 10
as well as the result of the addition.
Please find the answer below.
Please do comments in case of any issue. Also, don't forget to rate
the question. Thank You So Much.
.data
prompt: .asciiz "*\n*****\n* * * *\n* *\n* John Doe *\n*
*\n******************\n"
.globl main
.text
main:
li $v0,4
la $a0,prompt #it will print prompt
syscall
2)
.data
prompt: .asciiz "\nThe value of x = "
prompt1: .asciiz "\nThe value of y = "
prompt2: .asciiz "\nThe value of z = "
prompt3: .asciiz "\nThe result of addition is : "
.text
li $t0,10 # load x=10
li $t1,20 # load x=10
li $t2,-50 # load x=10
li $v0,4
la $a0,prompt #it will print prompt
syscall
li $v0,1
move $a0,$t0
syscall
li $v0,4
la $a0,prompt1 #it will print prompt
syscall
li $v0,1
move $a0,$t1
syscall
li $v0,4
la $a0,prompt2 #it will print prompt
syscall
li $v0,1
move $a0,$t2
syscall
add $s0,$t0,$t1
add $s0,$s0,$t2
li $v0,4
la $a0,prompt3 #it will print prompt
syscall
li $v0,1
move $a0,$s0
syscall