例如,如果参数为 20,则循环应计数 1、4、7、10、13、16、19,然后结束。到目前为止我写的东西会算数,但它不会停留在 20.
.globl __Z5counti
__Z5counti:
# rcx = the number to count
movq $1, %rdx # rdx =1 counting...
cmp $0, %rcx
je .End
.Loop:
addq $3, %rdx # rdx += 3
cmpq %rcx, %rdx # rdx == rcx?
jle .Loop
.End:
retq
我试过将 rcx 设置为 20,并做了一个应该在 rdx 为 <= rcx, but the output of rcx ends up being 14 instead of 20.
时停止的循环