0

here is my code

ASSUME cs:code,ds:data,ss:stack
data SEGMENT
ENDS
stack SEGMENT
    db 10 dup(0)
ENDS

code SEGMENT
start:
    mov ax,data
    mov ds,ax
    mov ax,stack
    mov ss,ax
    mov bx,19

    call output

    mov ah,4CH  
    int 21H 

output proc
    mov cx,0
    mov ax,bx
    mov bx,10

division:  
    div bx
    push dx
    inc cx
    cmp ax,0
    jne division

    ret 
output endp

code ENDS
end start

I use the debug to find the mistake in my code. I found that when ax = 0001,bx=000A and I invoke div bx , the ax became E666,I don't kown why it happen , it confused me. enter image description here

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
  • 1
    Please note that the [tag:assembly] tag specifically requests that you add processor and assembler tags also. Whilst I may assume that this is x86 or x64, why should I guess when you *know*? – Damien_The_Unbeliever Jun 11 '21 at 13:59
  • 1
    You're leaving the remainder in DX, where the next `div` uses it as the high half of the dividend, creating an infinite loop for numbers that aren't a power of the divisor or something like that. – Peter Cordes Jun 11 '21 at 14:36

0 Answers0