Some Assembly Required: An approachable introduction to assembly

2022-06-2815:42587125github.com

An approachable introduction to assembly. Contribute to hackclub/some-assembly-required development by creating an account on GitHub.


Since forever ago, I've wanted to try writing assembly, even if just to understand why the Rollercoaster Tycoon creator would write 99% of the game in it. To be fair, even after all of this, I still don't understand why they did that.

Embarking on this quest, I quickly found a lot of scattered and difficult to understand resources. It took compiling a bunch of different materials together to come to a high level understanding of what's happening in my computer.

I wanted to write down my learnings for those who are new to this part of their computer (like me!), including working code examples. This is by no means an exhaustive guide, but instead serves as an approachable introduction to assembly.

Going through this guide takes as little as 30 minutes, but you can also spend a few hours going through it if you want to delve into the code examples.

Enjoy!


What's inside? →


Made with love by Hack Club


Page 2


Since forever ago, I've wanted to try writing assembly, even if just to understand why the Rollercoaster Tycoon creator would write 99% of the game in it. To be fair, even after all of this, I still don't understand why they did that.

Embarking on this quest, I quickly found a lot of scattered and difficult to understand resources. It took compiling a bunch of different materials together to come to a high level understanding of what's happening in my computer.

I wanted to write down my learnings for those who are new to this part of their computer (like me!), including working code examples. This is by no means an exhaustive guide, but instead serves as an approachable introduction to assembly.

Going through this guide takes as little as 30 minutes, but you can also spend a few hours going through it if you want to delve into the code examples.

Enjoy!


What's inside? →


Made with love by Hack Club


Read the original article

Comments

  • By jessicard 2022-06-2816:267 reply

    It was so fun working with Hack Clubbers on this project!

    Hack Club is a group of teenagers from all over the world, and we decided to learn assembly together from scratch and see what happened.

    We ended up making this guide as we learned, since a lot of the resources we were working with weren't the easiest to parse.

    Happy to answer any questions :)

    • By jamal-kumar 2022-06-2819:042 reply

      I gotta say, it's pretty cool how nice young people have it these days with what's available in terms of stuff like Hack Club. The whole scene has become WAY more inclusive as a result of things like that, and the acerbic hacker archetype who snaps at you for not knowing things the way they do is so dead as a result - that to me is great, I don't miss those guys and their gatekeeping.

      If you want to check out some fun assembly code in a larger program, I suggest checking out the leaked furby source code. [1] The assembly for the lunar landing modules from the 1960s is also pretty wild [2]

      [1] https://www.seanriddle.com/furbysource.pdf

      [2] https://github.com/chrislgarry/Apollo-11

      • By deamanto 2022-06-290:291 reply

        You just brought a random memory from uni where a small group of people wanted to get others interested in cybersecurity and did a weekly session on teaching others.. First meeting had a huge turnout and I expected future meetings to consist of learning through teaching us concepts with some practical tasks, except it became a session of just a few people talking to each other using security terminology that no one understood because it was meant to be introductory.

        • By jamal-kumar 2022-06-291:081 reply

          I think the big thing is that pedagogy itself is a hugely broad subject and especially skill that you might just dunning-kruger yourself hard on thinking you're good at. I always thought school would have been a lot more engaging if the teachers were actually paid enough to give a damn, they have a tremendously undervalued skill set and we put our kids in the trust of them while cutting their salaries every other year or so? What the hell is the motivation at that point?

          I really cut my teeth on programming getting yelled at a lot by a guy in German about meeting OpenBSD kodequalität and that kind of sucked, to be honest I was at a point one time after enough workplace toxicity in IT (Getting sexually harassed by a boss at a megacorp guaranteed I don't ever want to work at one of those places again especially) where I figured I'd rather be a bee farmer or something instead. There's really no necessity for that kind of attitude but some people have been going around acting like this is the way things are in IT so you better suck it up and get used to it, especially when there's a lot of money on the line, and it's definitely true that a LOT of people could learn better on how to write code that doesn't get hacked or crashes, because often there isn't just tons of money on the line but people's health, safety, and wellness - but if the health, safety and wellness of the person writing the code is affected by some insanely stupid cultural assumption that's existed in this industry, then how good are they ultimately going to be at it in their code? It was kind of funny watching Linus Torvalds explode at people for these things back in the day, but in hindsight I'm very glad he took some time off to become a more emotionally and socially mature person for the good of the project. I don't want to work in an industry where it's just smelly angry brogrammers with maturity issues, the more that changes the better and I think I see it happening quite rapidly.

          What these kids are doing is a huge step in the right direction, I applaud them. They seem to get what the past half century or so of people seem to have been kind of embarrassingly bad at and that's just being decent human beings with each other.

          • By zozbot234 2022-06-295:271 reply

            > It was kind of funny watching Linus Torvalds explode at people for these things back in the day, but in hindsight I'm very glad he took some time off to become a more emotionally and socially mature person for the good of the project.

            It's ironic that you say this while complaining about bad attitudes in the OpenBSD community. When it comes to obnoxious attitudes, Linus Torvalds is a nobody compared to Theo de Raadt. BTW, Linus is now pushing for gradual adoption of Rust in the kernel, which would turn many issues of "writing code that doesn't crash" (though not all) into things that a compiler can check for you. That community is generally pretty relaxed and cooperative towards newcomers, due to a shared understanding that there's no point getting angry about code that won't even pass that check.

            • By jamal-kumar 2022-06-2912:57

              I haven't seen that out of Theo for a really long time, either. Most OpenBSD dev these days has seemed to move on from the beer hackathons and into academic/corporate dev for sure. It's all growing up. Most of my reference is relevant to +10 years ago. I like the OpenBSD scene these days a lot actually, there's a ton to learn from them. They are a lot more of a nice community than their old legacy might have you believing.

              I like the Redox crowd and other people who are trying their hand at pure rust kernel+userland as well, they are doing some very interesting things that probably should have been done a long time ago - it's just not exactly easy to move on from C/C++ heterodoxy when it's such a complex thing to even fathom entirely replacing. Like when your whole kernel is in a different ABI you need to replace the whole userland, too... Not exactly small potatoes. Very admirable to just go ahead and do it.

      • By jessicard 2022-06-2819:081 reply

        It's so amazing, I completely agree! It's really inspiring honestly.

        And... OH MY GOD FURBY SOURCECODE THIS IS AWESOME THANK YOU

        • By jamal-kumar 2022-06-2819:271 reply

          Glad you find joy in it. It's 6502 assembly, in case you were wondering - Though the chip was a low-voltage 6502-alike called the Sunplus.

          Those things were pretty crazy when they glitched out, my friend had one which would get thrown in into a loop where it just open and close its eyes looking from side to side going WEAOWEAOWEAOWEAO like some kind of possessed demon until you took the batteries out.

          Oh yeah, obligatory picture of what I'm pretty sure is Margaret Hamilton standing next to a printout of that lunar lander code [1]

          [1] https://www.nasa.gov/sites/default/files/thumbnails/image/ma...

    • By mixedmath 2022-06-2817:361 reply

      This is really wonderful. And I like how simple and clean the pages look, even through markdown+github. Cheers.

      • By jessicard 2022-06-2817:52

        Thank you so much!! We really wanted to try to make it live alongside the code examples in GitHub, but still feel almost e-book like. We definitely hacked around the GH Markdown a bit to achieve this. Thanks for noticing!

    • By djmips 2022-06-2817:331 reply

      I only skimmed but it's looking good so far! Would you like feedback or suggestions? And if so, using git issues or other? Thanks!

      • By jessicard 2022-06-2817:37

        Issues and PRs are preferred - thank you so much for reading! :D

    • By neverartful 2022-06-2817:061 reply

      Bravo! Great to see stuff like this! Hopefully you made some new friends too.

      • By jessicard 2022-06-2818:14

        Thank you so much! It was so fun working with the teenagers in the community.

    • By throwaway0x7E6 2022-06-2819:541 reply

      >Happy to answer any questions :)

      what happens when a member hits 20?

      • By tomcam 2022-06-294:24

        They’re taken away to be… replaced by someone more fit, capable, and attractive.

    • By dingosity 2022-06-2819:02

      Echoing other's comments... I'm happy you did this and hope to see more content like it!

    • By joe__f 2022-06-2820:18

      Hey that's awesome! When I was a teenager I learnt C++ so I could code on a Zelda fan game engine. Why did you guys want to learn assembly?

  • By kup0 2022-06-2817:332 reply

    My favorite part is the heavily commented code examples. Those are much more useful for increasing my understanding than most other resources. To me, that level of information density just works better for my brain than articles or sites that try to explain things.

    Something about being _in the code_ while stepping through lines one by one with explanations is just so much easier to follow. I wish more learning resources took this approach.

    • By folkhack 2022-06-2818:18

      > Something about being _in the code_ while stepping through lines one by one with explanations is just so much easier to follow.

      I just go straight to the code. Same with SO - I'm not reading words, I'm reading code. Even with zero familiarity I find code is easier to read with inline docs vs. digging through someone's word salad. Truth is most of us aren't great technical writers.

      That being said I did skim the content for this resource and found it to be pretty to the point and clear-cut. Even the metaphors and extra information were applicable to providing a good primer. I wish more devs would write with the same succinct technical clarity as this and maybe I wouldn't skip the word salad as much ha

    • By jessicard 2022-06-2817:491 reply

      Ahhhh thank you for mentioning this! This was _really_ important to us, because it was hard for us to find real code examples that worked, and when we did, they were hard to parse.

      It's also why we put it in GitHub, so it could live alongside the code examples :)

      • By kup0 2022-06-2819:311 reply

        Yes! I think two things with code examples have a significant impact, at least for me personally- 1) the examples are complete and work and 2) line-by-line explanation.

        A lot of resources show a snippet of code, followed by an impenetrable paragraph that tries to explain multiple concepts from the snippet all at once. Maybe that works for others, but for me it makes it impossible to parse and overwhelms me, so nothing sticks.

        • By NationOfJoe 2022-06-2823:56

          This 100%, i often find alot of blogs and documentation really difficult to follow because they just show a snippet and no where in the doc does it cover the prerequisites to get to that point.

          I get you don't want to clutter the point, but start with a link to working code or an article that explains the basics.

          I would be happy if more articles/docs explained how this code is being called.

  • By mhh__ 2022-06-2816:512 reply

    I basically learned C++ and assembly programmer at the same time when I was 16 by just watching the output of gcc.godbolt.org (yes ok zoomer)

    • By dleslie 2022-06-2817:051 reply

      That's clever! I'll recommend that to my niece and daughters.

      • By mhh__ 2022-06-2817:221 reply

        They might end up as compiler devs. Be careful...

        • By himujjal 2022-06-2817:332 reply

          And write parsers and llvm glue code all day long.

          • By mhh__ 2022-06-2817:43

            Don't forget test runners

    • By danbolt 2022-06-2817:52

      That's incredibly cool to hear! I'm really excited about the upcoming generation of programmers empowered by the tools they have with them.

HackerNews