Question: 0 0 INP / / Input the first value 0 1 STA 0 1 / / Store the input at mailbox 0 1 0 2
INP Input the first value
STA Store the input at mailbox
INP Input the second value
STA Store it at mailbox
INP Input the third value
STA Store it at mailbox
INP Input the fourth value
STA Store it at mailbox
INP Input the fifth value
STA Store it at mailbox
INP Input the sixth value
STA Store it at mailbox
INP Input the seventh value
STA Store it at mailbox
INP Input the eighth value
STA Store it at mailbox
INP Input the ninth value
STA Store it at mailbox
INP Input the tenth value
STA Store it at mailbox
LDA Load the last input value to check for
BRZ If input is zero, jump to exit check
SUB Subtract to check if input equals
BRZ If result is zero, jump to start user program at location
LDA Load a value that is nonnegative
BRP Always branch back to location
INP ; Input the first value from the user
STA ; Store the first input at mailbox
INP ; Input the second value
STA ; Store it at mailbox
INP ; Input the third value
STA ; Store it at mailbox
INP ; Input the fourth value
STA ; Store it at mailbox
INP ; Input the fifth value
STA ; Store it at mailbox
INP ; Input the sixth value
STA ; Store it at mailbox
INP ; Input the seventh value
STA ; Store it at mailbox
INP ; Input the eighth value
STA ; Store it at mailbox
INP ; Input the ninth value
STA ; Store it at mailbox
INP ; Input the tenth value
STA ; Store it at mailbox
LDA ; Load the last input value to check for
BRZ ; If input is zero after inputting jump to check for exit
SUB ; Subtract to check if input equals
BRZ ; If result is zero input was jump to location user program start
LDA ; Load a value that is nonnegative simulating positive value
BRP ; If the value is positive, loop back to location
The code above follows the following guidelines and run and if it does not than make it do so:
Suppose a small program is permanently stored in the last few mailbox locations. A BRANCH instruction at location also permanent, will start this program. This program will accept input values and will store them at consecutive mailbox locations, starting with mailbox You may assume that these values represent the instructions and data of a user's program to be executed. When a is received as input data, the program jumps to location where it will proceed to execute the values just entered. The small program described here is known as a program loader, or under certain circumstances as a bootstrap. This program takes advantage that instructions and data are indistinguishable Von Neumann architecture Thus, instructions could be treated as if they were data, if necessary. Mailbox Mnemonic Opcode Comment LDA initialize the STORE instruction at loc. STO storing the contents of mailbox that is INP input a value SUB subtract BRZ done loadingjump to for execution ADD restore input value DAT store value. This will contain XX with XX indexed LDA load the STORE instruction in ADD increment it STO and resave it BRA continue with the next input DAT value for testing DAT initial STORE instruction as a data value DAT value for indexing II What you need to do Load the above program loader in the LMC to understand what the program is doing. The instructions should be loaded in your LMC at the mailboxes indicated above that is they must start at memory location to work properly. Ensure that in mailbox you have the instruction to branch to mailbox first instruction of the program loader Note: The program below is used to fill the LMC memory with and is an example of selfmodifying codetry it in the LMC simulator As a matter of fact, the program loader works using the same principle. Change this program as required to load the program loader instructions starting in memory location start LDA line ADD one STA line LDA data line STA BRA start HLT data DAT one DAT Run the program loader and input the instructions of the following user program: Input two numbers and output the higher INP STA FIRST INP STA SECOND SUB FIRST BRP HIGHER LDA FIRST BRA DONE HIGHER LDA SECOND DONE OUT HLT FIRST DAT SECOND DAT Hint: Replace the mnemonics with the opcodes to input the instructions of this user program as numbers. Move the program loader so that it starts at mailbox
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
