Name: Date:
HW13
Your task is to compare the memory efficiency of four different styles of instruction sets. The architecture styles are the following:
- Accumulator: All operations use the accumulator register. Operands come from the accumulator and/or memory and the result of most operations is stored in the accumulator.
- Memory-memory: All three operands of each instruction are in memory.
- Stack: All operations occur on top of the stack. Only push and pop access memory, and all other instructions remove their operands from the stack and replace them with the result. The implementation uses a stack for the top two entries; accesses that use other stack positions are memory references.
- Load-store: All operations occur in registers, and register-to-register instructions have three operands per instruction.
For this assignment, you may make the following assumptions.
- The opcode is always 1 byte
- All memory addresses are 2 bytes
- All data operands are 2 bytes
- All instructions are an integral number of bytes in length
- For load store, there are 16 general purpose registers and register specifiers are 4 bits long.
Each architecture should be able to run this code:
do {
a = b - c;
b = b - d;
} while(a != 0)
You should have designed the instruction sets and programs in your class. For this homework, you will analyze your in-class design.
-
(20 points) Analyze the efficiency of each architecture for this piece of code. Count how many instructions are needed. Then, assuming the loop is executed once (e.g. each line of code is executed once), count how many bytes of instruction data must be transferred from memory to the processor in order to run the program. Also count how many bytes are needed to transfer any other data (e.g. for memory instructions like
lw
andsw
). Finally, compute the total transferred and analyze your results. Show your work.a. Accumulator cost:
Number of instructions Instruction bytes Other data bytes Total bytes b. Memory-memory cost:
Number of instructions Instruction bytes Other data bytes Total bytes c. Stack cost:
Number of instructions Instruction bytes Other data bytes Total bytes d. Load store cost:
Number of instructions Instruction bytes Other data bytes Total bytes -
(3 points) Which architecture is the most efficient in terms of number of instructions?
-
(3 points) Which architecture is the most efficient in terms of total bytes transferred?
-
(4 points) Which architecture is better and why?