Why would it be suitable to design an instruction set with 2-bits allocated for the register number and 10-bits allocated for the memory address? Would introducing a cache change this? (If possible I'd like to know why or where to find an explanation on this.)

If it helps an example would look like this 0001 xxyy yyyy yyyy and an instruction would be the opcode 0001 (Load) register xx from memory address yy yyyy yyyy.

  • $\begingroup$ Welcome to Computer Science! Unfortunately, your title does not match your question. Please take some time to improve it so readers know what to expect when reading it. $\endgroup$
    – dkaeae
    Mar 25 '19 at 10:25

Two bits for the register and ten bits for the address makes sense when you have ~four registers and ~1024 words of memory. Any more and you can't address it all (how would you access register #5, or memory address #1025?); any less and you're wasting precious bits in every instruction (why use two bits for the register when there's only two registers to choose from?).

Generally, the purpose of a cache is to make things faster without changing the underlying model. In other words, if you don't care how fast your code is, you can just pretend the cache isn't there. Everything will work the same either way.

P.S. You can address more memory than this using various tricks like "bank switching", but I doubt you're concerned with those yet.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.