Accembly lanqage Progren cx36 cx 86) nauage ProgroM naed het Airite on assenbl l
ID: 3601549 • Letter: A
Question
Accembly lanqage Progren cx36 cx 86) nauage ProgroM naed het Airite on assenbl lanuage pacgram Yat asd to entrer on intgdla amout btwan and 5000 Your program should display the corresponding class dectiptian using tro louwi hlrite die proqrom o dnat it exeutes util the use pus sone volue that you determine to be sentnel vale Your progrom must quard again and provide user messaqes inpu values vat ne outside dhe valid onge Donation Amount (dollars) _classo nation - Platmum 3000.tv 43.3gg $2000 to 2, 999 sold Silver bronze Co to $999Explanation / Answer
.data
input: .asciiz " Please input number between 1 to 5000 and 0 to exit "
warning: .asciiz " Please input valid number between 1 to 5000 "
print_copper: .asciiz " Copper "
print_bronze: .asciiz " Bronze "
print_silver: .asciiz " Silver "
print_gold: .asciiz " Gold "
print_platinum: .asciiz " Platinum "
.text ## Assembly language instructions go in text segment
main: ## Start of code section
li $v0, 4 # system call code for printing string = 4
la $a0, input # load address of string asking to input x
syscall # call operating system to perform operation
li $v0, 5 # system call code for input interger = 5
syscall # call operating system to perform operation
add $t1, $v0, $zero #Copy the value of input integer stored in register $v0 to register $t1 holding x, $zero is register containing zero
beq $t1,$zero,end #if user input zero then end the program
bltz $t1, warn #if $t1 is less than zero, then jump to label warn
subi $t2,$t1,5000 #register $t2 will containing positive value if amount exceeds 5000.
bgtz $t2, warn #if amount exceeds 5000, then it will jump to warn label
subi $t2,$t1,999 #register $t2 will containing <=0 if amount is <= 999
blez $t2, copper #if $t2 contain <=0 then brach to label copper to print Copper
subi $t2,$t1,1999 #register $t2 will containing <=0 if amount is <=1999
blez $t2, bronze #if $t2 contain <=0 then brach to label bronze to print Bronze
subi $t2,$t1,2999 #register $t2 will containing <=0 if amount is <=2999
blez $t2, silver #if $t2 contain <=0 then brach to label silver to print Silver
subi $t2,$t1,3999 #register $t2 will containing <=0 if amount is <=3999
blez $t2, gold #if $t2 contain <=0 then brach to label silver to print Gold
bgtz $t2, platinum #if $t2 contain >0 then brach to label platinum to print Platinum
j main #jump to label main to repeat the procedure
copper: li $v0, 4 # system call code for printing string = 4
la $a0, print_copper # load address of string printing copper
syscall # call operating system to perform operation
bronze: li $v0, 4 # system call code for printing string = 4
la $a0, print_bronze # load address of string printing Bronze
syscall # call operating system to perform operation
silver: li $v0, 4 # system call code for printing string = 4
la $a0, print_silver # load address of string printing Silver
syscall # call operating system to perform operation
gold: li $v0, 4 # system call code for printing string = 4
la $a0, print_gold # load address of string printing Gold
syscall # call operating system to perform operation
platinum: li $v0, 4 # system call code for printing string = 4
la $a0, print_platinum # load address of string printing Platinum
syscall # call operating system to perform operation
warn: li $v0, 4 # system call code for printing string = 4
la $a0, warning # load address of string warning asking to enter valid input
syscall # call operating system to perform operation
end: li $v0, 10 # system call code for exit = 10
syscall # call operating system to perform operation