 This time, we're going to start looking at how we can actually build loops. As I mentioned back in the conditional video, we're going to use an if statement to help us build these loops. We're going to look at the three different types of loops that you're probably familiar with. We'll start with while loops, then do while loops, and then for loops. So our while loop is a top test loop, which means that we're going to test our condition at the beginning of the loop instead of at the end. This is in contrast to the do while loop, which is a bottom test loop, which means that it only tests the condition after it's run the loop code at least once. In a language like C or Java, our while loop might have this form. And that's going to translate to something that looks about like this in assembly language. We have our loop label that tells us where our loop actually starts. And we're going to follow that up with our condition. That's going to determine whether or not we've run the body of loop. So we're putting something in there like a branch equals branch greater than whatever you need to actually test your condition. And we're setting that up so that if our original condition is false, then we're not going to run this loop. We're going to jump to the end of the loop. Otherwise, we're just going to fall through and run whatever code you've got inside this loop. Once it's run all of this code, it will get to this jump loop instruction, which tells it to go back to this label and run the test again. Determine whether or not it needs to run the loop body another time. If the condition is false, then we go to the end loop label. Otherwise, we go through and we run the body of the loop again. What happens inside the loop is, of course, dependent on what you're trying to program. As is the condition, the actual assembly language code that we need to implement our loop is actually not that bad. We've got a couple of labels, our condition, and a jump statement to ensure that we can do the loop repeatedly. Our do-while loop is not too much different. It's actually even simpler because this time we're going to do our test at the end, so we're not going to need this jump loop label. Instead, we'll run our loop code at least once, then we'll get to our condition. And if our condition is true this time, then we'll go back to the loop label and we'll run our code again. If our condition is false, then we fall through and we just start running whatever code is after our loop. Our for loop is pretty much the same idea. We're still going to have a condition and we'll use that to determine whether or not we run the loop body. But our for loop comes with lots of other pieces with it, too. We frequently have some variable initialization and an increment as well. So this time we start by initializing our registers to whatever we need them to be, just like we would with our for loop. And our loop label comes after that initialization. We only want to run the initialization once, but we still want to be able to run the condition multiple times. So we'll have our loop label then, like the while loop, we check to see if our condition is false. If our condition is false, then we don't run the loop body, we just skip down to the end of the loop. But if our condition is true, then we will fall through, we'll run our loop code, we will run whatever increment we had, and then we'll go back up to our test again. We'll see whether or not we want to run our loop body again. If we do, then we fall through into our loop, otherwise we go off to the end. So our for loop has more pieces to it, rather like the for loop does, but it's not too much more complex than our while loop. We've still just got a loop label, a jump loop instruction, and an end loop label. Everything else in there is really about the loop itself. So for the most part, building our loops involves making sure our conditions are correct and the body of our loop is correct.