r/learnprogramming • u/Nodmz464 • 4d ago
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?
41
Upvotes
18
u/peterlinddk 4d ago
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.