Question
Use MARIEs instruction set to write a program following the format as below. Your program should output a smaller number between two input numbers from
Use MARIEs instruction set to write a program following the format as below. Your program should output a smaller number between two input numbers from the user. If two inputs are the same output a special number 9999.
1. Load X
Recall that this instruction loads the contents of memory location X into the AC. However, the address X
must first be placed into the MAR. Then the data at location M[MAR] (or address X) is moved into the
MBR. Finally, this data is placed in the AC.
MAR ? X
MBR ? M[MAR]
AC ? MBR
Because the IR must use the bus to copy the value of X into the MAR, before the data at location X can
be placed into the MBR, this operation requires two bus cycles. Therefore, these two operations are on
separate lines to indicate that they cannot occur during the same cycle. However, because we have a
special connection between the MBR and the AC, the transfer of the data from the MBR to the AC can
occur immediately after the data is put into the MBR, without waiting for the bus.
2. Store X
This instruction stores the contents of the AC in memory location X:
MAR ? X, MBR ? AC
M[MAR] ? MBR
3. Add X
The data value stored at address X is added to the AC. This can be accomplished as follows:
MAR ? X
MBR ? M[MAR]
AC ? AC + MBR
4. Subt X
Similar to Add, this instruction subtracts the value stored at address X from the accumulator and places
the result back in the AC:
MAR ? X
MBR ? M[MAR]
AC ? AC MBR
5. Input
Any input from the input device is first routed into the InREG. Then the data is transferred into the AC.
AC ? InREG
6. Output
This instruction causes the contents of the AC to be placed into the OutREG, where it is eventually sent to
the output device.
OutREG ? AC
7. Halt
No operations are performed on registers; the machine simply ceases execution of the program.
8. Skipcond
Recall that this instruction uses the bits in positions 10 and 11 in the address field to determine what
comparison to perform on the AC. Depending on this bit combination, the AC is checked to see whether it
is negative, equal to 0, or greater than 0. If the given condition is true, then the next instruction is skipped.
This is performed by incrementing the PC register by 1.
9. Jump X
This instruction causes an unconditional branch to the given address, X. Therefore, to execute this
instruction, X must be loaded into the PC.
PC ? X
In reality, the lower or least significant 12 bits of the instruction register (or IR[110]) reflect the
value of X. So this transfer is more accurately depicted as:
PC ? IR[11-0]
However, we feel that the notation PC ? X is easier to understand and relate to the actual instructions, so
we use this instead.
Register transfer notation is a symbolic means of expressing what is happening in the system when a
given instruction is executing. RTN is sensitive to the datapath, in that if multiple microoperations must
share the bus, they must be executed in a sequential fashion, one following the other.
Address | instruction |
---|---|
100 | Load X |
101 | Add y |
102 | Store Z |
103 | Halt |
104 X. | 0023 |
105 Y. | FFE9 |
106 Z. | 0000 |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started