Prev: 47731 Up: Map Next: 47833
47797: Convert numeric value BC to ASCII string at location HL
Used by the routine at 46837.
Input
BC A numeric value
HL Points to location to hold a five-character string
47797 PUSH DE Store DE
47798 LD DE,62062 Point DE at table of powers of ten
47801 PUSH BC Store BC (value)
47802 PUSH HL Store HL (location to hold string)
47803 PUSH HL Store HL (location to hold string)
47804 LD H,B Load BC (value) into HL...
47805 LD L,C ...
47806 EX DE,HL Swap DE (now value) and HL (now pointer to table of powers of ten)
47807 LD C,(HL) Read WORD at HL (power of ten) into BC...
47808 INC HL ...and advance HL by two bytes...
47809 LD B,(HL) ...
47810 INC HL ...
47811 EX DE,HL Swap DE (now pointer to next power of ten) and HL (now value)
47812 LD A,47 Load A with 47 (ASCII code immediately prior to that for zero, "0")
47814 INC A Increase A to next ASCII character
47815 OR A Reset carry flag
47816 SBC HL,BC Subtract (BC [power of ten] + carry flag) from HL (value)
47818 JR NC,47814 If carry flag was not set then loop back to 47814
47820 ADD HL,BC Add power of ten back to HL
47821 EX (SP),HL Swap value on top of stack (now remaining value) with HL (now location to hold string)
47822 LD (HL),A Store ASCII code in string and advance HL to next slot...
47823 INC HL ...
47824 EX (SP),HL Swap value on top of stack (pointer to current position in string) with HL (now remaining value)
47825 DEC C Decrease C to check if last power of ten (i.e. 1) has been reached...
47826 JR NZ,47806 ...and if not, then loop back to 47806 for next power of ten
47828 POP HL Restore HL
47829 POP HL Restore HL
47830 POP BC Restore BC
47831 POP DE Restore DE
47832 RET Return
Prev: 47731 Up: Map Next: 47833