CppCon 2016: Jason Turner “Rich Code for Tiny Computers: A Simple Commodore 64 Game in C++17”


Presentation Slides, PDFs, Source Code and other presenter materials are available at:

The Commodore 64 was released in 1982 and is the best selling computer model of all time. At 34 years old, even the most simple embedded processor today outperforms it. Join me on an exploration of how C++17 techniques can be utilized to write expressive, high performance, high level code for simple computers. Together we will create a game for this aging system.

You’ll leave the talk with a better understanding of what your compiler is capable of and be able to apply these ideas to create better code on modern systems.

Host of C++Weekly Co-host of CppCast Co-creator and maintainer of the embedded scripting language for C++, ChaiScript and author and curator of the forkable coding standards document I’m available for contracting and onsite training.

Videos Filmed & Edited by Bash Films:

Source: https://cyrrion.com
Read more all post Computer Technology : https://cyrrion.com/computer/
  1. 6502 is a brain of f14 tomcat jet fighter

  2. vbarr67 says

    This is brilliant !

  3. Richard Huber says

    Wow, amazing!

  4. Arjan van Wieringen says

    28:06 was amazing 🙂

  5. vAzzury says

    I love this talk

  6. MR YUP says

    bookmark: 25:28

  7. TheSulross says

    To me this is THE best C++ presentation in the post C++11 era. Have watched it twice. Entertaining, interesting (inspired use of retro-computing as a hook), and informative/educational in respect to C++ the language

  8. Koray YILMAZ says

    I just started to learn C++ and the video was amazing. Thanks.

  9. Paul Moore says

    the actual correct use of volatile !!

  10. i an says


  11. Rafał Tomasz Janik says

    Hi JT,

    please, just take a look on what David Holz did with his AcheronVM: https://www.youtube.com/watch?v=zdJnz6-d060

    For the note: it is a different (socially flood) person than: @DavidSHolz, he is aka "White Flame": http://forum.6502.org/viewtopic.php?f=1&t=2236

    IMHO: this could be the next step of your "x86->6502 reassembler", it could be truly LLVM semantics capable mid-ware

  12. Martin S. says

    Stupid? No, why would it be stupid. Doing something you enjoy, fancy, and take fun and pleasure in isn't stupid. Creation is never stupid.
    As for PowerPoint crashing: I must be the only person in the whole world who RARELY experience issues with Windows and Office…What are you all doing to your computer, ladies and gents!?

  13. tunca tunç says

    28:00 it's truly 👀 opening

  14. madcommodore says

    6502 compatible CPUs were the ARM CPUs of the late 70s/early 80s

  15. Martijn van Buul says

    I know this video is 3 years old, but I keep referring people to this video because it's doing such a great job at dispelling some misconceptions. Unfortunately, there are no closed captions available for this video, which prevents me from showing this video to a deaf co-worker.

    I know generating proper captions would be a mammoth undertaking, but I would appreciate it if the automatic captions for this video would be enabled. Thank you in advance.

  16. Roaming Adhocrat says

    15:00 wait – a function in an anon namespace is visible in `main`?

  17. Rohit Benake says

    Excellent presentation, It was like seeing magic how compiler can optimize code .

  18. bitsflip says

    this is amazing, is there a similar compiler explorer for java?

  19. Depth One DJ says

    Who else came to watch after hearing Bjarne reference this talk on Lex Fridman's AI podcast?

  20. David Julitz says

    Well done, this was eye Opening.

  21. 64jcl says

    A shame you dont show the C64 emulator running the code as well while you do the coding/testing.

  22. Ben Nguyen says

    Very cool! As an alternative to the online C++17/IDE by Matt Godbolt.org that was mentioned, there's a few others that may be help.. webminal, codechef, jdoodle, rextester, linuxcontainers, thinapps.org , tutorialspoint, ideone, remoteinterview.io , onlinegdb, repl.it, codepad.org, cpp.sh, leafo.net, PythonAnywhere

  23. Steffen Nilsen says

    27:15 im going to show this to anyone who complains that I overuse const

  24. MindGame Arcade says

    Extremely good presentation, near perfection

  25. Mlf Conv says

    How did you manage to translate the x86 asm code to 6502

  26. Wavem Studios says

    Great work Jason

  27. Tom Atkinson says

    Did they say the x86 has hardware sprites?

  28. WizardNumberNext says

    x86_64 have 16 registers and it would be impossible to use all of them on PC (it doesn't matter if it is Windows or Linux or something else, as it is physical architecture which eats up resources, not logical one
    i386 had 8, of which 6 were (sort of) general purpose
    this is NEITHER PowerPC (32) NOR SPARC (32 with banks or renaming (I am confused now, as I do not remember) plus each thread have full set of registers)

  29. M S says

    4:13 "No modern compilers officially support [the 6502 instruction set]"… um, no. Sorry, but I had to stop watching at this point.

  30. the Sanctuary says

    I want to be a master of C++.
    How long does it take?

  31. xlar54 says

    cc65. A modern C compiler for 8 bit machines including the 64

  32. Tamas Kalman says


  33. Cloeren Jackson says

    As a Commodore 64 and C++ programmer, I have only these questions:

    1. Show me the C++ source file.
    2. Show me the 6510 executable.

  34. Zoltán Halassy says

    19:07 assigning 'a' directly will not work. C64 uses PETSCII instead of ASCII, so a conversion table wil be needed. Also the video memory is a bit tricky, because it doesn't use PETSCII directly. 'a' is 0x61 in ASCII, but it would output only some bar on the screen. You'll need to write 1 to memory address 1024 to get an "A". See http://sta.c64.org/cbm64scr.html for details.

  35. Zhao Li says

    Exceptions in C++ seems a game breaker regarding the zero-overhead thing. You have to be very careful not to use any thing that might throw.

  36. corsairegg says

    It’s ridiculous . What’s the point of this video ? It’s slow as hell, how can you talk about efficiency ? All that for a pong …

  37. skilz8098 says

    And in a few weeks; Bethesda will have a Skyrim Port for the Commodore 64…

  38. Peter Cordes says

    386 has 8 general-purpose integer registers. Using the 8-bit partial registers instead of the full register for EAX-EDX, i.e. AL/AH, BL/BH, CL/CH, and DL/DH, you get a total of 12 GP registers. This still includes the stack pointer, which you shouldn't really count unless you're actually stashing it somewhere to use it for a variable value in a hot loop. (Normal compilers will never do this for you.)

    386 has segment registers, control registers, and other stuff, but you can't use those for arbitrary variables. And even if you could, you don't want to because they're slow to read/write and you can't use them as operands for ALU instructions. (Especially slow on modern x86 where you have fast L1d cache that makes local variables in memory not a disaster if store/reload isn't part of the critical path latency.)

    modern x86-64 still only has 16 integer registers, 16 xmm/ymm vector registers, and 8 MMX registers (or 8 x87 stack regs instead of MMX). Register renaming onto a large pool of physical registers doesn't help you avoid spill/reload if you need more values live than you have architectural registers to store them in. Moving data between different kinds of registers varies in efficiency, but always takes an instruction.

    This talk came up an a Stack Overflow question; I wrote an answer (https://stackoverflow.com/questions/49807965/how-to-know-an-assembly-code-is-using-ram/49809894#49809894) where the 2nd part addresses the point about registers in a bit more detail.

  39. MikeOnTheBox says

    Anyone has a good video that explains what is the overhead he is talking about 😛

  40. slap_my_hand says

    This is why i love C++.

Leave A Reply

Your email address will not be published.