Help - Search - Members - Calendar
Full Version: DIV CX puts result in AX?
Hydrogenaudio Forums > Misc. > Off-Topic
kwanbis
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?
Garf
The comment is incorrect.
fccHandler
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
it is correct, at least on debug. the dividend is allways AX, and the result goes into AL.
fccHandler
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.
Garf
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.
Invision Power Board © 2001-2008 Invision Power Services, Inc.