Prev: 35525 Up: Map Next: 35627
35591: Convert numeric value BC to ASCII string at location HL
Used by the routine at 34697.
Input
BC A numeric value
HL Points to location to hold a five-character string
35591 PUSH DE Store DE
35592 LD DE,53419 Point DE at table of powers of ten
35595 PUSH BC Store BC (value)
35596 PUSH HL Store HL (location to hold string)
35597 PUSH HL Store HL (location to hold string)
35598 LD H,B Load BC (value) into HL...
35599 LD L,C ...
35600 EX DE,HL Swap DE (now value) and HL (now pointer to table of powers of ten)
35601 LD C,(HL) Read WORD at HL (power of ten) into BC...
35602 INC HL ...and advance HL by two bytes...
35603 LD B,(HL) ...
35604 INC HL ...
35605 EX DE,HL Swap DE (now pointer to next power of ten) and HL (now value)
35606 LD A,47 Load A with 47 (ASCII code immediately prior to that for zero, "0")
35608 INC A Increase A to next ASCII character
35609 OR A Reset carry flag
35610 SBC HL,BC Subtract (BC [power of ten] + carry flag) from HL (value)
35612 JR NC,35608 If carry flag was not set then loop back to 35608
35614 ADD HL,BC Add power of ten back to HL
35615 EX (SP),HL Swap value on top of stack (now remaining value) with HL (now location to hold string)
35616 LD (HL),A Store ASCII code in string and advance HL to next slot...
35617 INC HL ...
35618 EX (SP),HL Swap value on top of stack (pointer to current position in string) with HL (now remaining value)
35619 DEC C Decrease C to check if last power of ten (i.e. 1) has been reached...
35620 JR NZ,35600 ...and if not, then loop back to 35600 for next power of ten
35622 POP HL Restore HL
35623 POP HL Restore HL
35624 POP BC Restore BC
35625 POP DE Restore DE
35626 RET Return
Prev: 35525 Up: Map Next: 35627