• Possibly linux@lemmy.zip
    link
    fedilink
    English
    arrow-up
    3
    ·
    14 hours ago

    My simple assembly program can rum circles around compilers. As long as something is small it is possible to optimize better than a C compiler.

    • gens@programming.dev
      link
      fedilink
      English
      arrow-up
      2
      arrow-down
      2
      ·
      12 hours ago

      Compilers have a lot of chalenges to even compile, let alone optimize. Just register allocation alone is a big problem. An inherent problem is that the compiler does not know what the program is supposed to do. Humans still write better assembly then compilers.

      The one down arrow on the guy you are responding to is from me, just so everybody knows.

      • amos@lemmy.zip
        link
        fedilink
        English
        arrow-up
        2
        ·
        9 hours ago

        This is just wrong, the compiler (and linker) knows exactly what the program does as it has the ENTIRE source code available. Compilers have been so good the last 20 years that it is quite hard to write things faster in assembly/machine code.

        One of the harder parts about assembly is keeping track of which registers a subroutine uses and which one is available, as the program grows larger you might be forced to push/pop to the stack all the time. Inlining code is also difficult in assembler, the compiler is quite adept at that.

        It might have been true up until the 90s, but then compilers started getting so good (Watcom) there was rarely any point to write assembler code, unless there was some extremely hardware specific thing that needed to be done

        • Possibly linux@lemmy.zip
          link
          fedilink
          English
          arrow-up
          1
          ·
          3 hours ago

          The last time I wrote assembly I was making a make shift sound card thing with an Arduino. I hooked a speaker up to the GPIO and was toggling the bit