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.
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
![](/static/compass_v2/shared-icons/check-mark.png)
- 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
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)