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 instructioncounter register as follows:
instructionCounter;
This action completes the simulated execution of the first instruction. The entire process ie the
instructionexecution cycle begins anew with the fetch of the next instruction to execute.
Now let's consider how the branching instructions the transfers of controlare 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 programloading 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 reenter 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
ie 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.
Simpletron Simulator Modifications In Exercise 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 we propose building a compiler that converts programs written in a highlevel
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 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.
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