; in 16 bit DIV
; dividend = AX
; divisor = any register, bx in this case
; quotient = AX
; remainder = DX
mov ah,4ch ; terminate to DOS successfuly
I know the logic is "divide the number repeatedly, pushing remainders in stack, and then display one by one poping back from stack" My confusion is this;
ax = 235
after 1st div: remainder = dx = 5, and quotient = ax = 23
after 2nd div:remainder = dx = 3, and quotient = ax = 2
after 3rd div: remainder = dix = 0, and quotient = ax = 0.2
poping should yield:035 but it gives 235 correctly. I wonder what happens with last div that is gives 2 correctly. Please help me.
Re: please explain me this multi-digit print program
No black magic at all: An integral division of n by m with n < m always yields a quotient of 0 and a remainder of n. It's simply your manual calculation of the last step that is wrong. (Besides, the AX register never could hold a fractional value like 0.2 anyway... )
BTW, your "terminate to DOS successfully" code is broken or at least easily breakable: It relies on Int 21h Function 02h to return 0 in AL or at least leave it unchanged, which is not the case (see http://www.ctyme.com/intr/rb-2554.htm). Therefore your program will exit properly but return a non-zero completion code which (commonly) indicates failure.
Please use code tags when posting code. The labels are somewhat hard to spot in assembly language code lacking proper formatting like that above.
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.