1. Write a program that will read two values, a and b, and will print the quantity a+b and then loop to read another pair of values. a-b’ 2. Write a program that will read three values, a, b, and c, and compute a a* and b*c

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter15: Recursion
Section: Chapter Questions
Problem 7SA
icon
Concept explainers
Question

Help with my homework. Thank you so much.

Table A.2 Code for computing la - b|
Exercises
Symbolic code
Machine code
1. Although we have not yet described division in our miniature computer, let us
assume that a quotient p÷ q (the integral part) may be obtained by the code
sequence that corresponds to
Instruction
Addresst
Instruction
Address
name
Start
CLA P
START
RDS A
09
701
DIV Q
RDS B
10
702
CLA A
11
101
The resulting quotient will be found in the three lowest-order positions of the
АСС.
Write a sequence of symbolic codes and corresponding machine codes that
will compute the value
SUB B
STO C
TMI NEG
PRT C
TRA START
302
403
017
803
909
102
301
403
915
12
13
14
AGAIN
15
16
а — b,
y =
a+ b,
CLA B
SUB A
NEG
17
18
b.
Draw a picture of the storage cells showing all instructions and locations for
original or intermediate results. You must make certain decisions, such as where
STO C
19
TRA AGAIN
20
to keep a, b, and y in storage and at what location to begin the program.
Hint: Before the division can be carried out, both the numerator and the
denominator must be computed. At least one of these must be saved, in a place
that you will have to designate, while the other is being computed.
t We are assuming the following: (1) Instructions begin at 09.
(2) A at 01, B at 02, C at 03.
eea-b
2. After completing Exercise 1, write a sequence of instructions that reads a pair of
values for a and b from punch cards, computes y, prints it, and returns to read
another pair of values.
T.
e<0
3. Assume that a product p X q may be obtained by the code sequence that cor-
responds to
Negative
CLA P
MPY Q
Write a code sequence to compute the following.
Ceb-a
a) d=ªXb
a
b) c=
bx c
Print
Fig. A.10 Flowchart for computing a- b|.
Transcribed Image Text:Table A.2 Code for computing la - b| Exercises Symbolic code Machine code 1. Although we have not yet described division in our miniature computer, let us assume that a quotient p÷ q (the integral part) may be obtained by the code sequence that corresponds to Instruction Addresst Instruction Address name Start CLA P START RDS A 09 701 DIV Q RDS B 10 702 CLA A 11 101 The resulting quotient will be found in the three lowest-order positions of the АСС. Write a sequence of symbolic codes and corresponding machine codes that will compute the value SUB B STO C TMI NEG PRT C TRA START 302 403 017 803 909 102 301 403 915 12 13 14 AGAIN 15 16 а — b, y = a+ b, CLA B SUB A NEG 17 18 b. Draw a picture of the storage cells showing all instructions and locations for original or intermediate results. You must make certain decisions, such as where STO C 19 TRA AGAIN 20 to keep a, b, and y in storage and at what location to begin the program. Hint: Before the division can be carried out, both the numerator and the denominator must be computed. At least one of these must be saved, in a place that you will have to designate, while the other is being computed. t We are assuming the following: (1) Instructions begin at 09. (2) A at 01, B at 02, C at 03. eea-b 2. After completing Exercise 1, write a sequence of instructions that reads a pair of values for a and b from punch cards, computes y, prints it, and returns to read another pair of values. T. e<0 3. Assume that a product p X q may be obtained by the code sequence that cor- responds to Negative CLA P MPY Q Write a code sequence to compute the following. Ceb-a a) d=ªXb a b) c= bx c Print Fig. A.10 Flowchart for computing a- b|.
Exercises:
1. Write a program that will read two values, a and b, and will print the quantity
a+b
and then loop to read another pair of values.
a-b
2. Write a program that will read three values, a, b, and c, and compute
a*b
and
a
b*c'
3. Write a program that will read a number and print its absolute value.
In all three of the above programs, write the assembly code first, then write the machine code, then place the code into computer memory.
Transcribed Image Text:Exercises: 1. Write a program that will read two values, a and b, and will print the quantity a+b and then loop to read another pair of values. a-b 2. Write a program that will read three values, a, b, and c, and compute a*b and a b*c' 3. Write a program that will read a number and print its absolute value. In all three of the above programs, write the assembly code first, then write the machine code, then place the code into computer memory.
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Control Structure
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:
9780357392676
Author:
FREUND, Steven
Publisher:
CENGAGE L
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT