kwanbis
May 31 2005, 14:19
I have this code
1630:5006 MOV AX,BX
1630:5008 MOV CX,C8
1630:500B DIV CX
And the comments say that the result is put in CX. Can somebody explain why?
The comment is incorrect.
fccHandler
May 31 2005, 17:18
Yup. That code takes the unsigned 32-bit number in the DX:AX register pair and divides it by the unsigned 16-bit number in CX. The result is that AX will contain the quotient, and DX the remainder. (CX remains unchanged.)
kwanbis
May 31 2005, 19:28
it is correct, at least on debug. the dividend is allways AX, and the result goes into AL.
fccHandler
May 31 2005, 23:51
That is only true if the divisor is an 8-bit register. (For example, "DIV CL".) But in the code you posted, the divisor is the 16-bit CX register. In either case the comment is incorrect, because the contents of CX are not affected by the "DIV" instruction.
QUOTE(kwanbis @ Jun 1 2005, 03:28 AM)
it is correct, at least on debug. the dividend is allways AX, and the result goes into AL.
Hmm? That's not what the comment says, so how can it be correct?
I think there's some confusion here - the topic title doesn't correspond with what you posted either.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.