在NASM中分割时出现无限循环

时间:2019-09-29 02:34:50

标签: assembly nasm infinite-loop

在NASM中执行此循环时遇到一些麻烦。对于某些信息,在循环首次开始时:div2 = 2,binConv = 10,sum = 63,rmndr = 0。 我不明白为什么它无限循环。当我的“和”最终达到0时,它不应该与rbx中的0进行比较并退出循环吗?代码如下:

        mov     rbx,0
binLoop:
        mov     rax,0           ; Clear out rax                                
        mov     rax,[sum]       ; Move the remaining sum into rax            
        div     qword[div2]     ; Divide existing sum by 2                    
        mov     [sum],rax       ; Put the divided value of rax into sum var 
        mov     rax, 0          ; Clear out rax for the binary conversion      
        mov     rax,rdx         ; Move remainder into binConv var              
        imul    rax,[binConv]   ; Multiply by existing binary notation (10^x)  
        add     [rmndr],rax     ; Add the coverted remainder to rmndr var      
        mov     rax,0           ; Clear out rax for updating binConv var      
        mov     rax,[binConv]   ; Place binConv value into rax                
        imul    rax,10          ; Continue to do binConv*10 (10,100,1000,etc)  
        mov     [binConv],rax   ; Place the new value into binConv            
        cmp     rbx,[sum]       ; Check to see if sum has reached 0            
        jne     binLoop         ; Jump if sum !=0

0 个答案:

没有答案