CS0447 Project 3 Due March 29th midnight PROJECT: Write a program in MIPS ssembly language that behaves as follows: Repeatedly ask the user for input. The input can be a positive or negative decimal integer, or +,*,or p. While the user types in numbers, they should be put into a queue. When the user enters +, your program should list all the numbers in the queue and their sum (as shown below), and then set the queue to have just the sum in it. Similarly, if the user enters *, it should list all the numbers and their product, and set the queue to have just the product. When the user enters p, your program should output the first number in the queue in decimal, binary, and hexadecimal formats, and then exit. Your program should behave correctly when the user types +,*, or p when there are zero, one, ore more integers in the queue. Note that the sum of no numbers is zero, and the product of no numbers is 1. You don't have to worry about overflow. That is, if the answer is too big to fit into 32 bits, it's ok if your program doesn't work correctly. You can also assume that all numbers will be at most 10 digits. You can implement the queue with an array that you declare yourself. Thinking about the basic ideas used with the program stack (pushing, popping, etc.) may help you to think about how to implement the queue. You may assume that at most 16 numbers will ever be in the queue at a time, but if the user tries to enter more, you should give an error message, and keep the previous contents of the queue. WHAT TO SUBMIT: You will submit one file with the extension .s (an assembly language program). Copy a file called yourfirstname_yourlastname.s to /afs/cs.pitt.edu/usr0/moir/public/447/submission_3 SAMPLE RUN: Input: 12 Input: 15 Input: -10 Input: + 12+15-10=17 Input: 3 Input: * 17*3=51 Input: 8 Input: + 51+8=59 Input: p Base Output ------------- 10 59 2 0000 0000 0000 0000 0000 0000 0011 1011 16 0x0000003b HELP: To help you get started, here is a piece of code that reads in an expression from the user and stores it to an array. The example checks through the expression and prints out 'yes' if it contains a '+' and 'no' otherwise. Your program doesn't have to do anything like that - this is just an example you can use to figure out how to access individual characters in the string, etc. # This piece of code accepts a string of input, prints it out, and says "yes" # if the string contains a "+" and "no" otherwise .data v: .asciiz " ()0123456789*+-" # string of ascii chracters we will use exp: .space 128 # memory to store input string no: .asciiz "no" yes: .asciiz "yes" .text .globl main main: li $v0, 8 li $a1, 127 #maximum size for input expression la $a0, exp syscall #read input expression into exp la $a0, exp #print the string in exp li $v0, 4 syscall # This part is an example on how to access a character in a string # It merely checks for a "+" in an expression if there is one prints "yes" # otherwise prints a "no". la $t0, exp #prepare to access characters in exp la $t1, v #prepare to access a character in v lb $t3, 14($t1) #load "+" ascii into a register li $t4, 0xa #load end-of-line into $t4 loop2: lb $t2, 0($t0) #load next array element beq $t2, $t3, hi #if it's a "+", go to print yes addi $t0, $t0, 1 #increment loop counter bne $t2, $t4, loop2 #check for null (end of string), #continue if not found li $v0, 4 #print no la $a0, no syscall j exit hi: li $v0, 4 #print yes la $a0, yes syscall exit: li $2, 10 #exit program syscall