Answer-
lets assume we have following instruction sets in the given machine-
subtraction (SUB), multiplication (MUL), division (DIV) and data movement (MOV, LOAD, STORE, PUSH, and POP)
3-address machine has instructions like- SUB A, B, C means M [ A ]<----- M [ B ] -- M [ C ]
2-address machine has instructions like- SUB A,B means M [ A ] <------- M [A] -- M [B]
1-address machine has an accumulator to store the result.
0-address machine uses stack for both source and destination operands.
Given expression - A = (b/d) * (c-e)
the following table shows the 4 programs of different type of machines-
3-address machine | 2-address machine | 1-address machine | 0-address machine |
Div R1, b, d | Mov R1, b | Load b | push b |
Sub R2, c, e | Div R1, d | div d | push d |
Mul A, R1, R2 | Mov R2, c | store R | div |
Sub R2, e | load c | push c | |
Mul R1, R2 | sub e | push e | |
Mov A, R1 | mul R | sub | |
store A | mul | ||
pop A |
R1 and R2 are intermediate registers to hold the results temporarily.
we assume all instructions and the data values are in memory and must be fetched from memory.
Given that, opcode ----- 1 byte
address ------ 1 byte
data values ------ 2 bytes
so, instruction like SUB A, B, C requires
1 byte for the opcode, 1 byte for address A, 1 byte for address B, and 1 bytes for address C , in total of 4 bytes just to represent the instruction.
so 4 bytes require to fetch the instruction from the memory.
Also data at each address A, B and C requires 2 bytes, in total 6 bytes for the data value.
Therefore in total for the execution of SUB A,B,C we need 10 bytes.
So similar process is applied to other instructions also to calcute the number of bytes used.
total Memroy traffic for all types of instruction set:
3-address instruction | 2-address instruction | 1-address instruction | 0-address instruction |
Div R1, b, d 10 bytes | Mov R1, b 7 bytes | Load b 4 bytes | push b 4 bytes |
Sub R2, c, e 10 bytes | Div R1, d 7 bytes | div d 4 bytes | push d 4 bytes |
Mul A, R1, R2 10 bytes | Mov R2, c 7 bytes | store R 4 bytes | div 3 bytes |
Sub R2, e 7 bytes | load c 4 bytes | push c 4 bytes | |
Mul R1, R2 5 bytes | sub e 4 bytes | push e 4 bytes | |
Mov A, R1 5 bytes | mul R 4 bytes | sub 3 bytes | |
store A 4 bytes | mul 3 bytes | ||
pop A 2 bytes | |||
Memory Traffic--> 30 bytes | 38 bytes | 28 bytes | 25 bytes |
therefore , the total memory traffic is:
3-Address Machine: 30 bytes
2-Address Machine: 38 bytes
1-Address Machine: 28 bytes
0-Address Machine: 25 bytes
Calculate the total memory traffic for the set of instructions that implements the expression A= (b/d)...
Question 20 5 pts Suppose a computer has 32-bit instructions. The instruction set consists of 64 different operations. All instructions have an opcode and two address fields (allowing for two addresses). The first of these addresses must be a register direct address, and the second must be a memory address. Expanding opcodes are not used. The machine has 16 registers. What's the size of the largest memory space that can be addressed by this computer?Assume byte addressable memory.
There is an example below Now that everything is working you can try the following exercises. To complete them you will need to refer to the documentation in Appendix A The MiteASM Assembler and Appendix B The MiteFPGA Processor. Write an assembly language program for an over counter for a cricket umpire. This should 1. display a count on the 7-segment display. The count should increase by 1 when button 0 is pressed. It should reset to 0 when button...
This C++ Program consists of: operator overloading, as well as experience with managing dynamic memory allocation inside a class. Task One common limitation of programming languages is that the built-in types are limited to smaller finite ranges of storage. For instance, the built-in int type in C++ is 4 bytes in most systems today, allowing for about 4 billion different numbers. The regular int splits this range between positive and negative numbers, but even an unsigned int (assuming 4 bytes)...
5 Exercises Now that everything is working you can try the following exercises. To complete them you will need to refer to the documentation in Appendix A- The MiteASM Assembler and Appendix B - The MiteFPGA Processor. Write an assembly language program for an over counter for a cricket umpire. This should display a count on the 7-segment display. The count should increase by 1 when button 0 is 1. pressed. It should reset to 0 when button 1 is...