• davel@lemmy.ml
    link
    fedilink
    English
    arrow-up
    3
    ·
    5 months ago

    Assembly code is for writing C compilers, and C compilers are for writing Lisp interpreters.

        • henfredemars@infosec.pub
          link
          fedilink
          English
          arrow-up
          2
          ·
          edit-2
          5 months ago

          There’s actually good reasons for this design. It’s easy to write a Scheme interpreter in assembly, but it’s hard to write a C compiler in assembly that handles everything correctly. Much rather write it in higher level language if possible and Scheme lowers the bar to getting there, so you can get away from using assembly as quickly as possible. Or you can copy somebody else’s Scheme implementation of a C compiler because now you’re platform independent.

          Then you can write your C compiler in C (or steal a better compiler already written in C) and close the loop. For your final step, you use the C compiler to compile itself.

      • davel@lemmy.ml
        link
        fedilink
        English
        arrow-up
        2
        ·
        edit-2
        5 months ago

        I never did get very far with the TRS-80 Editor Assembler, but that was my first exposure to such things.

        I also remember the BASIC code for the Dancing Daemon which was replete with PEEKs and POKEs, such that much of it was written in machine code.

        • RestrictedAccount@lemmy.world
          link
          fedilink
          arrow-up
          2
          ·
          13 days ago

          Exactly how we did it too. We created the editor/assembler that peeked to see what was there and display it in Assembly, Hexadecimal, and ASCII.

          You could edit whichever version you wanted and it would Poke it into RAM.

          You could also save swaths to a file.

  • LavenderDay3544@lemmy.world
    link
    fedilink
    arrow-up
    2
    ·
    5 months ago

    OS and embedded dev here. I use assembly all the time. I’ve even worked on firmware that was entirely in assembly of strict requirements that couldn’t be met in C.

    Also even machine code hides a lot about how the underlying machine works so if you really want to do computing from scratch you really do hate to invent the universe because there’s abstractions all the way up the hardware stack just like there is in software.

  • jaybone@lemmy.world
    link
    fedilink
    arrow-up
    2
    ·
    5 months ago

    Assembly used to be a required course for CS undergrads in the 90s. Is that no longer the case?

    Also we had to take something called Computer Architecture, which was like an EE class designing circuits with gates and shit.

  • Cethin@lemmy.zip
    link
    fedilink
    English
    arrow-up
    2
    ·
    5 months ago

    Anyone who thinks OP asking about Assembly with this meme should play the game Turing Complete. It’s great. You have to design a computer all the way from the most basic logic gates (I think you only get a NAND gate to start), designing an ALU and CPU, creating your own machine language, and writing your own programs in the language you designed, and it’s all simulated the whole time. Machine language is pretty advanced as far as things go.

  • finley@lemm.ee
    link
    fedilink
    English
    arrow-up
    1
    ·
    5 months ago

    I remember watching assembly demos in the early-mid 90s and thinking those guys were wizards

  • JoYo 🇺🇸@lemmy.ml
    link
    fedilink
    English
    arrow-up
    1
    ·
    5 months ago

    I get the feeling that all of these assembly jokes are justifications to avoid learning assembly.

    You can still make syscalls in assembly. Assembly isnt magic. It isn’t starting from the creation of matter and energy, it’s just very specific code.

  • geekworking@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    5 months ago

    Look at mister fancy pants with and assembler.

    How about entering straight opcode, operand with only a hex keypad and two pairs of 7 segment LEDs. You can only see one set of numbers at a time. You had to write it out on paper to be able to keep track and count positions so you don’t use your spot.

    I had to do this as a project in school. Two 8088 units that we breadboarded to a UART that we used to drive a fiber optic link to communicate with each other with a basic protocol. All descrete components hand wired and coded.

    It made you tie all of skills together into a full system of hardware and software.

  • darklamer@lemmy.dbzer0.com
    link
    fedilink
    arrow-up
    1
    ·
    5 months ago

    It’s now been 18 years since the last time an employer paid me to write assembly, but it’s only been a year or so since the last time I had to read assembly at work (in order to verify what the compiler really was doing).

  • HStone32@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    5 months ago

    Not exactly accurate, I think. Even machine language is bound by the CPU’s architecture. You can’t do anything in machine language that wasn’t specifically provided for by the CPU architects.

    It would be more accurate to say it’s like creating a new universe using all the same laws of physics, thermodynamics, cosmology, ethics, etc as our existing universe.

  • Skull giver@popplesburger.hilciferous.nl
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    5 months ago

    Assembly isn’t that hard. It’s the same imperative programming, but more verbose, more work, and more random names and patterns to remember. If you can understand “x += 3 is the same as x = x + 3”, you can understand how the add instruction works.

    I wouldn’t be able to write Rollercoaster Tycoon in assembly because keeping track of all that code in assembly files must be hell, but people pretending like you need to be some kind of wizard to write assembly code are exaggerating.

    These days, you won’t be able to beat the compiler even if you wrote your code in assembly, maybe with the exception of bespoke SIMD algorithms. Writing assembly is something only kernel developers and microcontroller developers may need to do in their day to day life.

    Reading assembly is still a valuable skill, though, especially if you come anywhere near native code. What you think you wrote and what the CPU is actually trying to do may not be the same, and a small bit of manual debugging work can help you get started resolving crashes that make no sense whatsoever. No need to remember thousands of instructions either, 99% of assembly code is just variations of copying memory, checking equality and jumping anyway. Look up the weird assembly instructions your disassembler spits out, they’re documented very well.

    • leisesprecher@feddit.org
      link
      fedilink
      arrow-up
      1
      ·
      5 months ago

      Assembly is hard, because you need to understand your problem on multiple levels and get absolute zero guidance by compilers.

      Even C guides you a tiny bit and takes away some of the low level details, so you have more mental capacity to actually solve your problem.

      Oh, and you have a standard library. Assembly seems to involve solving everything yourself. No simple function call to truncate a string or turn a char array to uppercase.

    • CanadaPlus@lemmy.sdf.org
      link
      fedilink
      arrow-up
      0
      ·
      5 months ago

      I wouldn’t be able to write Rollercoaster Tycoon in assembly because keeping track of all that code in assembly files must be hell, but people pretending like you need to be some kind of wizard to write assembly code are exaggerating.

      Well, they’ve got a point for the bigger machine codes. Just the barebones specification for x86 is a doorstopper IIRC.

      From what I’ve heard, writing big stuff in assembly comes down to play-acting the compiler yourself on paper, essentially.

        • CanadaPlus@lemmy.sdf.org
          link
          fedilink
          arrow-up
          1
          ·
          edit-2
          5 months ago

          TIL. I had tried to understand it a bit, but felt lost pretty fast, and then eventually found out that’s because it’s huge. Is there a good intro to the basic instructions you’re aware of?

          By “play act the compiler” I mean a fairly elaborate system of written notes that significantly exceeds the size of the actual program. Like, it’s no wonder they started thinking about building machine compilers at that stage.

        • luciferofastora@lemmy.zip
          link
          fedilink
          arrow-up
          0
          ·
          5 months ago

          What language is your pseudocode example modeled after? It vaguely reminds me of some iOs App code I helped debug (Swift?) but I never really learned the language so much as eyeballed it with educated guesses, and even with the few things I double checked it has been a few years, so I have no clue what is or isn’t legal syntax anymore.

    • luciferofastora@lemmy.zip
      link
      fedilink
      arrow-up
      0
      ·
      5 months ago

      Having toyed with video game reverse engineering, I definitely feel like I ought to learn a bit more. I understand mov, pointers and registers, and I think there was some inc and add in the code I read to try to figure out base pointers and pointer paths (using Cheat Engine), but I think knowing some more would serve me well there.