4.5 JMP and LOOP Instructions
1 In real-address mode, which register is used as the counter by the LOOP instruction?(在实地址模式下,循环指令使用哪个寄存器作为计数器?)
答 :CX
2 The LOOP instruction does the following: It decrements ECX; then, if ECX is not equal to zero, LOOP jumps to the destination label.(循环指令执行以下操作:使ECX递减;然后,如果ECX不等于零,则循环跳转到目标标签。)
答 :√
3 JMP is a conditional transfer instruction.
答 :×
4 A JMP instruction can only jump to a label inside the current procedure.
答 :√
5 The LOOP instruction first checks to see whether ECX is not equal to zero; then LOOP decrements ECX and jumps to the destination label.
答 :×
6 The target of a LOOP instruction must be within 256 bytes of the current location.
答 :×
7 If ECX is initialized to zero before beginning a loop, how many times will the LOOP instruction repeat? (Assume ECX is not modified by any other instructions inside the loop.)
答 :4,294,967,296 times
8 What will be the final value of EAX in this example?
mov eax,0
mov ecx,10 ; outer loop counter
L1:
mov eax,3
mov ecx,5 ; inner loop counter
L2:
add eax,5
loop L2 ; repeat inner loop
loop L1 ; repeat outer loop
答 :This is a trick! The program does not stop, because the first LOOP instruction decrements ECX to zero. The second LOOP instruction decrements ECX to FFFFFFFFh, causing the outer loop to repeat. (这是个骗局!程序不会停止,因为第一个循环指令将ECX递减为零。第二个循环指令将ECX递减为FFFFFFFFh,导致外部循环重复。)