Hello all,

I know that this may be trivial to many programmers on here and I do apologize. I am just having some trouble understanding the relationship between the registers and division.

currently, I am working on a piece of code that will convert a numeric value into an ASCII character to be displayed on the screen.

I have a general idea of how to do it. The steps I plan to take are the following

1. Take the number I plan to convert to ascii and divide it by ten

2. take the remainder and save it to an array (keep doing this until the whole number is in the array - backwards most likely)

3. add the numbers in the array by the ascii char for '0 to convert it to the numerical representation of "said" number.

4. print them out backwards from the array to put them back in order

5. use a write routine to print out the values to screen.

So an example:

`;other important stuff`

.data

PutDataHere byte 8 dup(?)

val1 word 356

divisor byte 10

temp byte ? ;same problem is I use word

.code

mov ax, val1

mov bl,divisor

idiv bl

lea esi, PutDataHere

mov [esi],AH

inc esi

mov temp,AL

mov ax, temp ;datasize conflict

main PROC

main END

END main

So my questions:

1. does dividing ax always result with the answer in AL and AH, where AH is the remainder

2. what about dividing EAX or AH, do they always default to the same registers, or how is that determined.

3. How can I keep dividing a value to keep splitting it up

- in the above example, I want to divide 356 by 10 to get 35.6 and save the six, I then want to loop back and divide 35 by 10 to get 3.5 and save the 5 then finally 3/10 to get .3 and save the 3.

I understand that a 16-bit number once divided will result in an 8-bit answer and remainder, so how can I take the 8-bit answer and divide it again without having a size conflict.

Once again this may be very simple for some, but I am a very visual learner and sometimes I need things explained like a 5th grader :(

thank you.