05 iteration Flashcards

1
Q

Convert to Assembly:

while (AL < BL) {
CL = CL + DL
AL++
}

A

while_begin:
cmp al, bl
jae while_end
add cl, dl
inc al
jmp while_begin

while_end:

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Convert to Assembly:

do {
cl = cl + dl;
al++;
}while (al < bl);

A

do_begin:
add cl, dl
inc al
cmp al, bl
jb do_begin

do_end:

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Instruction that allows a loop to execute several iterations (specified by RCX)

A

loop instruction

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the format equivalent of
loop <label>?</label>

A

dec rcx
cmp rcx, 0
jne label

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Convert to Assembly:
(either using loop instruction or not or both)

for (rcx=100; rcx>0; rcx–){
bx = bx + cx;
}

A

// 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:

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

True or False:
The loop instruction is limited to the rcx register and to counting down.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly