ShellFl0w – Assembly: Th3_Rubb!t_Jump

ALERT: If there are grammatical errors or logical errors, please let us know, thank you.


Well, we are almost at the end of the Assembly section of this chapter:, in this article I will go into some concepts that have been expressed previously and then we will discuss the control structures, how they work and when to insert them.
At the end of this chapter, there will be videos that retract these notions and there will probably also be exclusive ones.

Control Structures

Thanks to high-level languages such as C/C+++, Java and Python we know what are the control structures or conditional, in assembly we will not meet with them, but with its ancestors (the goto for example), the logic that defines the use of these is given by the programmer and depends on it its proper functioning, a bit like all the language Assembly.


The control structures reason on the basis of the comparison of data, So the subtraction between two operands of which the result of this operation determines a result extrapolated from the FLAGS register (Remember, the result is not memorized anywhere), this contains in it many variations that can be taken into account according to the received result.

For integers without sign:

There are 2 flags (bits in the FLAGS register) which are important: the Zero Flag (ZF) and Carry Flag (CF). The Zero Flag is set if the resulting difference is 0. The Carry Flag is used as subtraction loan.
cmp left, right: thanks to the result we can see that flag returns.

Now, we can see some pratics examples:

For integers with sign:
There are three important flags: The Zero Flag (ZF), OverFlow Flag (OF) and Sign Flag (SF):

  • The Zero Flag remains the same as in the previous example.
  • The Overflow Flag is set when there is an OverFlow or UnderFlow case.
  • The Sign Flag instead if the result of the operation is negative.

Let’s see several practical examples here too:

Why cmp 10, 10 returns 0? Well because clearly 10 – 10 = 0, so if it is 0 then it is a Zero flag. While cmp 10, 5 then 5 – 10 returns -5 then negative number then Sign Flag.

We take cmp as a reference point, but it is not the only one we can use for comparisons.

With jumps we can decide which part of the code to skip to and if we want to create iterations, just to give an example we see code:

Now we have seen what are the conditioned jumps, namely those jumps that given a cmp will perform a certain action, here is an example of jump non-conditioned jumps.

These are the “opcodes” that we can use when we have to specify the jump condition, in the previous code we have set that if in the comparison we had obtained a Zero Flag, then we would have obtained a jump, taking the same code, we can have fun in the:

As difficult as it may seem, Assembly is not a difficult language but the crucial part of this is the organization, in fact if you really learn how this language works and in general how a computer works, it is not impossible to devote yourself to this without too many problems, as always I recommend to deepen these topics.

Leave a comment