05 iteration Flashcards
Convert to Assembly:
while (AL < BL) {
CL = CL + DL
AL++
}
while_begin:
cmp al, bl
jae while_end
add cl, dl
inc al
jmp while_begin
while_end:
Convert to Assembly:
do {
cl = cl + dl;
al++;
}while (al < bl);
do_begin:
add cl, dl
inc al
cmp al, bl
jb do_begin
do_end:
Instruction that allows a loop to execute several iterations (specified by RCX)
loop instruction
What is the format equivalent of
loop <label>?</label>
dec rcx
cmp rcx, 0
jne label
Convert to Assembly:
(either using loop instruction or not or both)
for (rcx=100; rcx>0; rcx–){
bx = bx + cx;
}
// USING LOOP
mov rcx, 100
cmp rcx, 0
je end_for
begin_for:
add bx, cx
loop begin_for
end_for:
// NOT USING LOOP
mov rcx, 100
begin_for:
cmp rcx, 0
je end_for
add bx, cx
dec rcx
jmp begin_for
end_for:
True or False:
The loop instruction is limited to the rcx register and to counting down.
True