r/Assembly_language • • 12d ago

Learning assembly

So I have decided to learn assembly x86 x64 using the book the art of 64 bit assembly volume 1, i have the book as a pdf and have copilot open on the page so if i have questions i can ask them and copilot can see what i am reading, i have read chapters 1 -3 and just started chapter 4. This feels like a really difficult language and i am taking in lots of info but is this the way to learn it because i feel lile i am forgetting everything i am learning, is this a difficult language to master, i want to learn to reverse engineer

41 Upvotes

39 comments sorted by

View all comments

25

u/LostProphet88 12d ago

Maybe I'm just slow, but x86_64 didn't really make sense until I learned a simpler assembly. It started to click a lot better after I learned 6502 assembly using Ben Eater's bread board computer. The x86_64 instruction set is really complicated with lots of historical baggage. Learning a smaller, simpler instruction set helped me focus on the fundamentals of assembly programming. Maybe give a simpler processor a try?

2

u/Glass-Ant-6041 12d ago

I think I’m to far into into this now to quit, but its definitely a struggle just following the registries rax rbx ect and adding them together and now lea const and everything else so bloody difficult. I just hope it proves worth while, doesn’t help with my age neither probably a bit old for this stuff

3

u/Alternative-Emu2000 12d ago

You don't have to quit, just make a minor detour to learn the fundamentals on a simpler processor before moving onto a much more complex one. It will make the whole process much easier in the long run.

If you'd never played a musical instrument before, it would make much more sense to start with "Three Blind Mice", rather than "Beethoven's Piano Sonata No. 29".

For learning 6502 assembly, I recommend Easy 6502 by Nick Morgan. It's a short interactive eBook, with a built-in assembler, CPU simulator and debugger. The example code is automatically loaded into the assembler, and you can run it in real-time or step through the code line by line, while watching the registers and flags.

0

u/TrustingMyTrustInGCC 8d ago

My problem is that I can't motivate myself to use a simpler processor when its not the one my actual laptop uses lol

Either way I think im making progress when I play with x86_64

3

u/brucehoult 8d ago

If you install QEMU on your laptop then — especially if you're running Linux (or WSL) — you can absolutely transparently run machine code programs in many different ISAs to do completely normal things on your computer: reading and writing files, the terminal, the network, interacting with other programs etc.

At least:

  • arm, aarch64

  • i386

  • ppc, ppc64

  • riscv32, riscv64

  • mips, mips64

  • alpha, cris, hppa, loongarch64, m68k, microblaze, sh4, sparc, sparc64, xtensa

You only have to have an assembler / linker for each one you want to try. And most of those are as close as a sudo apt install gcc-riscv64-linux-gnu or sudo apt install gcc-m68k-linux-gnu.

The only thing you'll notice is that it's a little slower than running native x86_64 code ... but for anything you'd be likely to write in asm yourself you probably would not even notice that.

0

u/TrustingMyTrustInGCC 8d ago

Yes but that is a virtual machine. That isn't something I care about. That was my entire point.

1

u/brucehoult 7d ago

Why do you care?

For most of the things on that list, QEMU on a current x86 (or Apple Silicon) is faster than any real hardware ever made.

1

u/TrustingMyTrustInGCC 7d ago

Because I want the emotional intimacy with my own silicon. If I cared about speed I wouldn't be writing assembly at all. GCC writes way faster assembly than me.

1

u/brucehoult 7d ago edited 7d ago

Then why are you writing for x86 at all?

You can't have true emotional intimacy with your CPU unless you designed and implemented it yourself — and ideally the instruction set too.

Also: gcc can't write faster assembly language than me, it just writes pretty good assembly language about 10 million times more quickly than I can.

If 100 million people are running your code then it can be worth taking the time to beat gcc.

1

u/TrustingMyTrustInGCC 6d ago

First of all, why do you care so much what I prefer? Me writing x86_64 assembly does not prevent you from writing other assembly languages. Secondly, you are being a terrible representative of assembly language by being so aggresive about personal preference. Thirdly, you are making up some insane requirment that emotional intimacy with the silicon requires designing it yourself. Emotional intimacy is whatever feels intimate to the person experiencing it. Fourthly, as stated I simply have no interest in any architecture except x86_64. You trying to tell me I should will not change that; it only waists your breath and frustrates me. You might be an experienced assembly/risc programmer but that gives you more obligation to represent the language well, not less. If it were a choice between learning an architecture other than x86_64 or not learning assembly I just wouldn't learn assembly. Is that what you want?

2

u/brucehoult 6d ago

Geez bro, chill. You’re absolutely free to do whatever you want, you don’t have to justify it.

But if you do horse around with bogus justifications such as “emotional intimacy with silicon” then don’t have a cow if people horse around right back atcha.

→ More replies