I don’t need something practical. I just need something fun to keep me motivated.

  • orclev@lemmy.world
    link
    fedilink
    arrow-up
    2
    ·
    3 days ago

    So, there’s not a great answer to that. The big problem is that x86 assembly is painful because the x86 instruction set is a weedy overgrown mess due to being built on top of literal decades of cruft. Even a CPU made today starts off by booting up pretending to be an 8086 processor, a 16 bit CPU from 1978. To get to a “modern” operating mode you need to walk through a series of configuration steps to get the CPU into the correct mode, but all those modes and configs add a lot of noise when trying to understand x86 assembly. For that reason it’s probably a good idea to start by not learning x86, but instead the far more minimal and sane ARM assembly.

    The problem of course is that there’s like a 99% chance that the system you’re going to be working on when learning assembly is an x86 system not an ARM one. So now you need two more things, you need an assembly cross-compiler to use your x86 system to build an ARM executable, and you need an ARM emulator to run it. Personally I’d install LLVM (specifically clang) and start by writing a small C wrapper with some inline assembly in it. For running it I’d use QEMU and a Linux ARM image (maybe one of the raspberry pi distros).

    Finally allow me to introduce you to one of the absolute coolest tools out there godbolt compiler explorer. Godbolt allows you to take a snippet of code written in one of dozens of supported languages and see the assembly instructions that various compilers would produce from that code. This is a great way to learn more about not just assembly, but any of the supported languages and is also an invaluable tool for doing fine grained optimizations.

    • ageedizzle@piefed.caOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      3 days ago

      Even a CPU made today starts off by booting up pretending to be an 8086 processor, a 16 bit CPU from 1978.

      That’s fascinating.

      The godbolt compiler looks like it would be very useful for learning programming. Reminds me of this website even though it’s not quite the same because it’s a game.

      Thanks!