A lc3 program capable of evaluating postfix expression

Assignment Help Basic Computer Science
Reference no: EM13667056

Overview
Your task over MP2 and MP3 is to create a LC3 program capable of evaluating postfix expressions (a.k.a reverse polish notation) using a stack. A postfix expression is a sequence of numbers ('1','5', etc.) and operators ('+', 'x', '-', etc.) where every operator comes after its pair of operands. For example "3 + 2" would be represented as "3 2 + ­" in postfix. The expression "(3 - 4) + 5" with 2 operators would be "3 4 - 5 +" in postfix. Notice that a nice feature of postfix is that the parentheses are not necessary. This makes the expressions more compact.
This week you will work on developing code to handle the input typed in by the user at the keyboard. In MP3 you will develop the subroutines for evaluating the expressions.
This is not a collaborative MP.
Details
Your program should read in the input from the keyboard and echo it to the screen. Operators, operands will be separated by a space (x20) in the input. Operands will always be 0-9 and the input will not have any invalid characters. Stop reading the input once you encounter a new line character (xA).
While you are reading the input, you have to store it starting at x5000. Before storing the operands in memory, you must first convert them from their ASCII values to their numerical values. Operators should only have the negation of their ASCII values stored in memory (you are doing this because this way you cannot confuse between operator and operand values. Write the code for this conversion in the DECODE subroutine. For those of you doing the challenge the operand can take any two or three digit values and they could be the same as one of the operator ascii values.). For example the ASCII value of '+' is x2B, so store xFFD5. To mark the end of the entered expression store the negative of the newline character (xFFF6) in the last memory location. Depending on the system you use, the "enter" key could either be mapped to the "line feed (xA)" or "carriage return (xD)" ASCII values. For both just store the negation (2's complement) of the value. So xFFF3 is also valid at the last memory location.
So, for the the input "3 4 - 5 +", the memory at x5000 will look like this-
Address
Data
x5000 x0003
x5001 x0004
x5002 xFFD3
x5003 x0005
x5004
xFFD5
x5005 xFFF6

Reference no: EM13667056

Questions Cloud

Find the angle through which the lower leg moves : For part of the performance of a football kick a punter's ankle is moving at a linear velocity of 279.23 cm/s relative to the knee. find the angle through which the lower leg moves
Evaluate the angular acceleration in the second training : In a large centrifuge used for training astronauts and pilots, a small chamber is fixed at the end of a rigid arm that rotates in a horizontal circle. Evaluate the angular acceleration in the second training exercise
Evaluate the unknown wavelength : Two parallel slits are illuminated by light composed of two wavelengths, one of which is 645 nanometer. Evaluate what is the unknown wavelength
Compute the initial speed of the second arrow : Two arrows are shot vertically upward. The second arrow is shot after the first one, but while the first is still on its way up. Compute the initial speed of the second arrow
A lc3 program capable of evaluating postfix expression : Create a LC3 program capable of evaluating postfix expressions
Find the earth linear velocity and angular velocity : The mean distance between the Earth and Sun is 149.6 x 10^6 kilometer. Find the earth linear velocity and angular velocity as it rotates around the sun
Find what is the angular acceleration : A 26.0 in diameter wheel is rotating initially at 33.3 revolutions per second. The wheel slows down uniformly and comes to rest in 12 s. Find what is the angular acceleration
Evaluate how high does the ball go : A vertical spring with a force constant of 300 N/m is compressed 6.0 centimeter and a 0.25 kilogram ball located on top. Evaluate how high does the ball go
Calculate the percentage of the initial kinetic energy : A 5.00 gram object moving to the right at+20.0 cm/s makes an elastic head-on collision with a 10.0 gram object that is initially at rest, Calculate the percentage of the initial kinetic energy transferred to the 10.0 g object

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Program that accepts 10 integers and determines and prints

write a program that accepts 10 integers and determines and prints the smallest and largest integer input by the user. Your program should use at least the following four variable

  The head office of kkae

The head office of KKAE is located in Australia/Sing/India. Documents and reports must be displayed/printed in English. Grammar and spelling in all the documents and output reports follow the English version. For example, some of the foreign salutati..

  How many tails and heads you get

Simulate tossing a coin 10,000 times and record how many tails and heads you get. Make two runs as with the dice. Again accumulate the number of heads and tails in an array. Your for loops would go from 0 to 1.

  How far could it transmit a signal

A step-index multimode fiber has a modal dispersion of about 30 ns/km. Using the formula for maximum data rate for a given dispersion, about how far could it transmit a signal at 1Gbit/s?

  Write program reads in the length and width of a rectangular

Write a program that reads in the length and width of a rectangular yard (in meters) and the length and width of a rectangular house (in meters) placed in the yard. Your program should compute the time (in minutes) required to cut the lawn around ..

  How many memory banks are needed

How many memory banks are needed so that a stream of loads can, on average, require only one cycle per load?

  Explain functionality of multiprogrammed system in user mode

In multiprogrammed system, must this functionality be available in user mode or only accessible by system call? Why or why not?

  Project charter and project management plan

Project Charter and Project Management Plan

  Explain the characteristics of value-type variables

Briefly explain the characteristics of value-type variables that are supported in the C# programming language.

  What do the terms "syntactic sugar" and "syntactic salt"

What do the terms "syntactic sugar" and "syntactic salt" mean? From your knowledge of the C# programming language, list at least five syntactic sugar and salt features.

  Suppose fred sees your rsa signature on m1 and m2

Suppose Fred sees your RSA signature on m1 and m2

  Use eulers method

Use Euler's Method with (a) h=.5, (b) h=.25, and (c) h=.05 to solve dy/dx=yx^3-2.3y over the interval from x=0 to 2, where y(0)=1.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd