In an assignment to instruction set, we are told to write a sequence of instructions for arithmetic operations needed in different architecture models: accumulator, stack, load/store, memory/memory.
Given:
- Opcode - 8 bits
- Memory addresses - 16 bits
- All registers are coded with 4 bits
- All data operands - 32 bits
- All instructions must be of an even number of bytes, i.e. 8 x N bits, where N is a natural number.
AND! Addresses of registers can be packed together
Question 1: When do we pack two registers together? How does the system know it's not one register coded into 4 bits? Could you please give me an example?
Say, we are given A = B + C. Instructions needed in the load/store model for this operation:
1. load r2, B;
2. load r3, C;
3. add r1, r2, r3;
4. store r1, A.
The 1st instruction is 28 bits long, so we need additional 4 bits.
Question 2: Does it make difference where to put the 4 bits in form of 0000? How would you make the instruction of a whole number of bytes?
I'll appreciate your help very much.
NOPoperator which is a do-nothing 4bit instructions you can stuff anywhere you end up with a non-32bit size. - Marc B