Assembly Language Programs using QtSpim Project
You are required to turn in the following source file:
assignment4.s
Objectives:
-write assembly language programs to:
-perform decision making using branch instructions.
-use syscall operations to display integers and strings on the console window
-use syscall operations to read integers from the keyboard.Assignment Description:
Write a MIPS assembly language program that checks if a customer is a member or not, and reads in their purchased amount, and gives discounts accordingly.
If a customer is a member and their purchased amount is less than or equal to 9000, then the customer gets 10% discount, i.e., their payment will be their purchased amount * (0.9). If a customer is a member and their purchased amount is greater than 9000, then the customer gets 10% discount and also a discount of 200, i.e., their payment will be their purchased amount * (0.9) – 200. If a customer is not a member, there is no discount.
Name your source code file Assignment4.s.
The following shows how it looks like in a C program:
int membership;
int purchasedAmount;
int payment =0;printf(“Are you a store member? Enter 1 for a member, 0 for a non-member\n”);
//read an integer from a user input and store it in membership
scanf(“%d”, &membership);if (membership !=0 && membership != 1)
{
printf(“Invalid Answer.”);
}
else
{
printf(“Enter your purchase amount in cents:\n”);//read an integer from a user input and store it in purchasedAmount
scanf(“%d”, &purchasedAmount);if (membership == 1 && purchasedAmount <= 9000)
{
payment = purchasedAmount – purchasedAmount/10;
}
else if (membership == 1 && purchasedAmount > 9000)
{
payment = purchasedAmount – purchasedAmount/10 – 200;
}
else if (membership == 0)
{
payment = purchasedAmount;
}//print out the payment
printf(“Your total payment is %d \n”, payment);} //end of else
Here is a sample output (user input is in bold):
Are you a store member? Enter 1 for a member, 0 for a non-member
1
Enter your purchase amount in cents:
30000
Your total payment is 26800
———————————————–
Here is another sample output (user input is in bold):
———————————————–
Are you a store member? Enter 1 for a member, 0 for a non-member
0
Enter your purchase amount in cents:
50010
Your total payment is 50010
———————————————–
Here is another sample output (user input is in bold):
———————————————–
Are you a store member? Enter 1 for a member, 0 for a non-member
1
Enter your purchase amount in cents:
9000
Your total payment is 8100
———————————————–
Here is another sample output (user input is in bold):
———————————————–
Are you a store member? Enter 1 for a member, 0 for a non-member