However, that has a number of serious drawbacks, with the most serious one being that it really isn't suited for nested loops (it uses CX as the counter, which if you have more than one loop means you have to somehow save the CX value before entering the inner loop and then restore it afterward).
A more solution is simply to use ordinary conditional branches. Here's a fairly typical example, which has a simple optimization of moving the test to the end of the loop (which avoids an unneeded unconditional branch on each pass):
; initialize the counter variable
mov counter, 0
; jump to the conditional test
; add the body of the loop here
; increment the counter before going into the test
cmp counter, target
thanks! however, i'm having a problem with the multiple variables in my for loop. my inner for loop needs the value of i, which is declared in my outer for loop. also, k is needed in my inner for loop statement. when i tried working this out in assembly, it seems like the registers are not enough to store all my variables. T_____T
No, they probably wouldn't be; the x86 is notorious for it's relatively small register set. You can, however, use a memory variable for this purpose instead, either by a define-byte or by setting up an activation record on the stack.