5 ms·
It's very common for people to learn assembly using x86(-64) but this ISA is so messy, complicated and layered that it always seems like the bad choice to me. I
by simias 6y ago
It's very common for people to learn assembly using x86(-64) but this ISA is so messy, complicated and layered that it always seems like the bad choice to me. It's like teaching an intro programming course using C++, I understand why it's practical but it seems like it will be more trouble than it's worth.
I'd probably recommend getting some ARM or ARM64 board and starting with this, most of the concepts will carry over to other assemblies anyway. Writing a simple CPU emulator for some simple architecture and then coding on it can also be a great teaching experience, if a little more involved.
I find this tutorial a bit oddly structured too, but that may be because I'm from un*x world and I don't have the Windows mindset. It basically goes from "int3 ret" to "The PE Format and DLL Imports". That seems like quite the jump, and not necessarily super relevant to learning ASM IMO.
- Craighead 6y agoWhy is c++ not the best intro to programming language?
- simias 6y agoIt's too complicated IMO. The surface to cover is absolutely huge. Teaching complete novices to program is complicated enough, explaining the difference between char * and std::string and how a char is not really a char if you deal with unicode and OOP and destructors and exceptions and virtual calls and global constructors and RAII and templates and overloading and... I think it would make more sense to start with a simpler language and work your way to C++ if that's what you want.
- Darvon 6y agoDepends if your goal is to teach the maximum number of people the fundamentals of logic, or to transfer as much practical knowledge as quick as possible to the students with an aptitude for programming.
- josteink 6y ago> It's very common for people to learn assembly using x86(-64) but this ISA is so messy, complicated and layered that it always seems like the bad choice to me. Agreed. As someone who did lots of assembly for the 6502 and the whole Motorola 68k series CPUs while on Mac & Commodore-machines, I thought I might as well learn x86 assembly when I moved to "regular" PCs. After a week or so of en-bafflement, I just decided that dealing with assembly on any sort of regular basis was not something I was interested in doing on the Intel-platform. It was inferior to competing platforms in almost every conceivable way back then (except performance) and it haven't improved since. It's just utterly terrible and the only reason it's still around is backwards compatibility. Nobody would design anything like this today.
- stevekemp 6y agoIt really depends what you started with - I've never touched 6502, but I did a lot of z80 assembly back in the day. Since Zilog was started by ex-Intel people there's a lot in common. For me jumping from z80 -> x86 was only a small change. The same notion of paired-registers and very similar instructions made it a simple enough change. Of course these days there have been a lot of changes, but the basics are still basic, albeit idiosyncratic.
- wolf550e 6y agoI think I agree but it is very important that the student learns which facts they were taught are about ARM/ARM64/MIPS (or whatever you choose to use) and which are about computers in general. Otherwise, you get people coming to stack overflow with questions like "How come this book says that on x86 you can jump into the middle of an instruction and execute those bytes as a different instruction, when clearly this is impossible, because I have studied RISC-based computer in a COA class and thought that instructions are read sequentially and that instructions memory are read from memory 4 bytes at a time".
- roel_v 6y agoOne of the main reasons for learning assembly today is to do reverse engineering, for which the plumbing is just as important as the concepts.
- simias 6y agoI mainly use assembly for optimization myself, in general to double-check that the compiler did what I expected it to do. I also sometimes use it when I do bare-metal programming or other very low level code, but that's pretty niche these days. But even more generally I think you won't have any trouble picking up x86 idiosyncrasies if you've familiarized yourself with ARM/MIPS/Z80 assembly. Although maybe MIPS would be a bad choice because it doesn't use flags which are an important concept for many assembly languages. IMO the key concepts for an assembler tutorial would be, out of the top of my head: - The stack, - banking registers, the frame pointer, - The various types of jumps/calls/branches and their differences, - Conditionals, - Calling conventions, - Banking/context switching/IRQs (at least for low level programming, not so important if you're only dealing with userland I suppose), That stuff exists on basically any architecture. Then you have things like immediate encoding and addressing modes which are also very important and architecture-specific. I suppose SIMD could be interesting as well, but these days it seems to be mostly done with intrinsics instead of raw assembly, at least in my experience.
- roel_v 6y agoYes, when you study assembly as a general programming language, the same way you learn another language. But again, for people who are interested in reverse engineering, the focus is different, and you'll find that if you start looking for assembly tutorials online (and also the books on modern assembly, e.g. I have "Modern x64 assembly language programming" and "Windows 64 bit assembly language programming quick start" here next to me and those fit that description), a lot of those are for aspiring reverse engineers. The (numerical) optimization angle is a lot harder to find, agner.org probably being the exception. E.g., knowing what _main is and how to call an OS primitive is a lot more important when reverse engineering than knowing about context switching and simd. I was just trying to say, that's where the focus on a specific OS comes from, and a focus on things that people who do manual numerical optimization would consider irrelevant or at best tangential to what they consider 'important' in assembly.
- raxxorrax 6y agoKind of disagree, but just because the literature for ASM for x86 is that good. What I am missing most of the time is declaration of the platform. In most cases "learning ASM" means x86/Linux or x64/Linux, this time it is x64/Windows. Because you will quickly get to a point where you want to do system calls and that can vary from platform to platform. If you like an easy instruction set and don't care about platform specific syscalls, I would recommend an 8bit µC. An Arduino for example.
- simias 6y agoI get your point (and agree about 8bit µC) but I would also point out that ARM/Linux and ARM64/Linux are pretty common and accessible these days. Buying an RPi to learn ASM and not have to deal with x86 nonsense would be a good investment IMO. Maybe not everybody shares my deeply rooted dislike for x86 though.
- deleted 6y ago[deleted]
- deleted 6y ago[deleted]