Here's some pseudocode for the algorithm (not actually assembly code but it shouldn't be too hard to implement it):

` ``;num = our number to convert to a string ;sptr = pointer to where to store our string ;len = length of our string numberToString: ;Temporarily store a copy of sptr tsptr = sptr; ;We don't have to do much if the number is 0. if num == 0: *sptr = '0' inc sptr *sptr = 0 return ;Convert our number to a string. loop: *sptr = (num % 10) + '0' inc len inc sptr num = num / 10 if num > 0: goto loop ;Insert our null terminator *sptr = 0 dec sptr ;The middle point of our string middle = len / 2 ;Reverse the string reversal: swap *tsptr, *sptr inc tsptr dec *sptr dec len if len >= middle: goto reversal return`

Example:

193 / 10 = 19R3

19 / 10 = 1R9

1 / 10 = 0R1

As you can see, our remainders are 391. That's the reverse of 193. So if logged the remainders each time, and then reversed them, we'd have all our individual numbers. Simply add those numbers to '0', which is the ASCII value for 0 and that converts a single digit into its ASCII equivalent. Once our number hits 0, we know we've converted the whole thing.

]]>