Routines |
Prev: $217D | Up: Map | Next: $2241 |
|
||||||||
$217E | LDA #$20 | Prepare 5 space characters at $8A-$8E. | ||||||
$2180 | STA $8A | |||||||
$2182 | STA $8B | |||||||
$2184 | STA $8C | |||||||
$2186 | STA $8D | |||||||
$2188 | STA $8E | |||||||
$218A | LDA $A4 | Pick up the MSB of the number. | ||||||
$218C | CMP #$28 | Is it less than 40 (meaning the number is less than 10240)? | ||||||
$218E | BCC $21B6 | Branch if so. | ||||||
$2190 | LDA $8A | Increment the character code of the first digit at $8A from space to '1', '1' to '2' etc. | ||||||
$2192 | CLC | |||||||
$2193 | ADC #$01 | |||||||
$2195 | ORA #$10 | |||||||
$2197 | STA $8A | |||||||
$2199 | LDA #$30 | Set the character code of the second, third and fourth digits at $8B, $8C and $8D to '0'. | ||||||
$219B | STA $8B | |||||||
$219D | STA $8C | |||||||
$219F | STA $8D | |||||||
$21A1 | LDA $A3 | Subtract $2774 (10100) from the number at $A3. (This is a bug.) | ||||||
$21A3 | SEC | |||||||
$21A4 | SBC #$74 | |||||||
$21A6 | STA $A3 | |||||||
$21A8 | BCS $21AC | |||||||
$21AA | DEC $A4 | |||||||
$21AC | LDA $A4 | |||||||
$21AE | SEC | |||||||
$21AF | SBC #$27 | |||||||
$21B1 | STA $A4 | |||||||
$21B3 | JMP $218C | Jump back to consider the 10000's digit again. | ||||||
$21B6 | CMP #$27 | Is the MSB of the number 39 (meaning the number is at least 9984)? | ||||||
$21B8 | BNE $21C0 | Branch if not. | ||||||
$21BA | LDA $A3 | Pick up the LSB of the number. | ||||||
$21BC | CMP #$74 | Is it 116 or more (meaning the number is 10100 or more)? (This is a bug.) | ||||||
$21BE | BCS $2190 | Branch back to deal with the 10000s digit if so. | ||||||
The 10000s digit has been computed. Now for the 1000s digit.
|
||||||||
$21C0 | LDA $A4 | Pick up the MSB of what remains of the number. | ||||||
$21C2 | CMP #$04 | Is it less than 4 (meaning the number is less than 1024)? | ||||||
$21C4 | BCC $21EA | Branch if so. | ||||||
$21C6 | LDA $8B | Increment the character code of the second digit at $8B from space or '0' to '1', '1' to '2' etc. | ||||||
$21C8 | CLC | |||||||
$21C9 | ADC #$01 | |||||||
$21CB | ORA #$10 | |||||||
$21CD | STA $8B | |||||||
$21CF | LDA #$30 | Set the character code of the third and fourth digits at $8C and $8D to '0'. | ||||||
$21D1 | STA $8C | |||||||
$21D3 | STA $8D | |||||||
$21D5 | LDA $A3 | Subtract $03E8 (1000) from the number at $A3. | ||||||
$21D7 | SEC | |||||||
$21D8 | SBC #$E8 | |||||||
$21DA | STA $A3 | |||||||
$21DC | BCS $21E0 | |||||||
$21DE | DEC $A4 | |||||||
$21E0 | LDA $A4 | |||||||
$21E2 | SEC | |||||||
$21E3 | SBC #$03 | |||||||
$21E5 | STA $A4 | |||||||
$21E7 | JMP $21C2 | Jump back to consider the 1000s digit again. | ||||||
$21EA | CMP #$03 | Is the MSB of the number 3 (meaning the number is at least 768)? | ||||||
$21EC | BNE $21F4 | Branch if not. | ||||||
$21EE | LDA $A3 | Pick up the LSB of the number. | ||||||
$21F0 | CMP #$E8 | Is it 232 or more (meaning the number is 1000 or more)? | ||||||
$21F2 | BCS $21C6 | Branch back to deal with the 1000s digit if so. | ||||||
The 1000s digit has been computed. Now for the 100s digit.
|
||||||||
$21F4 | LDA $A4 | Pick up the MSB of what remains of the number. | ||||||
$21F6 | BEQ $2213 | Branch if it's zero (meaning the number is less than 256). | ||||||
$21F8 | LDA $8C | Increment the character code of the third digit at $8C from space or '0' to '1', '1' to '2' etc. | ||||||
$21FA | CLC | |||||||
$21FB | ADC #$01 | |||||||
$21FD | ORA #$10 | |||||||
$21FF | STA $8C | |||||||
$2201 | LDA $A3 | Subtract $64 (100) from the number at $A3. | ||||||
$2203 | SEC | |||||||
$2204 | SBC #$64 | |||||||
$2206 | STA $A3 | |||||||
$2208 | BCS $220C | |||||||
$220A | DEC $A4 | |||||||
$220C | LDA #$30 | Set the character code of the fourth digit at $8D to '0'. | ||||||
$220E | STA $8D | |||||||
$2210 | JMP $21F4 | Jump back to consider the 100s digit again. | ||||||
$2213 | LDA $A3 | Pick up the LSB of the number. | ||||||
$2215 | CMP #$64 | Is it 100 or more? | ||||||
$2217 | BCS $21F8 | Branch back to deal with the 100s digit if so. | ||||||
$2219 | JMP $2222 | Otherwise jump forward to compute the 10s digit. | ||||||
$221C | LDA #$20 | Set the character codes of the last two digits at $8D and $8E to 32 (space). | ||||||
$221E | STA $8D | |||||||
$2220 | STA $8E | |||||||
The 100s digit has been computed. Now for the 10s digit.
|
||||||||
$2222 | LDA $A3 | Pick up the LSB of what remains of the number. | ||||||
$2224 | CMP #$0A | Is it less than 10? | ||||||
$2226 | BCC $223B | Branch if so. | ||||||
$2228 | LDA $8D | Increment the character code of the fourth digit at $8D from space or '0' to '1', '1' to '2' etc. | ||||||
$222A | CLC | |||||||
$222B | ADC #$01 | |||||||
$222D | ORA #$10 | |||||||
$222F | STA $8D | |||||||
$2231 | LDA $A3 | Subtract 10 from the number at $A3. | ||||||
$2233 | SEC | |||||||
$2234 | SBC #$0A | |||||||
$2236 | STA $A3 | |||||||
$2238 | JMP $2222 | Jump back to consider the 10s digit again. | ||||||
The 10s digit has been computed. Now for the 1s digit.
|
||||||||
$223B | CLC | Add 48 to the remaining value to get the character code of the final digit, and store it at $8E. | ||||||
$223C | ADC #$30 | |||||||
$223E | STA $8E | |||||||
$2240 | RTS |
Prev: $217D | Up: Map | Next: $2241 |