Hello everyone.
Again, I'm Tayfun and today we're starting a fresh lecture where we break down the basic structure
of assembly instructions at the building blocks of any low level program.
Now, if you ever looked at an assembly listing and thought it looked like a pure chaos, this lecture
will give you a clear map to understand it.
So let's understand the structure of assembly instruction.
Assembler language is made up of straight direct line of code, and most follow a standard format like
the.
At the most left we have label or address.
Then we have mnemonic, and after that we have operands.
And then we have the command.
This is just us.
If we add command there will be.
If we don't, there won't.
Now the label format uh, as a label address.
For example, let's write some assembly code here
00A92AB7
move.
And the operates we have x dword p and.
We'll move it to another address 0A9B for example.
Yeah just f a.
That's it.
And after that uh, we have the command.
This command is just the moves.
Let's say we are with the command here that moves the default value at um, uh, zero a, nine b for
now.
Default value is this here address.
And yeah, let's start now with the label or address.
Now this part defines the memory location where the instruction resides in debugging tools or disassemblers.
This is often raw memory address.
And in this uh, in this case it is uh 00A92A B7, just an address random address.
And during development labels can be used instead like, uh, start loop or read value.
Now these labels make code more readable and help during branching and function calls.
And then we have the mnemonic.
In this case it's mov.
So this is the actual instruction the operation you want the CPU to perform.
Now common mnemonics include mov uh add subtract gmp uh which add adds the value subtract subtracts
the values gmp jump to another instruction.
And we also have call which calls a function or subroutine.
We had an introductory lecture to mnemonics and instructions in previous lectures.
I strongly suggest if you have passed that lecture, watch that again.
Now the mnemonic is human readable representation of a binary opcode which the CPU will execute.
And here we have the operands the operands basically the destination and the source.
In our example x dword ptr and some hexadecimal address here.
Now this means move the 32 bit value, which is uh, Dword is 32 bit value from that address up here
into a EAX register, and the CPU reads the value from the memory and stores it in a register.
So some operands are immediate values like mov uh, for example, move x uh five.
Now some registers like EB or EC and some are memory registers like memory references like, uh, this
one here.
Right.
And yeah, last one is the comments here.
Uh, anything after the semicolon in assembly is a command.
Uh, comments are not executed.
Uh, just like any other programming languages.
They're just there to help humans understand what code is doing.
And for example, uh, in this case, we can add the comment that says, uh, to other programmers and
for us that this loads the contour value.
Now, commenting is crucial in reverse engineering and debugging.
Uh, because when you're trying to understand someone else's code, especially without the source,
these annotations became, uh, your friend.
And to summarize every line in assembly language, and assemble a program doesn't matter.
It's an ARM or x86 usually follows this clean structure, an address or label to tell where it lives,
a mnemonic to say what it does, and some operands to show what it does it to, and optionally a comment
to explain why it is there.
Now, learning this format helps make sense of disassembled binaries and lets you communicate with the
CPU in its native language.
Now in the next lecture, we will start analyzing common instruction types and patterns used in real
world binaries, especially the opcodes.
And we also learn.
We will also learn about the copy.
How to copy the data.
And after that we will start analyzing other reverse engineering and malware tools.
Now that's it with our lecture.
Thank you for watching.
Stay tuned.
And we'll turn this cryptic code into something you can read like a book.