# This program should help you in your second project. It reads the input # expression, remove blanks, add ( at the beginning and ) at the end and put # the resulting expression at "Array". .data v: .asciiz " ()0123456789*+-" exp: .space 128 # reserve memory locations for data Array: .space 128 .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 $t0, exp la $t1, Array la $t2, v lb $t2, 1($t2) # load a ( into $t2 sb $t2, 0($t1) # put ( at the start of the Array addi $t1, $t1, 1 la $t2, v lb $t2, 0($t2) # load a blank into $t2 ll: lb $t3, 0($t0) # copy exp into Array discarding blanks bne $t2, $t3, jp # if not blank go to jp addi $t0, $t0, 1 j ll jp : sb $t3, 0($t1) addi $t1, $t1, 1 addi $t0, $t0, 1 bne $t3, $zero, ll # if not (end of string) go to ll la $t2, v lb $t2, 2($t2) # load a ) into $t2 sb $t2, -2($t1) # insert ) before the and the in Array sb $zero, -1($t1) # put a null after ) in Array to make it possible # to print Array as a string. # you should insert your call to Eval here la $a0, exp li $v0, 4 syscall # print the string in exp la $a0, Array li $v0, 4 syscall # print the string in Array li $2, 10 # prepare to exit with syscall 10 syscall # make call # end of program