Answered step by step
Verified Expert Solution
Link Copied!

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 sentinel-controlled loop to read 10 positive numbers. Compute and display their
sum.
b) Use a counter-controlled 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.
1.37(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 object-oriented software model of the Simpletron of Exercise 7.36. 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 7.36.
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 -99999 to stop entering your program.
Your application should simulate the memory of the Simpletron with a one-dimensional array mem-
ory that has 100 elements. Now assume that the simulator is running, and let's examine the dialog
as we enter the program of Fig. 7.35(Exercise 7.36):
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 -99999 is input, the program
should display the following:
*4 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 00 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 (i.e.,
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.
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_2

Step: 3

blur-text-image_3

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

Concepts of Database Management

Authors: Philip J. Pratt, Mary Z. Last

8th edition

1285427106, 978-1285427102

More Books

Students also viewed these Databases questions

Question

2.5 Describe a social audit.

Answered: 1 week ago