HW
LMC programming
Instructions:
· You are permitted to discuss the following questions with others in the class. However, you must write up your own solutions to these questions.
1. Write a program using the LMC instruction set that:
a. Asks the user for 2 numbers (say, A & B). If A = B:
i. It prints A
ii. Otherwise, it asks for a third number (say, C). It then prints the larger of the two values (A or C).
Write the program instructions and their addresses in the form of a flowchart (with branches) so that your program logic is clearly understandable. To help you do so, a snapshot from an unrelated example is shown below. Note that these are just examples, the instructions will be different in your program.
For every step in the flowchart, write down “Instruction address - LMC instruction - Description”.
Addr – LMC Instruction – Description
Know which memory addresses you plan to store your operands. This example assumes A is stored in address 91.
00 –INPUT – Input A
01 – STORE 91 – Store A
…
Note that instructions that you DON’T branch to are located sequentially in memory after the conditional branch instruction.
12 – BRP 32 - Is A > B?
Yes No
13 – LOAD 92 – Load B
30 – LOAD 91 – Load A