So part 3 already. Yay!
I cannot thank you guys enough for your support.
Section 6: Conditional Jumps
Consider the code below.
section .text global _start other: mov eax, 1 mov ebx, 0 int 0x80 _start: mov eax, 4 cmp eax, 3 jg other
Let's break down the code you may not understand.
cmp is a keyword indicating that we are doing a comparison
The syntax for
cmp <value/register>, <value/register>
A better way to say it is
cmp <a>, <b>.
a is being compared to
In this case
eax is being compared to
This command sets a
system flag basically sets a register in the CPU to equal a value of what went on in the comparison.
jg this is a conditional jump, it looks at what the
system flag is set to and performs a jump based on that.
There are many types of these conditional jumps. Let's review a few.
jgJump if the flag says
jlJump if the flag says
jgeJump if the flag says
greater than or equal to
jleJump if the flag says
less than or equal to
jeJump if the flag says
jneJump if the flag says
not equal to
As you can see
Jump if greater than.
This means that if
eax is greater than
3 it will jump.
So basically we have made an if statement.
But if we add more code after the jump it isn't executed.
That we will discuss in the next section.
Section 7: Calls.
Consider the code below.
section .text global _start other: mov ebx, 0 ret _start: call other mov eax, 1 int 0x80
So let's break this down.
call is the same as
jmp but it sets a register to be equal to the line number after the call.
ret just returns to that line.
Anyways that's it.
Farewell until part 4!
The usual, feedback and upvotes.
@Jakman @oboy12 @ilyasseDev @paulm6cgovern @meham @ZDev1 @vamsidhargodlaveti @bobafet24 @johnstev111 @21natzil @aaqilahamad @AlvarezIiiIii @mkhoi @TheForArkLD @DynamicSquid @FallenAngel13 @SarahHeisnoran @Coder100 @Verbix @AbhayBhat @PaoloAmoroso @Highwayman Part 5 is here!!!!!! https://repl.it/talk/learn/Assembly-Language-Crash-Course-5/45709
Oh look, everyone is using the HahaYes cycle squeezer technique, I think I need to write a article about it.
@HahaYes well, I'm not writing a tutorial for myself am I? So I make it as easy to use as I can for the people that want it. Therefore I just put it in all one post so that they just have that page rather than having to go scrambling around repl talk to find the post in the 'series' which will help them with their problem.
I generally find that people doing series in repl talk is just cycle farming, especially if after the series is over, they then post the whole thing combined into one post. It is also a waste of electronic paper to split it up into multiple posts.
Quick question: don’t ret and call push the instruction point to the stack or something...? I never understood how they could remember the place of the call...
UwU yeas! This is so nice! We’re getting to the good stuff!! When do we do stack operations and such?