1

I'm learning about computer architecture and I know how a computer works when it executes a program. The thing that makes me confused is when the instruction length is longer than the width of the bus AND the instruction length is NOT the double of the bus width. Let's say we have 12 bit instructions and an 8 bit bus. What does the computer do? Does it:

  1. Analyse the PC
  2. Go to the address of the PC
  3. Fetch 8 bits of the instruction
  4. store 8 bits in instruction register
  5. increase PC by 8 bits (???)
  6. fetch the remaining 4 bits
  7. fill the instruction register (which is 12 bits long?)

Well as you see I'm confused here. I suppose it's not like this, but I need to know in detail how it works and what the PC is after every step.

Would be very grateful for some help! Thanks in advance.

Daniel Heilper
  • 1,182
  • 2
  • 17
  • 34
Myone
  • 1,103
  • 2
  • 11
  • 24
  • *Somewhat* related: [With variable length instructions how does the computer know the length of the instruction being fetched?](http://stackoverflow.com/q/24269368/2467198) –  Jul 21 '14 at 19:25

1 Answers1

2

Normally, the smalls amount of memory that can be read or written is 1 byte, i.e. 8 bits. So if the CPU needs 12 bits only, it has to read two 8-bit bytes. From the 16 bits, the required 12 bits are extracted by hardware, and the remaining 4 bits are not used.
Since this is not so memory efficient, the instruction length of a CPU normally is a multiple of 8 bits, e.g. by packing operands directly into the instruction.
So your 7 steps in your example are right except step 6, in which 8 bits are fetched, of which only 4 would be used.

Reinhard Männer
  • 14,022
  • 5
  • 54
  • 116
  • Thanks! So really the PC increases by 8 bits every time? So after 1/2 instruction PC = [0x01] and after 2 instructions PC = [0x04]? Assuming it starts at 0x00. And the instruction register is always 12 bits even it the CPU fetches 16 bits? – Myone May 24 '14 at 08:17
  • This depends on the CPU / micro controller used. The 1st CPU, the INTEL 8080, had, e.g. 8-bit and 16-bit instructions . I don't know if there is any CPU using a 12 bit instruction word. But if so, it could read three 8 bit bytes from memory, and interpret them as two instructions... – Reinhard Männer May 24 '14 at 09:14