0
\$\begingroup\$

I am trying to design a (very) simple processor architecture. I am in the process of creating a basic instruction set for it, however I am not sure of the best ("best" meaning what most people use - to remove subjectiveness) way to implement some instructions.

Take an output instruction for example, and say I want to output register a or register b - there are two ways that I know of to do this: have two different instructions, one for outputting a and one for outputting b, or it could be one instruction and depending on the next byte in memory (argument) it outputs either a or b.

What is the most common, or most efficient way of doing this?

Thanks in advance.

P.S. This is my first question, so if I've done something terribly wrong point it out and I'll try to fix it.

\$\endgroup\$

2 Answers 2

1
\$\begingroup\$

You still need to define what "best" means to you in the context of your overall implementation. You've told us nothing at all about the overall architecture of your "simple" CPU or your design process. How much time have you spent studying the instruction encoding of existing 8-bit processors? Even something as primitive as the 8008 — note how some instructions can refer to one or two of the eight registers. Or the 6800, which has two data registers like yours does.

But in general terms, a "parameter" ("operand" is a more common term for this) doesn't need to occupy an entire byte. If your CPU has two registers, then most instructions are going to want to refer to one or the other of them. So why not dedicate one bit of the first byte of the instruction to denote which register is to be the source or destination of the operation?

\$\endgroup\$
1
  • \$\begingroup\$ I have spent some time with the (seriously old) Z80, but not studying it in-depth. I should probably change "best" to something else, I mean "What is most common, and fairly simple". And the second paragraph answers my question. Thanks \$\endgroup\$
    – Jachdich
    Commented Dec 15, 2018 at 13:10
0
\$\begingroup\$

CPU architecture design is a very complicated - and interesting! - subject. There are many choices to make, and what is best bepends (among other things) on the state of technology you use - especially the speed difference between CPU and memory.

Do read up on CPU design. The best (advanced) books I know on this subject are by Hennessy and Patterson. Watch out: each edition of their seminal book is an almost totally different book.

\$\endgroup\$
1
  • \$\begingroup\$ That sounds cool! I'll certainly look into those books \$\endgroup\$
    – Jachdich
    Commented Dec 15, 2018 at 20:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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