Live data from Hacker News

Some Assembly Required: An approachable introduction to assembly

github.com

121–130 of 131 posts

Re: Some Assembly Required: An approachable introduction to assembly

#122

Earlier quoted context omitted.

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 u…

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 yea…

> 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.

Re: Some Assembly Required: An approachable introduction to assembly

#124
post #60
post #14

Assembly language is actually simple stuff. You just need to read the datasheet. No difficult type systems to deal with. In the old days programming assembly language was nasty because one mistake could mean your computer had to be rebooted and you lost your work. Not anymore.

It's simple in the same way C is simple. Sure it's a very small language with pretty straight forward commands, but once you try doing anything of significance it becomes extremely complicated and it's easy to do nasty things with it.

It may be simple but that simplicity is its downfall. How many databases, compilers, modern games. OOP classes or even file handling routines do you see in assembler? Few or none at all. Writing assembly language is slow and painstaking work. You can easily get 10x the productivity by switching to C or even better in higher languages. Games were written in assembler back then because Basic was too slow. And C compilers were only starting to appear on personal computers from the late 1980s.

Writing an assembler for 8-bit CPUS like 6502/Z80 was doable; I wrote a 6502 cross assembler (in Z80) so a Z80 development machine could output 6502 in 1985. It got harder with 8086 and 68000 chips.

Re: Some Assembly Required: An approachable introduction to assembly

#125

Earlier quoted context omitted.

> I succeeded only because my teenage self somehow pulled off a phone call to Motorola sales where I claimed to be an engineer "evaluating" the 6809 CPU and they sent me the manual and a quick reference card. lol that is such a nice story

Moto and the other large semi vendors back then had data departments that would send you any datasheet on request. My teenage self made many such requests, but in writing in order to not reval my age (in snail mail, everyone's an adult).

Yes. Around 1994 when I was in college, a friend and I were into video graphics and Intel had a video digitizer chip. We wrote to Intel (snailmail) asking for the data/spec sheet and about two months later, we received a packet with about 120 pages of the data/spec sheet.

Re: Some Assembly Required: An approachable introduction to assembly

#126

Earlier quoted context omitted.

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 yea…

> 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 Raad…

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.

Re: Some Assembly Required: An approachable introduction to assembly

#127
post #14

Assembly language is actually simple stuff. You just need to read the datasheet. No difficult type systems to deal with. In the old days programming assembly language was nasty because one mistake could mean your computer had to be rebooted and you lost your work. Not anymore.

I taught myself x86 assembly from a book as a pre-internet teenager. My first .COM printed exactly what it was supposed to on the screen. Then it printed a bunch of random junk and my computer rebooted. This happened every single time I ran the executable. Eventually I actually read the first chapter properly and added MOV AH,4CH / MOV AL,0 / INT 21H. When my executable returned to the DOS prompt this time after runn…

What did cause the reboot? Is this some kind of DOS watchdog that reboots the system because your program didn't exit gracefully?

Re: Some Assembly Required: An approachable introduction to assembly

#128
post #14

Assembly language is actually simple stuff. You just need to read the datasheet. No difficult type systems to deal with. In the old days programming assembly language was nasty because one mistake could mean your computer had to be rebooted and you lost your work. Not anymore.

You still need to learn a lot of stuff. Problem is that it isn't portable. You have differences in architectures but most are quite similar if your goal is to make a program work instead of it being efficient for which you need deep knowledge about an architecture and its quirks. A few different mnemonic and register names is the far smaller problem.

But you also need to know about calling conventions of your operating system if you want to do any form of system call, which you very likely want to. Which registers supply arguments, which registers have to be saved, addresses of system functions which can change with OS or kernel version. You also need to learn what these function do. How would anyone know that writing a 48 into your accumulator and calling interrupt at address 80 opens a socket on Linux?

Thinking about this again makes assembly seem like a terrible, terrible idea...

To start with I would either recommend x86_64 for either Windows and Linux. I would prefer Linux here but I believe UEFI for example uses the Windows calling conventions, so taking a look at that might be practical. But these combinations usually offer the most learning helpers.

Usually you should only cause general protection faults at worst if you have something newer than a 386. But no guarantee...

Re: Some Assembly Required: An approachable introduction to assembly

#129
This is great!

As a developer who didn't learn via a scholastic setting, taking the time to sit down and learn a bit of assembly was something I see as a critical point in my career.

Starting with a high level scripting language, my brain had a hard time dealing with so much abstraction and taking what felt like a crazy amount of axioms as given.

I took a few months to sit down and go through the excellent book Programming From the Ground Up. After doing some bit twiddling, writing a basic allocator, and a handful of the other exercises from the book, I felt way more prepared to handle abstractions higher up.

Anything that I couldn't infer based on the underlying knowledge was something I could google, then quickly form the missing links between starting from the bottom.

I feel like learning C could give the same benefits, though I do hear some struggle with pointers, and in assembly you get to look face first at what they actually are. Everyone has different levels of abstraction that they're comfortable with as well. Assembly was enough to fill the seeming void of knowledge that I felt was holding me back, but for others it may be higher depending on which aspects are puzzling (memory management, intermediate representations, etc).

I also appreciate how much information modern VM authors publish about the inner workings of their platforms. It helps a lot in the same manner to reason about the systems (v8, JVM, CLR, etc).

Post reply on HN