Assembly Primer For Hackers (Part 9) Conditional Branching

Posted By: SecurityTube_Bot
Posted On: Mon 21 Feb 2011
Views: 13893
Share this video:
Share it on Facebook Share it on Twitter Share it on Reddit Share it on Digg Share it on Stumbleupon
Support SecurityTube:


Description: This is Part 9 of the "Assembly Language Primer for Hackers" video series. Please start here by watching Part 1 of this series, if you have not already done so. In this video we will look at Conditional Branching in Assembly Language using the JXX family of instructions and the LOOP instruction.

The conditional jump instructions such as JA, JAE, JZ, JNZ etc. use various flags in the EFLAGS register such as the Zero Flag (ZF), the Parity Flag (PF), Overflow Flag (OF), Sign Flag (SF) etc.  to determine which instruction path to take next. In this video we will look at the JZ condition jump instruction in great detail. JZ using the Zero Flag (ZF) to determine if the last instruction resulted in the Zero operation or not and then chooses to jump to a specified location if it was set. We will also look at the LOOP instruction which used the ECX register to loop over a set of instructions over and over again.

Please download the ConditionalBranching.s sample code file to try the example shown in this video.




Tags: programming ,

This video is part of the following groups:

1. Assembly Language Megaprimer for Linux ( 11 videos)


Comments (19)

slingshot on Sat 26 Mar 2011

Great video series, I have going thru these and doing some extra exercises.

Great work. Thank you so much for all your work.

Col_Loki on Sat 30 Apr 2011

Top notch thanks. This series has been a major help to me. Looking forward to doing more.

sekstiseks on Sat 30 Apr 2011

Thanks again man! Well explained. =)

balder on Wed 18 May 2011

again thanks, one thing which would be nice would be a further reading or .. home work section :). i find my self having to go back through the video at the end so i can note down all the things to try out. however it would be good to have a pointer to a good source for further reading. i found this http://bit.ly/lncuoy however it uses intel syntax

balder on Wed 18 May 2011

" however it would be good to have a pointer"
sorry that should have read "Also it would be nice ..."

rails345 on Tue 31 May 2011

I appreciate the skill and effort you've put into this series. My read of the Intel x86 instruction set suggests that the Conditional Loop slide at 15:30 is in error for LOOPZ and LOOPNZ. Shouldn't this read ...ECX is not zero AND the zero flag (ZF) is set (for LOOPZ) and (ZF) is not set (for LOOPNZ). This would be the 1st error in this series and speaks of a lot of attention to detail. Thanks!

nkb on Fri 24 Jun 2011

Awesome again !!

xplt on Fri 08 Jul 2011

As always! Another great movie! Thank you Vivek!

punkt2 on Tue 12 Jul 2011

it says "video not found" :(
can you reupload it? Please!
That's so a great and interesting video series

neo on Fri 15 Jul 2011

Bravo Vivek.

mac on Mon 01 Aug 2011

yooyoyoyooy going great sir, But i have the problems i can't write the code from my own.

voidexp on Fri 12 Aug 2011

I have an Intel Core 2 Duo, so, a 64-bit processor. The example code
pushl %eax
...
popl %eax
does not work for me. Reading some Intel manuals, i found that using 64 bit versions of these commands, pushq/popq %rax does the job, however, I'm still wondering why GNU As shouts
Error: invalid instruction suffix for `pop'
when I try to use pusl/popl on %eax.

gutterchurl on Wed 31 Aug 2011

voidexp: that should be %ecx, not %eax. pushq/popq %rcx works for me on linux x64

orrala on Mon 03 Oct 2011

thanks, bro :) next one!

Thilee on Thu 01 Dec 2011

Thank you very much. Please keep uploading the video tutorials.

RobinB on Fri 09 Dec 2011

Vivek thank you for your effort in creating these videos. I think it would be great if you could give us homework, in that you tell us to make a program or something like that. Also when you start out there are a lot of things to remember and maybe you could make cheat sheets for stuff like registers, flags, some syntax for both the assembly language but also gdb and compiling. Just some thoughts, love your work, keep up the good work!

RobinB on Fri 09 Dec 2011

As Balder said pretty much :)

Patcher on Sun 18 Dec 2011

gr8 job..!!!

bala150985 on Wed 01 Feb 2012

Thanks Vivek & Thanks gutterchurl

Login to post a comment