• Jo Miran@lemmy.ml
    link
    fedilink
    arrow-up
    8
    arrow-down
    1
    ·
    1 month ago

    In college back in 1991. Also had to do PASCAL and FORTRAN but thankfully those two were in a single course.

    • expatriado@lemmy.world
      link
      fedilink
      arrow-up
      12
      ·
      1 month ago

      I also took PASCAL in the 90s, but it is considered a high level language, and writes similarly to other high lvl languages, assembly has a very different syntax

      • Jo Miran@lemmy.ml
        link
        fedilink
        arrow-up
        3
        ·
        1 month ago

        Oh, I know. I meant that we had to take courses on older languages as part of the curriculum. That was a funky little college program. The oddest experience for me was taking Python back in the day as the “new thing” then not seeing it again until it absolutely exploded ~10 years ago. That program is also why I ended up playing with Linux so early on. The professors truly seemed to have a passion for emerging technologies while not wanting anyone to forget what came before. Thankfully, no punch cards.

      • thejml@lemm.ee
        link
        fedilink
        English
        arrow-up
        2
        ·
        1 month ago

        We used turbo pascal in school in the early 90’s. And it had assembly blocks… which I used copious amounts of because it was the only way to make the IBM PS/1’s do useful graphics.

  • davel [he/him]@lemmy.ml
    link
    fedilink
    English
    arrow-up
    50
    arrow-down
    1
    ·
    1 month ago

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

  • fuy@lemmy.ml
    link
    fedilink
    arrow-up
    3
    ·
    1 month ago

    For a university assignment, I built a compiler for x86; I cheated a bit by relying on LLVM, but it gave me a better understanding of the architecture. I also developed emulators for the NES (Ricoh 2A03) and RISC-V (RV32I) as a hobby. For the latter, I implemented it in FPGA.

  • jaybone@lemmy.world
    link
    fedilink
    arrow-up
    29
    ·
    1 month 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.

    • CanadaPlus@lemmy.sdf.org
      link
      fedilink
      arrow-up
      15
      ·
      1 month ago

      Which target did you use? Having to learn even a fraction of modern x86 would be ridiculous, but SPARC or something could be good to know, just to reduce the “magic box” effect.

        • trolololol@lemmy.world
          link
          fedilink
          arrow-up
          4
          ·
          1 month ago

          I learned mips as graduate. In undergrad had to build with logic gates for things like 2 digit decimal counter and my architecture classes were diagram blocks for a simple CPU. But by that time we knew how to do moderate complexity circuits in VHDL simulation, and we had to make a simple VHDL circuit run for real in FPGA.

      • trolololol@lemmy.world
        link
        fedilink
        arrow-up
        5
        ·
        1 month ago

        I had to learn assembly but was one topic of many we handled in architecture. Like one question of one exam. That was one of the toughest professors we had, class was about 2001

    • Cethin@lemmy.zip
      link
      fedilink
      English
      arrow-up
      3
      ·
      edit-2
      1 month ago

      I think the university I went to phased out the EE requirements the year after me. Honestly, I think it should be required. Understanding how the computer “thinks” is such an important skill.

    • luciferofastora@lemmy.zip
      cake
      link
      fedilink
      arrow-up
      2
      ·
      edit-2
      1 month ago

      I attended two different Bachelor’s courses, one with a very technical (2016-2018) and one with a more high level focus (2018-2023). The first did have a class where we learned how to go from logic gates to a full ALU as well as some actual EE classes, but I didn’t go far enough or memorise the list of classes to remember whether Assembly would have become a thing. We learned programming with first Processing, then C and C++.

      The second had C as an elective course, and that was as technical and low-level as it ever got.

  • MyNameIsRichard@lemmy.ml
    link
    fedilink
    arrow-up
    6
    ·
    1 month ago

    Only on the VIC20 and Atari STe. On the VIC20 you had to write the assembler, manually convert it to machine code and enter that into the computer. There was a cartridge with an assembler, debugger and an extra 3.5Kb memory for it but I never got one.

    • stanka@lemmy.ml
      link
      fedilink
      arrow-up
      2
      ·
      1 month ago

      Vic 20 was my first. I watched my dad struggle with and eventually give up on assembly. Something-something and the microbots. I was fearful of it until I took Assembly at Uni. That 2nd/3rd year class was where the final puzzle piece of how computers work fell in place for me.

      My first job was writing assembly tests for a DSP hardware design team. Fell in love. Never looked back.

  • r00ty@kbin.life
    link
    fedilink
    arrow-up
    2
    ·
    1 month ago

    I used to write z80 asm without an assembler back when I was a LOT younger. The ZX spectrum manual I had, had the full instruction list with the byte values.

    I think it was oddly easier than some higher level languages for some tasks.

    But, making changes was an utter nightmare.

  • JoYo@lemmy.ml
    link
    fedilink
    English
    arrow-up
    80
    arrow-down
    7
    ·
    1 month 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.

  • AFK BRB Chocolate@lemmy.world
    link
    fedilink
    English
    arrow-up
    8
    ·
    1 month ago

    I had an assembly class in college. I didn’t love of at all. Got my first job after graduating and it was writing space shuttle engine control software, which was in assembly. I was kind of surprised at how fast it became natural after dealing with it full time. Still, it felt luxurious when we upgraded the controller and could do the software in C.

      • Fonzie!@ttrpg.network
        link
        fedilink
        arrow-up
        5
        ·
        edit-2
        1 month ago

        You dropped this \

        Short explanation: Type ¯\\\_(ツ)\_/¯ to see ¯\_(ツ)_/¯.

        Long expanation: Lemmy supports formatting, like _italic_ becomes italic. To stop this from happening, you can put a \ before it like \_; the \ isn’t shown. This is why ¯\_(ツ)_/¯ becomes ¯_(ツ)_/¯. To show a \ you need an additional \ like so: \\, and to make sure _ is shown and not turned into italic, it too needs \. This is why ¯\\\_(ツ)\_/¯ becomes ¯\_(ツ)_/¯

        • AnUnusualRelic@lemmy.world
          link
          fedilink
          arrow-up
          2
          ·
          1 month ago

          The backslash is known as an escape character in this context, because it removes (escapes) the special meaning of the following character.

          It’s also used that way in most Unix shells.

          • Fonzie!@ttrpg.network
            link
            fedilink
            arrow-up
            5
            ·
            edit-2
            1 month ago
            global _main
                extern  _GetStdHandle@4
                extern  _WriteFile@20
                extern  _ExitProcess@4
            
                section .text
            _main:
                ; DWORD  bytes;    
                mov     ebp, esp
                sub     esp, 4
            
                ; hStdOut = GetstdHandle( STD_OUTPUT_HANDLE)
                push    -11
                call    _GetStdHandle@4
                mov     ebx, eax    
            
                ; WriteFile( hstdOut, message, length(message), &bytes, 0);
                push    0
                lea     eax, [ebp-4]
                push    eax
                push    (message_end - message)
                push    message
                push    ebx
                call    _WriteFile@20
            
                ; ExitProcess(0)
                push    0
                call    _ExitProcess@4
            
                ; never here
                hlt
            message:
                db      '¯\\\_(ツ)\_/¯', 10
            message_end:
            
            • Lightscription@lemmy.world
              link
              fedilink
              arrow-up
              1
              ·
              edit-2
              1 month ago

              Do you want to show us what that looks like in assembly, ASCII from machine code? …ha, ha, ha, no!

              Depends on the device, I know. Such a pain without the higher level languages.

              What would it look like for ARM android touch screens? Just for one character…

              But if some characters go missing or are exchanged for others for no discernable reason, then might that be an exploit on a EC or assembly level?

        • ulterno@lemmy.kde.social
          link
          fedilink
          English
          arrow-up
          2
          ·
          edit-2
          1 month ago

          Alternatively, you can just use the `` enclosure, used for single line code.
          That is a “grave accent” or a “backtick”, the key you will find on the left of the ‘1’ key and under the ‘Esc’ key on a standard (ISO, maybe) 104/105 key qwerty keyboard.

          ¯\_(ツ)_/¯

  • HStone32@lemmy.world
    link
    fedilink
    arrow-up
    11
    arrow-down
    1
    ·
    1 month 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.

    • UNY0N@lemmy.world
      link
      fedilink
      arrow-up
      6
      ·
      1 month ago

      I don’t think accuracy was the goal, it is a joke not a dissertation. It’s more about how it feels to try a language like assembly after working with higher-level languages.

  • LavenderDay3544@lemmy.world
    link
    fedilink
    arrow-up
    11
    ·
    1 month 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.

  • Skull giver@popplesburger.hilciferous.nl
    link
    fedilink
    arrow-up
    46
    arrow-down
    1
    ·
    edit-2
    1 month 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.

    • CanadaPlus@lemmy.sdf.org
      link
      fedilink
      arrow-up
      6
      ·
      1 month 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.

      • Skull giver@popplesburger.hilciferous.nl
        link
        fedilink
        English
        arrow-up
        10
        ·
        1 month ago

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

        I think that’s true for just about any programming languages, though the program you’re “compiling” is a human understanding of what you’re trying to accomplish. Things like val bar = foo.let { it.widget?.frub() ?: FrubFactory::defaultFrub(it) } don’t come naturally to the human mind, you’re already working through the logic required before you start typing.

        As for the x86 instruction count: you don’t need to know all of them. For instance, here’s a quick graph of all of the instructions in systemctl on my system:

        With the top 15 or maybe to 25 of these instructions, you can probably write any program you can think of, and what’s missing will probably be easily found (just search for “multiply” or “divide”). You don’t need to know punpckldq to write a program.

        • luciferofastora@lemmy.zip
          cake
          link
          fedilink
          arrow-up
          1
          ·
          1 month 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.

          • That’s Kotlin. Mostly used for programming for the JVM, though it compiles to native code as well these days. Very interesting for cross platform app development, although I rarely do that these days.

            I think Swift has a similar syntax, but it doesn’t do some of the less obvious Kotlin tricks as far as I’m aware.

            • luciferofastora@lemmy.zip
              cake
              link
              fedilink
              arrow-up
              1
              ·
              1 month ago

              I’ve heard of Kotlin in the context of Android apps, but never actually used or learned it. I did one mobile app dev project with Java in Android Studio, but never had any formal classes on it either and just learned as I went (the result was shit, but we got a decent grade for being able to evaluate the difficulties and shortcomings and point out learnings).

        • CanadaPlus@lemmy.sdf.org
          link
          fedilink
          arrow-up
          1
          ·
          edit-2
          1 month 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.

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

            I believe this guide can get you started pretty quickly to get the basics down. There are tons of guides online, but most of them will give you the basics (“this is how to find a prime number”) and then leave you on your own. Once you know how instructions, calling conventions, and system calls work, the rest of assembly programming is just reading documentation or Googling “how do I X in assembly”.

            What can help is using websites like godbolt.org to write simple C programs and looking at the compiled output. Look up instructions you don’t recognize and make sure you don’t enable optimizations, unless you want to deal with atrocities like VGF2P8AFFINEINVQB.

            If you don’t mind getting started with old assembly, there are also more comprehensive guides for MS-DOS and old Windows that mostly involve 16 bit and 32 bit programs programming. 64 bit programming is different (uses more registers to pass variables, floating point support is guaranteed, etc.) but there aren’t as many good books on the topic anymore now that it’s become a niche.

            I think there are quite a few guides out there for ARM these days, if you have something like a Raspberry Pi or an emulator you can also learn ARM assembly (which has fewer supported weird instructions, but also a tonne of weird stuff).

            If you want to go deep, you can also check Ben Eater’s youtube channel where he shows step by step how an 8 bit computer on a breadboard works, how instructions relate to memory, and all that. With some intuition from that, learning amd64 assembly may be a lot easier than going from normal programming languages to assembly.

            Edit: to get into understanding assembly programming, [Human Resource Machine[(https://store.steampowered.com/app/375820/Human_Resource_Machine/) will explain the concepts of assembly programming without ever overtly explaining the concepts. Plus, it’s a fun puzzle game.

    • leisesprecher@feddit.org
      link
      fedilink
      arrow-up
      19
      ·
      1 month 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.

      • Skull giver@popplesburger.hilciferous.nl
        link
        fedilink
        English
        arrow-up
        12
        ·
        1 month ago

        Unless you’re developing an OS or something, you’ll probably be using the C standard library and maybe a bunch of other libraries provided by most distros. Just because you’re doing assembly doesn’t mean you need to program syscalls manually.

        Modern assemblers also come with plenty of macros to prevent common mistakes and provide common methods. For instance. NASM comes with things like %strcat to do string concatenation.

        I suppose the lack of compiler warnings can be a challenge, but most low-level compilers don’t exactly provide guidance for when you design your program wrong.

        No doubt Assembly is harder than Java or Python, but compared to languages like C, I don’t think it’s as hard as people pretend to it to be.

    • luciferofastora@lemmy.zip
      cake
      link
      fedilink
      arrow-up
      1
      ·
      1 month 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.

      • Modern decompilers like the one packaged with Ghidra helps a lot for intuiting how instructions work. Unfortunately, a lot of video game code is obfuscated, so you’re probably more likely to run into weird instructions, but OK the other hand you’ll learn what they do faster than when you rarely encounter them.

        If you want to write amd64 code, you can get away with mastering just one instruction, and that’s the kind of tomfoolery that obfuscated programs will try to use to make your life harder.