Can anybody fix me the following program in MIPS assembly th
Can anybody fix me the following program in MIPS assembly that takes a constant infix string, converts it in postfix and then finds the result of the converted function?? ########################################################################### .data iMax: .word 40 postfix : .asciiz \"(1 + 5) * (8 - (4 -1))\" msg: .asciiz \"The Polish notation result is : \"\" .text .globl main main: la $t0, postfix #address of string input lw $t0, iMax sub $sp , $sp , $t0 #space for 40 words in stack move $s0, $sp lw $t0, iMax li $t2,0 li $t3,0 lb $t1,$s0($t2) #load Bit of $t0 in $t1 LoopA: beq $t1, 0, Null #if bit == NULL beq $t1, 40, LeftParenthesis #if bit == ( beq $t1, 41, RightParenthesis #if bit == ) beq $t1, 43, plus #if bit == + beq $t1, 42, mul #if bit == * beq $t1 ,45, sub #if bit == - beq $t1, 47, div #if bit == / j LoopA Null: j print LeftParenthesis: sw $t1, $t2($s0) #save to stack addi $t1, $t1, 1 #next character addi $t2, $t2, 4 #sync with stack pointer j LoopA rp: addi $t1,$t1,-1 #remove left parenthesis \'(\'/\')\' j LoopA RightParenthesis: beq $t1, 40, rp addi $t1, $t1, -1 #remove right parenthesis \'(\'/\')\' la $a0, $t1 #print the number or symbol li $v0, 4 syscall addi $t1, $t1, -1 #Go to previous bit j RightParenthesis plus: lw $s0, $t2($s0) addi $t2, $t2, 4 lw $s1, $t2($s0) addi $t2, $t2, 4 add $s2, $s1, $s0 sw $s2, $t2($s0) addi $t1,$t1,1 #Go to next char j LoopA sub: lw $s0, $t2($s0) addi $t2, $t2, 4 lw $s1, $t2($s0) addi $t2, $t2, 4 sub $s2, $s1, $s0 sw $s2, $t2($sp) addi $t1, $t1, 1 #Go to next char j LoopA mul: lw $s0, $t2($s0) addi $t2, $t2, 4 lw $s1, $t2($s0) addi $t2, $t2, 4 mult $s1, $s0 mflo $s2 sw $s2, $t2($s0) addi $t1, $t1, 1 #Go to next char j LoopA div: lw $s0, $t2($s0) addi $t2, $t2, 4 lw $s1, $t2($s0) addi $t2, $t2, 4 div $s1, $s0 mflo $s2 sw $s2, $t2($s0) addi $t1, $t1, 1 #Go to next char j LoopA print: move $a0,0($s0) #move the result to the first position li $v0,4 syscall li $v0, 10 syscall #exit the system
Solution
Please find the code for infix to postfix conversion in assembly language . This will work for any inputs .
.globl _toPostfix
removeone:
movl 4(%esp),%edx /* edx is temporary storage because we cannot copy from one memory address to another */
movl 4(%esp),%edx
movl %edx,(%eax,%edi,1)
jmp miniloop
decrements:
popl %ebp
100 ret
| 002 | _toPostfix: | 

