Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

tion 0 0 . As we've indicated, the switch reading the value and storing it in memory location memory [ operand ] . The value

tion 00. As we've indicated, the switch reading the value and storing it in memory location memory [operand]. The value is then
read into location 09.
At this point, simulation of the first instruction is completed. All that remains is to prepare
the Simpletron to execute the next instruction. Since the instruction just performed was not a
transfer of control, we need merely increment the instruction-counter register as follows:
instructionCounter++;
This action completes the simulated execution of the first instruction. The entire process (i.e., the
instruction-execution cycle) begins anew with the fetch of the next instruction to execute.
Now let's consider how the branching instructions - the transfers of control-are simulated.
All we need to do is adjust the value in the instruction counter appropriately. Therefore, the
unconditional branch instruction (40) is simulated within the switch as
instructionCounter = operand;
The conditional "branch if accumulator is zero" instruction is simulated as
if (accumulator ==0){
instructionCounter = operand;
}
At this point, you should implement your Simpletron simulator and run each of the SML
programs you wrote in Exercise 7.36. If you desire, you may embellish SML with additional fea-
tures and provide for these features in your simulator.
Your simulator should check for various types of errors. During the program-loading phase,
for example, each number the user types into the Simpletron's memory must be in the range -9999
to +9999. Your simulator should test that each number entered is in this range and, if not, keep
prompting the user to re-enter the number until the user enters a correct number.
During the execution phase, your simulator should check for various serious errors, such as
attempts to divide by zero, attempts to execute invalid operation codes, and accumulator overflows
(i.e., arithmetic operations resulting in values larger than +9999 or smaller than -9999). Such seri-
ous errors are called fatal errors. When a fatal error is detected, your simulator should display an
error message, such as
****** Attempt to divide by zero ******
*** Simpletron execution abnormally terminated ******
and should display a full computer dump in the format we discussed previously. This treatment
will help the user locate the error in the program.
7.38(Simpletron Simulator Modifications) In Exercise 7.37, you wrote a software simulation of
a computer that executes programs written in Simpletron Machine Language (SML). In this exer-
cise, we propose several modifications and enhancements to the Simpletron Simulator. In the exer-
cises of Chapter 21, we propose building a compiler that converts programs written in a high-level
programming language (a variation of Basic) to Simpletron Machine Language. Some of the follow-
ing modifications and enhancements may be required to execute the programs produced by the
compiler:
a) Extend the Simpletron Simulator's memory to contain 1,000 memory locations to en-
able the Simpletron to handle larger programs.
b) Allow the simulator to perform remainder calculations. This modification requires an
additional SML instruction.
c) Allow the simulator to perform exponentiation calculations. This modification requires
an additional SML instruction.
image text in transcribed

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

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions

Question

7. What are the main provisions of the FMLA?

Answered: 1 week ago

Question

2. Do small companies need to develop a pay plan? Why or why not?

Answered: 1 week ago