Arithmetic 1xx ADD 2xx SUB Data Movement 3xx STORE 5xx LOAD BR 6xx JUMP BRZ 7xx BRANCH ON 0 BRP 8xx BRANCH ON + (Non-Negative) Input/Output 901 INPUT 902 Output Machine Control (coffee break) 000 HALT COB Based on these Instruction Set Write a program for the Little Man Computer to do the following calculation and output the result: ( a + b ) − ( c + d ) where a , b , c , and d are four numbers the program reads from the In basket.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Arithmetic 1xx ADD 2xx SUB

Data Movement 3xx STORE 5xx LOAD BR

6xx JUMP BRZ 7xx BRANCH ON 0 BRP 8xx BRANCH ON + (Non-Negative)

Input/Output 901 INPUT 902 Output

Machine Control (coffee break) 000 HALT COB

Based on these Instruction Set

Write a program for the Little Man Computer to do the following calculation and output the result: ( a + b ) − ( c + d ) where a , b , c , and d are four numbers the program reads from the In basket.

 

Expert Solution
Step 1
  • Introduction :

The Little Man Computer (LMC) is a hypothetical machine that was created to help teach the fundamentals of computer programming. It is a simple concept that is easy to understand and use, and is often used in computer science classes as a way to teach students the basics of machine language and assembly language programming. 

The LMC has a very simple instruction set, which consists of 8 instructions. These instructions are used to move data around the computer, perform arithmetic operations, input data from the user, and output data to the user. 

To solve the problem posed, the program would need to read the four numbers (a, b, c, and d) from the In basket, perform the calculation (a + b) - (c + d), and then output the result to the Out basket. 

In order to do this, the program would need to use a combination of the following instructions:

1. Data Movement Instructions:

• LOAD: Used to load a value into the Accumulator (the memory location used to store the result of each calculation).
• STORE: Used to store a value from the Accumulator in a memory location.

2. Arithmetic Instructions:

• ADD: Used to add two values together.
• SUB: Used to subtract one value from another.

3. Input/Output Instructions:

• INPUT: Used to read a value from the In basket.
• OUTPUT: Used to write a value to the Out basket.

4. Machine Control Instructions:

• HALT: Used to end the program execution.

To solve the problem posed, the program would need to follow the steps outlined below:

1. Load the value of an into the Accumulator.

2. Store the value of an into a memory location.

3. Load the value of b into the Accumulator.

4. Add the value of b to the Accumulator.

5. Store the result of the addition in a memory location.

6. Load the value of c into the Accumulator.

7. Store the value of c in a memory location.

8. Load the value of d into the Accumulator.

9. Add the value of d to the Accumulator.

10. Store the result of the addition in a memory location.

11. Load the value stored in the first memory location into the Accumulator.

12. Subtract the value stored in the second memory location from the Accumulator.

13. Store the result of the subtraction in a memory location.

14. Output the value stored in the third memory location to the Out basket.

15. Halt the program.

Algorithm :

read four numbers a, b, c, and d from the In Basket
store the numbers in memory locations (1-4)
add a and b and store the result in memory location 5
add c and d and store the result in memory location 6
subtract the value in memory location 6 from the value in memory location 5 and store the result in memory location 7
output the value in memory location 7 

 

 

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Execution of the instruction
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY