![]() |
Routines |
| Prev: 27570 | Up: Map | Next: 27671 |
|
||||||||
| 27572 | LD HL,58123 | |||||||
| 27575 | LD B,L | B=11 | ||||||
| 27576 | DEC L | Clear the buffer at 58112, which will be used to store the ASCII codes of the digits | ||||||
| 27577 | LD (HL),0 | |||||||
| 27579 | DJNZ 27576 | |||||||
| 27581 | LD A,48 | 48 is the code for '0' | ||||||
|
Before inserting any ASCII codes into the buffer, we need to figure out whether the first digit is the 10000s, 1000s, 100s, 10s or units digit.
|
||||||||
| 27583 | LD BC,55536 | BC=-10000 | ||||||
| 27586 | EX DE,HL | DE=58112 | ||||||
| 27587 | ADD HL,BC | Subtract 10000 | ||||||
| 27588 | JR C,27620 | Jump if it 'went' | ||||||
| 27590 | SBC HL,BC | Otherwise add the 10000 back | ||||||
| 27592 | LD BC,64536 | BC=-1000 | ||||||
| 27595 | ADD HL,BC | Subtract 1000 | ||||||
| 27596 | JR C,27633 | Jump if it 'went' | ||||||
| 27598 | SBC HL,BC | Otherwise add the 1000 back | ||||||
| 27600 | LD BC,65436 | BC=-100 | ||||||
| 27603 | ADD HL,BC | Subtract 100 | ||||||
| 27604 | JR C,27646 | Jump if it 'went' | ||||||
| 27606 | SBC HL,BC | Otherwise add the 100 back | ||||||
| 27608 | LD C,246 | BC=-10 | ||||||
| 27610 | ADD HL,BC | Subtract 10 | ||||||
| 27611 | JR C,27658 | Jump if it 'went' | ||||||
| 27613 | SBC HL,BC | Otherwise add the 10 back | ||||||
| 27615 | LD A,L | A=units left | ||||||
| 27616 | AND A | Are there any? | ||||||
| 27617 | RET Z | Return if not (nothing to do) | ||||||
| 27618 | JR 27666 | Jump forward to place the units digit into the buffer | ||||||
|
Compute and insert the 10000s digit.
|
||||||||
| 27620 | INC A | Get the ASCII code for the 10000s digit in A | ||||||
| 27621 | ADD HL,BC | |||||||
| 27622 | JR C,27620 | |||||||
| 27624 | SBC HL,BC | |||||||
| 27626 | LD BC,64536 | BC=-1000 | ||||||
| 27629 | LD (DE),A | Place the 10000s digit into the buffer | ||||||
| 27630 | LD A,47 | |||||||
| 27632 | INC E | Move DE along to the next slot in the buffer | ||||||
|
Compute and insert the 1000s digit.
|
||||||||
| 27633 | INC A | Get the ASCII code for the 1000s digit in A | ||||||
| 27634 | ADD HL,BC | |||||||
| 27635 | JR C,27633 | |||||||
| 27637 | SBC HL,BC | |||||||
| 27639 | LD BC,65436 | BC=-100 | ||||||
| 27642 | LD (DE),A | Place the 1000s digit into the buffer | ||||||
| 27643 | LD A,47 | |||||||
| 27645 | INC E | Move DE along to the next slot in the buffer | ||||||
|
Compute and insert the 100s digit.
|
||||||||
| 27646 | INC A | Get the ASCII code for the 100s digit in A | ||||||
| 27647 | ADD HL,BC | |||||||
| 27648 | JR C,27646 | |||||||
| 27650 | SBC HL,BC | |||||||
| 27652 | LD (DE),A | Place the 100s digit into the buffer | ||||||
| 27653 | LD C,246 | BC=-10 | ||||||
| 27655 | LD A,47 | |||||||
| 27657 | INC E | Move DE along to the next slot in the buffer | ||||||
|
Compute and insert the 10s digit.
|
||||||||
| 27658 | INC A | Get the ASCII code for the 10s digit in A | ||||||
| 27659 | ADD HL,BC | |||||||
| 27660 | JR C,27658 | |||||||
| 27662 | SBC HL,BC | |||||||
| 27664 | LD (DE),A | Place the 10s digit into the buffer | ||||||
| 27665 | INC E | Move DE along to the next slot in the buffer | ||||||
|
Compute and insert the units digit.
|
||||||||
| 27666 | LD A,L | A=number of units left | ||||||
| 27667 | ADD A,48 | A=ASCII code for the units digit | ||||||
| 27669 | LD (DE),A | Place this into the buffer | ||||||
| 27670 | RET | |||||||
| Prev: 27570 | Up: Map | Next: 27671 |