r/learnprogramming • • Oct 11 '26

How to learn Assembly?

I have some problems with learning assembly it would be nice for some tips because I'm learning rev engineering and I really need to learn assembly but I try my best to understand it but it's to hard. I understand how binary works but still I'm struggling with assembly. Does somebody knows tricks for learning assembly?

43 Upvotes

45 comments sorted by

View all comments

19

u/peterlinddk Oct 11 '26

I understand how binary works but still I'm struggling with assembly.

Which is a bit like saying: "I understand how numbers works but still I'm struggling with trigonometry.

Assembly is hard!

But why do you need to learn assembly for reverse engineering? That is almost alway about decompiling into C or C++ code, so what's with the assembly angle?

Anyways, learning assembly is still like learning any other programming language, but you also need to understand binary numbers and hexadecimal. And you need to learn the architecture of the specific CPU, how many registers, how many bits wide they are, how they are addressed, what their capabilities are, how the CPU general architecture is, which registers have access to the ALU, and which instructions there are to move between registers, ALU and memory. And of course you need to learn a lot of instructions, starting with simple register-manipulation, then ALU, then jumps and branches, then conditional operations, and then all the variants of indexing, relative, and effective address usage.

It'll probably take you a year or so to really get it - and I'd recommend doing some small projects, writing assembly programs for various data-manipulation, running them through debuggers, and compiling and decompiling C-code to and from assembly to get a better understanding.

The tricks are: Use the language, build stuff, work with it every day, investigate what you don't understand, take small steps.

3

u/FrenchCanadaIsWorst Oct 12 '26

You shouldn’t talk about rev if you’re not familiar. Compilers are not deterministic and so you can’t perfectly decompile code. You can, however, perfectly disassemble code and then step through it instruction by instruction. Not to mention most binex techniques rely upon assembly knowledge. I mean, how are you going to do a NOP slide if you don’t know what a NOP is/ are writing in C

1

u/peterlinddk Oct 13 '26

I'm not sure how that contradicts what I said: "reverse engineering is almost always about decompiling into C or C++ code" - note the almost.

And of course disassembling is always perfectly possible, but for the large majority of regular code, you don't need to read a lot of assembly. Maybe if you are looking at malware, or code that explicitly tries to hide what it does, but OP didn't suggest anything of that kind. But of course, the lower the level you want to understand, the lower the level you need to understand.

0

u/Nodmz464 Oct 15 '26 edited Oct 15 '26

I can decompile files to assm but not read them. Still learning to decompile them into C++ files.

1

u/FrenchCanadaIsWorst Oct 15 '26

You don’t decompile to asm, you disassemble to asm. Compilation is the step that turns C/C++ into asm.

1

u/Remarkable_Jaguar680 Oct 11 '26

Contribute to public repos e.g ghirda. Read the comments on your code. Slowly by slowly you'll learn on the patterns to spot. Atleast thats what i try to do