Try adding xor dx, dx
before each div
and see if that doesn't help.
Since you're specifying a 16-bit target, div
divides dx:ax
by that target. If dx
starts out containing a large number (more accurately, anything but quite a small number), the result will overflow. Even if it doesn't overflow, your result won't just be ax
/bx
as you apparently intend.