简体   繁体   中英

The "div" command doesn't work in Assembly

In my code, everything worked as expected but after a regulad "div bx" command it stopped working. I used the command several times befor in the same code and it worked perfectly (I wrote cwd at the beggining). has it happen to you? what is wrong? here is the part of the code:

    proc Reduction
mov dx,0
mov cx,0
mov ax,0
mov bx,0
mov cx, [sheerit]
tsim:
mov ax,0
mov ax,[sheerit]
mov [sheerit1],ax
mov ax,[number2]
mov [number22],ax
mov dx,0
mov ax,[sheerit1]
mov bx,[counter]

div bx
cmp dx,0
jne next
mov ax,[number22]
mov bx, [counter]
div bx
cmp dx,0
jne next
mov ax,[counter]
mov [big],ax
next:
add [counter],1
loop tsim
mov ax,0
mov bx,0
mov cx,0
mov dx,0
mov ax,[sheerit]
mov bx,[big]
; here it stopped working:
div bx
mov [sheerit1],ax
mov ax,0
mov bx,0
mov cx,0
mov dx,0
mov ax,[number2]
mov bx,[big]
div bx
mov [number2],ax
ret
endp Reduction
mov bx,[big] ; here it stopped working: div bx

This will happen if the big variable is still zero at this point which in turn could happen if in the tsim loop the counter was never transferred to big .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM