Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ASSEMBLY Work Task Part 1 Now, load the stack using a loop with the values shown below. After the stack is loaded, use index mode

ASSEMBLY

Work Task

Part 1

Now, load the stack using a loop with the values shown below. After the stack is loaded, use index mode (indexing using the SP register) to load R10 with 0x0000.0044 and R11 with 0x0000.0077.

32-bits

Stack Pointer

0x0000.0011

0x0000.0022

0x0000.0033

0x0000.0044

0x0000.0055

0x0000.0066

0x0000.0077

0x0000.0088

Figure 1: Stack and its contents.

Part 2

Code the simple postfix notation calculator that performs the operation shown in Figure 2. This calculator will only perform one operation (512+4*+3-). The infix expression of the operation to be performed is 5 + ((1 + 2) x 4) 3. Dont worry about saving the operators on the stack. Always push values on the stack. However, when you reach an operator, pop the values off the stack into registers, perform the arithmetic operation, and push the result back on the stack according to Figure 2. Your final result should be 14 (0x0000.000E) and should be on the top of the stack.

Input

Operation

Stack

Comment

5

Push Value

5

1

Push Value

1

5

2

Push Value

2

1

5

+

Add

3

5

Pop two value (1, 2) and push result (3)

4

Push Value

4

3

5

x

Multiply

12

5

Pop two value (3, 4) and push result (12)

+

Add

17

Pop two value (5, 12) and push result (17)

3

Push Value

3

17

-

Subtract

14

Pop two value (17, 3) and push result (14)

Result

(14)

Figure 2: Postfix notation operations.

Part 3

Now take the postfix notation calculator a step further. Using loops, branches, and the stack create a postfix notation calculator that performs the operations specified in RPN_IN. Add the variables, pointers, and the constant below to the appropriate sections of your code. Use these variables to implement your calculator. The constant OPER contains the ASCII representation of the operators (addition, subtraction, multiplication, and division) in HEX. Use this constant in the loop to determine what operation to perform. RPN_IN is the variable with the operation to perform and data. The values in RPN_IN below are initially 63/4*2+, and the result should be 10. However, I should be able to change RPN_IN only, and your code should still work.

.data

RPN_IN .byte 0x06,0x03,0x2F,0x04,0x2A,0x02,0x2B ; 63/4*2+=10

RPN_OUT .byte 0 ; Output

.text

RPN_START .word RPN_IN ; Pointer to start of RPN array

RPN_END .word RPN_OUT-1 ; Pointer to end of RPN array

OPER .byte 0x2A,0x2B,0x2D,0x2F ;*,+,-,/

OPER_PTR .word OPER ; Pointer to operator

You will traverse the RPN_IN array in a similar fashion to Lab 3. You will jump out of the array when an operator is found, pull two values off the stack, perform that particular operation, push the result onto the stack, and then return to the loop. Otherwise, you will just push the value on the stack.

Notes

Use signed instructions (i.e., assume the data is signed). Use word, half word, and byte instructions when appropriate. I will deduct points if the wrong instruction type is used. You must use the variables, constants, and pointers above only. Dont add any variables, constants, or pointers. Points will be deducted if you do so.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essential SQLAlchemy Mapping Python To Databases

Authors: Myers, Jason Myers

2nd Edition

1491916567, 9781491916568

More Books

Students also viewed these Databases questions

Question

Discuss cross-cultural differences in perception

Answered: 1 week ago