Author Topic: Something about Fetch, Decode, Execute  (Read 2858 times)

0 Members and 1 Guest are viewing this topic.

Offline mike_g

  • Amiga 1200
  • ****
  • Posts: 435
  • Karma: 34
    • View Profile
As theres quite a few people here that code in ASM here I'm hoping someone could answer this for me. In the FDE cycle, if the same instruction (involving data) has to be run several times does the processor have to fetch the instruction over and over before each time it can get the data. Or does it leave the instruction in its register and just fetch the data until a new instruction is needed. This would be better, but is it how it works?  Cheers.

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: Something about Fetch, Decode, Execute
« Reply #1 on: May 02, 2007 »
if you use the same instruction (as in the exact same instruction which is the exact same address in memory) then that instruction is only fetched once then the CPU accesses the instruction in the cache that is until the cache has been filled. this will free up the data bus for better use

Challenge Trophies Won:

Offline mike_g

  • Amiga 1200
  • ****
  • Posts: 435
  • Karma: 34
    • View Profile
Re: Something about Fetch, Decode, Execute
« Reply #2 on: May 02, 2007 »
I just realised that if the command was the same but a parameter that went with it was different, then it would not be exactly the same instruction. So I guess it would have to fetch the instruction every time. Cheers rain_storm.

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Something about Fetch, Decode, Execute
« Reply #3 on: May 02, 2007 »
Depends on the instruction cacheing on the chip.  IIRC, CPUs like Z80 don't have an instruction cache and have to re-read every instruction from RAM every time.  68000 (or was it MIPS4000?) has a 4 instruction cache so if there's a tight loop it might not have to re-fetch anything.  Newer Intel CPUs have 10s or 100s of instructions in local caches.

So the fetch decode execute cycle is about as simple as the CPU can be described, fetch the instruction, decode it (which might mean all sorts of things, like fetching data from RAM) and then execute the result (which might mean storing data back to RAM).  In a modern Intel, there might be as many as a dozen instructions being executed at once, at various stages of completion (super pipelining).

Jim
Challenge Trophies Won: