Question: ARM ASSEMBLY LANGUAGE ARM ASSEMBLY LANGUAGE ARM ASSEMBLY LANGUAGE HOMEWORK 8 INTRODUCTION: In Reverse Polish(postfix) notation the operators follow their operands; for instance, to add

ARM ASSEMBLY LANGUAGE

ARM ASSEMBLY LANGUAGE

ARM ASSEMBLY LANGUAGE

HOMEWORK 8

INTRODUCTION: In Reverse Polish(postfix) notation the operators follow their operands; for instance, to add three and four one would write "3 4 +" rather than "3 + 4". If there are multiple operations, the operator is given immediately after its second operand; so the expression written "3 4 + 5" in conventional infix notation would be written "3 4 5 +" in RPN: first subtract 4 from 3, then add 5 to that. An advantage of RPN is that it obviates the need for parentheses that are required by infix. While "3 4 + 5" can also be written "(3 4) + 5", that means something quite different from "3 (4 + 5)", and only the parentheses disambiguate the two meanings. In postfix, the latter would

be written "3 4 5 + ", which unambiguously means "3 (4 5 +) ".

Interpreters of Reverse Polish notation are stack-based; that is, operands are pushed onto a stack, and when an operation is performed, its operands are popped from a stack and its result pushed back on. Stacks, and therefore RPN, have the advantage of being easy to implement and very fast.

Please complete the implementation of the two functions given in the questions section below. Test your functions using the main program given. After you complete the homework rename the file HW8_AssemblyFunctions.S to HW8_yourredID.S and submit only this file on blackboard. Do not include main.c or add contents of main.c to this file.

QUESTION 1: Write a function to convert a given function from infix to postfix in assembly. The basic structure of the function is given in the attached assembly language file.

QUESTION 2: Write a function to convert a given function from postfix to infix in assembly language. The basic structure of the function is given in the attached assembly language file.

File : main.c Purpose : Generic application start */ #include  #include  #include  extern toPostFix(char *, char *); extern toInFix(char *, char *); int main(void) { static char convertedstring2[16]; static char convertedstring1[16],checkstring1[16],checkstring2[15]; static char string1[16]; strcpy(string1,"A*B+(C*D)+E");; static char string2[16]="(A+B)*(C+D)+E"; toPostFix(string1, convertedstring1); // toPostFix(string2, convertedstring2); // toPostFix(convertedstring1, checkstring1); // toPostFix(convertedstring2, checkstring2); printf(" String 1- Infix to Postfix is %s ",convertedstring1); // printf(" String 2- Infix to Postfix is %s ",convertedstring2); // printf(" String 1- Postfix to Infix is %s ",checkstring1); // printf(" String 2- Postfix to Infix is %s ",checkstring2); return EXIT_SUCCESS; } 

 .global toInFix .data // declare any global variables here .text toInFix: mov r12,r13 // save stack pointer into register r12 sub sp,#32 // reserve 32 bytes of space for local variables push {lr} // push link register onto stack -- make sure you pop it out before you return // Your solution here pop {lr} // pop link register from stack mov sp,r12 // restore the stack pointer -- Please note stack pointer should be equal to the // value it had when you entered the function . mov pc,lr // return from the function by copying link register into program counter .global toPostFix .data // declare any global variables here .text toPostFix: mov r12,r13 // save stack pointer into register r12 sub sp,#32 // reserve 32 bytes of space for local variables push {lr} // push link register onto stack -- make sure you pop it out before you return // Your solution here pop {lr} // pop link register from stack mov sp,r12 // restore the stack pointer -- Please note stack pointer should be equal to the // value it had when you entered the function . mov pc,lr // return from the function by copying link register into program counter 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!