Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Now, let's walk through execution of the first SML instruction, + 1 0 0 9 in memory location oo . This procedure is called an

Now, let's walk through execution of the first SML instruction, +1009 in memory location oo.
This procedure is called an instruction-execution cycle.
The instructionCounter tells us the location of the next instruction to be performed.
fetch the contents of that location from memory by using the Java statement
instructionRegister = memory [instructionCounter];
The operation code and the operand are extracted from the instruction register by the statements
operationCode = instructionRegister /100;
operand = instructionRegister %100;
Now the Simpletron must determine that the operation code is actually a read (versus a write, a
load, and so on). A switch differentiates among the 12 operations of SML. In the switch state.
ment, the behavior of various SML instructions is simulated as shown in Fig. 7.36. We discuss
branch instructions shortly and leave the orhers to you.
rend:
Display the prompt "Enter an integer", then input the integer and store it
in location memory [operand].
load:
accumulator = memory [operand];
add:
accumulator += memory[operand];
halt: , Terminate the SML program's execution and display the following message:
Simpletron execution terminated
Fig. 7.36| Behavior of several SML instructions in the Simpletron.
When the SML program completes execution, the name and contents of each register as well
as the complete contents of memory should be displayed. Such a printout is often called a com-
puter dump (no, a computer dump is not a place where old computers go). To help you program
your dump method, a sample dump format is shown in Fig. 7.37. A dump after executing a
Simpletron program would show the actual values of instructions and data values at the moment
execution terminated.
REGISTERS :
MEMORY:
40+0000+0000+0000+0000+0000+0000+0000+0000+0000+0000
50+0000+0000+0000+0000+0000+0000+0000+0000+0000+0000
70+0000+0000+0000+0000+0000+0000+0000+0000+0000+0000
80+0000+0000+0000+0000+0000+000+0000+0000+000+0000+0000
90+0000+0000+0000+0000+0000+0000+0000+0000+0000+0000
+0000+0000+0000+0000
Fig. 7.37| A sample dump.
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