A very compact and obscure looking routine. But a clever use of the Carry flag underneath!
0673 7358 18 ASCII CLC 0674 7359 69 06 ADC #6 0675 735B 69 F0 ADC #$F0 0676 735D 90 02 BCC ASC1 0677 735F 69 06 ADC #$06 0678 7361 ; 0679 7361 69 3A ASC1 ADC #$3A 0680 7363 48 PHA ; TEST FOR LETTER B IN ADR DURING WBNPF 0681 7364 C9 42 CMP 'B' ; 0682 7366 D0 0A BNE ASCX 0683 7368 A5 FD LDA SAVX 0684 736A C9 07 CMP #NCMDS 0685 736C D0 04 BNE ASCX ; NOT WB CMD 0686 736E 68 PLA 0687 736F A9 20 LDA ' ' ; FOR WB, BLANK 0'S IN ADR 0688 7371 48 PHA 0689 7372 68 ASCX PLA 0690 7373 60 RTS
ASCII
Convert the low nibble in A to ASCII hex. Call it with the upper nibble containing 0.
A returned has the ASCII equivalent of the byte value.
What is happening here?
- clear the Carry flag (673)
- A is shifted into a range that later allows the Carry flag to distinguish between numeric digits (0–9) and alphabetic digits (A–F) (674)
- Adding $F0 causes only values A–F to generate a carry.(675)
Input Accumulator Carry 0–9 $F6–$FF 0 A–F $00–$05 1 - Carry is clear, the value was 0–9. Otherwise an extra ADC $06 is executed before the final addition.(677)
- Add $3A to make it ASCII ((679)
- if the character is ‘B” and the current command is WH BNPF repalce with ‘ ‘
to suppress illegal characters in the BNPF format
Note that suppressing ‘F’ is also part of the BNPF format definition. It is not done on the TIM for unknown reasons.
Examples
Input = 5
5 + 6 = 11 11 + $F0 = $FB Carry=0 $FB + $3A = $35 ASCII '5'
Input = A (10)
10 + 6 = 16 16 + $F0 = $00 Carry=1 00 + 6 + C = $07 07 + $3A = $41 ASCII 'A'
See also:

MEMORY PLUS
MEMORY PLUS: 8K RAM, 8K ROM, VIA 6522, 2716 EPROM programmer
The MEMORY PLUS board is a RAM/ROM expansion board for ...

Chessmate for the KIM-1
Since I have a well documented source of the Chessmate ROMs and made a VT100 version of Microchess I made a VT100 versio...

MCS Alpha 1
MCS Alpha 1
The ALPHA-1, made by Berliner Unternehmens MCS ("Micronic Computer Systeme GmbH") is an early computer, pro...

My KIM-1 expansions in Radio Bulletin
KIM-1 expansions in Radio Bulletin"
My KIM-1 system was based upon what we had published in Radio Bulletin. These artic...