Let's say there was a CPU with an input bus of 4 bits and the 4 bits are the opcode then the next 4 bits are the operand. It would just be an 8-bit instruction split in two. Is this possible and how would it be done with logic gates?
$\begingroup$
$\endgroup$
2
-
1$\begingroup$ One would need to remember the first part of an instruction (the opcode) until all parts (operands) are available, maybe until processed and result(s) made use of. Circuits to do so have been named latches, flip-flops, registers. Time allowing, compare Intel 8088 & 8086. $\endgroup$– greybeardCommented Apr 26, 2023 at 6:31
-
$\begingroup$ "x86 instructions can be anywhere between 1 and 15 bytes long": this should answer the first part of your question. $\endgroup$– user16034Commented Apr 26, 2023 at 12:57
Add a comment
|
1 Answer
$\begingroup$
$\endgroup$
You should look into "state machines".
Simple CPUs with variable length instructions have some kind of state machine.
Default state is fetching the opcode, then it fetches parameters or do memory accesses, eventually going through different states to execute each instruction.