在递归过程中添加WriteDec和CRLF调用时,它将进入无限循环。
以下代码在EAX寄存器= 0时导致无限循环
.code
MAIN PROC
mov ecx, 10
L1:
push 10
call f1
call exitProcess
main ENDP
f1 PROC
push ebp
mov ebp, esp
sub esp, 4
mov eax, [ebp+8]
shr eax, 1
call WriteDec
call CRLF
mov [ebp-4], eax
jz skip
call f1
skip:
mov eax, [ebp+8]
call WriteDec
call CRLF
; ** comment out ** mov ebp, [ebp]
mov esp, ebp
pop ebp
ret 4
f1 ENDP
END MAIN
预期结果:
5
2
1
0
1
2
5
10
答案 0 :(得分:2)
罪魁祸首在这里:
IEnumerable<EnumDto> genderDtos = dtos.Get<Gender>();
IEnumerable<EnumDto> maritalStatusDtos = dtos.Get<MaritalStatus>();
IEnumerable<EnumDto> residentialStatusDtos = dtos.Get<ResidentialStatus>();
在x86中,MOV指令未设置任何标志,因此JZ将采用上面该函数调用遗留的ZF标志的状态。
正确的代码如下:
mov [ebp-4], eax
jz skip