The Fetch-Execute Cycle: What's Your Computer Actually Doing?

The Fetch-Execute Cycle: What's Your Computer Actually Doing?

The fetch-execute cycle is the basis of everything your computer or phone does. This is literally The Basics. • Sponsored by Dashlane —try 30 days for free at: https://www.dashlane.com/tomscott

Thanks to Dashlane for sponsoring the video! If you’re techie enough to watch this video, you should be using a password manager. Get a 30-day free trial at https://dashlane.com/tomscott

MORE BASICS: https://www.youtube.com/playlist?list=PL96C35uN7xGLLeET0dOWaKHkAlPsrkcha

MINOR CORRECTIONS:
In the graphics, “programme” should be “program”.
I say “Mac instead of PC”; that should be “a phone instead of a PC”.
And most importantly, I say “every sixth cycle”: that should be “every ninth”.
Fortunately, none of these materially affect the content of the video!

Written by Sean M Elliott and Tom Scott
Directed by Tomek
Graphics by Mooviemakers https://www.mooviemakers.co.uk/
Audio mix by Haerther Productions https://haerther.net/

I’m at https://tomscott.com
on Twitter at https://twitter.com/tomscott
on Facebook at https://facebook.com/tomscott
and on Instagram as tomscottgo

50 Comments

  1. talzO9 on September 20, 2019 at 8:21 pm

    is that a green screen



  2. SteveVi0lence on September 20, 2019 at 8:22 pm

    Mine is downloading porn



  3. EramsorGR on September 20, 2019 at 8:23 pm

    I should make a song of Tom saying "fetch, decode, execute"



  4. Forgan Mreeman on September 20, 2019 at 8:25 pm

    if i’ve said it once i’ve said it 100x, programmers are actual aliens. or i’m an idiot. i had trouble keeping up with this very simple example. i failed two programming courses in a row while studying for my computer science degree. it made me drop out.
    i’m just not a programmer. kudos to those who are. it’s an incredible feat



  5. Gerrit Zimmermann on September 20, 2019 at 8:25 pm

    If all humans were snapping their fingers simultaneously, with both hands, it would still not be sufficient to drive that virtual CPU to the same speed a bog-standard multicore processor works at nowadays …



  6. Maghil vannan on September 20, 2019 at 8:27 pm

    @Tom Scott can you do a video about how pipelining is done in a basic level



  7. Kiki Tay on September 20, 2019 at 8:27 pm

    Where can I find more about what’s going on in his video’s background?



  8. DevinDTV on September 20, 2019 at 8:28 pm

    If you want to learn more, check out Ben Eater’s series on constructing an 8 bit CPU.



  9. Dull Bananas on September 20, 2019 at 8:28 pm

    you love red



  10. SteveVi0lence on September 20, 2019 at 8:29 pm

    God Bless Scott’s Tot’s



  11. losthor1zon on September 20, 2019 at 8:30 pm

    Nice demonstration. I’m only disappointed that you didn’t give an example of assembly language so that people can see what it looks like. (I vaguely remember 8080 / Z80 assembler, but any would do.)



  12. Mass Games on September 20, 2019 at 8:30 pm

    4:45 snapping skills are a little scary at this point



  13. Raymond Mataka on September 20, 2019 at 8:31 pm

    Most indirect flex



  14. Luminescent Lion on September 20, 2019 at 8:31 pm

    Isnt the clock on the MoBo though, CPU just takes that and runs it through a multiplier to get its speed(in hertz), which it runs the instructions at.



  15. Overbite Games on September 20, 2019 at 8:34 pm

    watching this with a wrist injury has my hands feeling a certain way.

    Ouch.



  16. Daniel Wilson on September 20, 2019 at 8:34 pm

    Ah, good ol’ ECE 4613 — Computer Architecture. That example’s a little on the slow side, though — typically you’ll see some pipelining, with instruction 2 loading while instruction 1 decodes, or rather instruction 2 loading and decoding while instruction 1 goes about the rather slower process of executing (provide the execute phase hasn’t been split up and not counting speeding things along some more by making memory accesses another phase in the pipe). That way once the pipe fills up, you’re burning through a phase of as many instructions as you have pipeline phases all at once (which gives the components no respite, often making them switch every clock cycle, dramatically increasing heat build-up), making for big ol’ gains in throughput when not frustrated by conditional jumps making a missed branch prediction mean dumping large portions of the pipe, leaving a so-called "bubble".
    I sure can see why you left it out, though!



  17. felix34ever1 on September 20, 2019 at 8:37 pm

    This helps so much with computer science, now I understand what’s actually happening at the bits of the cpu



  18. Qwerty-Space on September 20, 2019 at 8:38 pm

    The original Roller Coaster Tycoon is a good example of a game written in Assembly!!



  19. Gustav Krause on September 20, 2019 at 8:38 pm

    did your finger actually hurt after recording this footage?
    Edit: Also this sponsoring ist nice cause it’s actually related to your content and you give a detailed explanation on password managers too, so props for that 🙂



  20. 6StringPassion on September 20, 2019 at 8:40 pm

    Great video! Alan Turing deserves mention here.



  21. Laurpud on September 20, 2019 at 8:40 pm

    Sorry, I still don’t get it. I guess I need it dumbed down even more



  22. Claxvii 177th on September 20, 2019 at 8:42 pm

    Tom, you are a bloody wizard



  23. Kshitij Shah on September 20, 2019 at 8:42 pm

    People who unironically code in assembly for fun are masochists



  24. Lucas Dupuis on September 20, 2019 at 8:43 pm

    I’ve watched this video three times in a row and my brain still refuses to understand most of it, am I small brain ?



  25. Chris Cerne on September 20, 2019 at 8:49 pm

    Interesting video! I know this is an oversimplified example, but isn’t the fetch -> decode -> execute process of a CPU done in one clock cycle? Fetch -> decode -> execute is carried over a series of logic gates that only depend on one clock cycle to process an instruction.



  26. Gull Lars on September 20, 2019 at 8:49 pm

    I did code a 16-bit RISC assembly program once for a project, which was an interpreter for ASCII encoded commands and piping of data in an FPGA soft core to control the hardware blocks’ functionality. There are some really clever things you can do at the machine code level to make your code small and fast, but to do so correctly is very hard and basically requires you to be able to step through the code flow in your head (or with flowcharts for assistance). If you think refactoring c++, java or C# is hard, try refactoring hundreds or thousands of lines of assembly. Some experience with code golfing can come in really handy then. (our case was on the order of 450-500 lines of an initial assembly implementation getting refactored and reduced to 150 lines because of a need to keep more data state in the limited registers, and a severe penalty for too much memory access to shuffle data between RAM and registers.



  27. Rei on September 20, 2019 at 8:51 pm

    lil glitchy there



  28. Isaac Clodfelter on September 20, 2019 at 8:56 pm

    Higher level programming languages are just the endless cycle of computer programmers programming programs to program their programs just a little better. I love it.



  29. Tom Scott on September 20, 2019 at 8:56 pm

    And away we go with another season of three computer-science videos! A whole team made this happen: pull down the description for all the details! And thanks to Dashlane for sponsoring: you can find more about them at https://www.dashlane.com/tomscott



  30. Hydrochloric Acid on September 20, 2019 at 8:56 pm

    Are you trying to hypnotize me tom?



  31. Neonic Plays on September 20, 2019 at 9:00 pm

    Register? I thought that was a cache



  32. KidUKnott on September 20, 2019 at 9:00 pm

    I love your The Basics series, Tom. Do keep them coming. I bet it’s a lot of work to come up with topics and make them, but they are awesome. I wish I’d watched these ten years ago. Subscribed.



  33. joshmbrown42 on September 20, 2019 at 9:01 pm

    As someone who’s studied CS in the US, "programme counter" really threw me off for a few seconds.



  34. Dave Thackeray on September 20, 2019 at 9:03 pm

    To demonstrate my abject stupidity I still don’t understand how a basic computer works.



  35. GaMerZ on September 20, 2019 at 9:03 pm

    RIP Tom Scott



  36. Cyrus Hale on September 20, 2019 at 9:05 pm

    I’m tech enough to use something betting than dashlane.



  37. sawyer bergeron on September 20, 2019 at 9:06 pm

    If you get into it further it gets even cooler. Modern cpus take those instructions and execute them out of order if one needs to wait, they do those jump instructions before they know they actually need to to do work in advance, they do all three of those steps (fetch, decode, execute) at the same time for multiple instructions, and many don’t even have a specific set of bits for each register: they just rename and move them around as time passes to allow that parallelism from earlier to work properly.



  38. burbon ­ on September 20, 2019 at 9:07 pm

    these snaps are making my fingers hurt…



  39. Deeptadeep Roy on September 20, 2019 at 9:07 pm

    very well explained… definitely better than my microprocessor book… got myexam tomorrow… this definitely helped



  40. VidarW on September 20, 2019 at 9:08 pm

    Great video. Great snapping.



  41. Martina Drums on September 20, 2019 at 9:10 pm

    All of that so people can watch porn.



  42. Mitch Connor on September 20, 2019 at 9:11 pm

    the finger snapping made me uncomfortable.



  43. Ren Kelb-Lancaster on September 20, 2019 at 9:13 pm

    This is crazy I can’t believe my laptops so hardworking



  44. Acheron Hades on September 20, 2019 at 9:16 pm

    love that ublock origin in the dashlane ad!



  45. Anders Struck on September 20, 2019 at 9:17 pm

    Good thing you didn’t include pipelining, multi-layer caches or different architectures (register to register vs register to mem, etc)



  46. Dr Logiq on September 20, 2019 at 9:17 pm

    What’s my computer actually doing? Well, Tom… most of the time it’s just doing whatever it feels like, which is almost never what I need it to be doing! Blummin’ Windows 10 _mumble mumble_ "Don’t turn off your computer" _mumble_ …
    This is a great explanation, nice and concise 🙂



  47. Dojel Notmyrealname on September 20, 2019 at 9:18 pm

    Wouldn’t the fetch/decode/execute be happening simultaneously? Most CPU’s are pipelined like that in my understanding.



  48. SM23 on September 20, 2019 at 9:18 pm

    Each one of his snaps were so impressive the shockwave came through my phone and ended the life of 10 of my brain cells



  49. Arfnudaniack Blue on September 20, 2019 at 9:19 pm

    And a system is only as good as the person in charge of designing it.



  50. michael wittmann on September 20, 2019 at 9:19 pm

    6:19 JAVA ENTERS CHAT