div cx
is actually dividing dx:ax
- you should zero dx
beforehand for the result you expect.
To expand, it's performing: (dx * 0x10000 + ax) / cx
, storing the quotient in ax
, and the remainder in dx
. If the quotient does not fit in ax
, that is: dx >= cx
, a divide (overflow) error is raised.