Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Now write SML programs to accomplish each of the following tasks: a ) Use a sentinel - controlled loop to read 1 0 positive numbers.
Now write SML programs to accomplish each of the following tasks:
a Use a sentinelcontrolled loop to read positive numbers. Compute and display their
sum.
b Use a countercontrolled loop to read seven numbers, some positive and some negarive,
and compute and display their average.
c Read a series of numbers, and determine and display the largest number. The first num
ber read indicates how many numbers should be processed.
Computer Simulator In this problem, you're going to build your own computer. No
you'll not be soldering components together. Rather, you'll use the powerful technique of software
based simulation to create an objectoriented software model of the Simpletron of Exercise Your
Simpletron simulator will turn the computer you're using into a Simpletron, and you'll actually be
able to run, test and debug the SML programs you wrote in Exercise
When you run your Simpletron simulator, it should begin by displaying:
Welcome to Simpletronl
Please enter your program one instruction
th or data word at a time. I will display
the location number and a question mark
ow You then type the word for that location.
& Type to stop entering your program.
Your application should simulate the memory of the Simpletron with a onedimensional array mem
ory that has elements. Now assume that the simulator is running, and let's examine the dialog
as we enter the program of Fig. Exercise :
Your program should display the memory location followed by a question mark. Each value to the
right of a question mark is input by the user. When the sentinel value is input, the program
should display the following:
Program loading completed
a Program execution begins
The SML program has now been placed or loaded in array memory. Now the Simpletron exe
cutes the SML program. Execution begins with the instruction in location and, as in Java, con
tinues sequentially, unless directed to some other part of the program by a transfer of control.
Use the variable accumulator to represent the accumulator register. Use the variable instruc
tioncounter to keep track of the location in memory that contains the instruction being per
formed. Use the variable operationCode to indicate the operation currently being performed ie
the left two digits of the instruction word Use the variable operand to indicate the memory loca
tion on which the current instruction operates. Thus, operand is the rightmost two digits of the
instruction currently being performed. Do not execute instructions directly from memory. Racher,
transfer the next instruction to be performed from memory to a variable called instructionRegis
ter. Then pick off the left two digits and place them in operationCode, and pick off the right two
digits and place them in operand. When the Simpletron begins execution, the special registers are
all initialized to zero.
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