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.

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

Discuss the roles of metacognition in learning and remembering.

Answered: 1 week ago

Question

Do you agree that unions stifle creativity? Why or why not?

Answered: 1 week ago

Question

6 What is the selection phase?

Answered: 1 week ago