Machine that has a single register and six instructions

Assignment Help Basic Computer Science
Reference no: EM13313489

Assume a machine that has a single register and six instructions.

LD A Places the operand A into the register
ST A Places the contents of the register into the variable A
AD A Adds the contents of the variable A to the register
SB A Subtracts the contents of the variable A from the register
ML A Multiplies the contents of the register by the variable A
DV A Divides the contents of the register by the variable A

Write a java program utilizing stacks that accepts a postfix expression containing single-letter operands and the operators +, -, *, and / and prints a sequence of instructions to evaluate the expression and leave the result in the register. Use variables of the form TEMPn as temporary variables.

For example, using the postfix expression ABC * + DE - / should print the following to the console:

LD B
ML C
ST TEMP1
LD A
AD TEMP1
ST TEMP2
LD D
SB E
ST TEMP3
LD TEMP2
DV TEMP3
ST TEMP4

Reference no: EM13313489

Questions Cloud

Write a program to ask the user to enter the amount spent : Write a program to ask the user to enter the amount spent on food and Gas for each day of the week. Count and display the number of days the user spent more than 20 dollars per day on food and more than 10 dollars/per day on gas.
How far is the object from the converging lens : A converging lens (f1 = 24.0 cm) is located 56.0 cm to the left of a diverging lens (f2 = -28.0 cm). How far is the object from the converging lens
Review evans and richardson : How specifically does economic of scale serves as a value for global branding? since higher volume doesn't necessarily translate into value for global acceptance of a brand
Find how far from the lens is the object : An object is placed to the left of a lens, and a real image is formed to the right of the lens. How far from the lens is the object
Machine that has a single register and six instructions : Machine that has a single register and six instructions
What is the index of refraction of the unknown liquid : A layer of oil (n = 1.45) floats on an unknown liquid. A ray of light originates in the oil and passes into the unknown liquid. What is the index of refraction of the unknown liquid
What is the difference between syntax and semantics : Explain the distinction between an ambiguity in a proposed algorithm and an ambiguity in the representation of an algorithm.
What is the tension in the cables : A 20 Kg loudspeaker is suspended 2.0 m below the ceilling by two cables that are each 30' from vertical . What is the tension in the cables
Describe the ka of lactic acid hc3h5o3 : The Ka of lactic acid, HC3H5O3, is 1.410?4. (a) Suppose buffer #1 is prepared using 40.0 mL 0.1 M HC3H5O3 and 60.0 mL 0.1 M C3H5O3- to give a final volume of 100.0 mL. What is the pH of this buffer

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Write an expression whose value is a reference newly created

A BufferedReader has a constructor that takes a single InputStreamReader parameter. InputStreamReader has a constructor that takes a single InputStream parameter

  Express e and f in sum-of-minterms algebraic form

Express E and F in sum-of-minterms algebraic form.

  Use the raptor to complete the problem

Use the Raptor to complete the problem, Input names of students from the user, terminated by "ZZZ", 0, 0, 0, and create a data file grades with records of the following form: student (string), test (integer), test 2 (integer), test 3 (integer)

  Discuss difference between microcontroler and microprocessor

Discuss the differences between microcontrollers and microprocessors.

  Find minimum associativity needed of level cache

Determine the minimum associativity needed of the level 1 cache for consistent performance independent of both arrays' position in memory?

  Evaluate the cost of materials

Evaluate the cost of materials

  How many sensors does snort use

Is Snort an HIDS or an NIDS? 2. How many sensors does Snort use? 3. What does a preprocessor do? 4. Is Snort anomaly-based or signature-based?

  Find a regular expression for the language

Find a regular expression for the language over {a,b} that consists of all strings containing exactly one occurrence of substring ab.

  Write a segment of java code that will rotate the elements

Write a segment of Java code that will rotate the elements of an array by one position, moving the initial element to the end, like.

  Which languages give the programmer the freedom to choose

Is allowing the programmer this freedom a good language design strategy or not? Take a position and defend it.

  Display the total and average number of calories burned

Write a condition-controlled while loop that allows the user to enter the calories they burned. Stop looping when the user enters a negative number. Display the Total and Average number of calories burned.

  Write a program that reads a file containing two columns

write a program that reads a file containing two columns of floating-point numbers. prompt the user for the file name. print the average of each column in c++.

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