Answered step by step
Verified Expert Solution
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
As we've indicated, the switch reading the value and storing it in memory location memory
operand
The value is then
read into location
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
is simulated within the switch as
instructionCounter
operand;
The conditional "branch if accumulator is zero" instruction is simulated as
if
accumulator
instructionCounter
operand;
At this point, you should implement your Simpletron simulator and run each of the SML
programs you wrote in Exercise
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
to
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
or smaller than
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. java code
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started