Suppress KIM echo

A new article in English, but in fact an article from May 1979 in Dutch: how to suppress the KIM-1 hardware echo.

Suppress KIM-1 echo

Hans Otten, May 1979, March 2021
Original article: KIM Kenner 17 page 14, Dutch, Hans Otten

Problem: the KIM-1 hardware is echoing incoming serial characters to the output, no echo in software involved. Very annoying!

In the KIM Kenner 1 Siep de Vries, founder of the Dutch KIM Club mentioned how in Focal for the 6502 a trick was built in to suppress the hardware echo by manipulating the TTY out bit. I took the idea and implemented the software.

Hardware echo

The echo of incoming serial to outgoing is shown in the next figures (from the KIM user manual and the KIM Circuit poster).

The TTY KEYBD signal goes via a transistor and NAND gate U15 to PA7 port of the 6532. That signal also goes to pin 10 input  of NAND gate U26  which is the TTY out line. This is the hardware echo. When the KIM-1 sends out a character it comes  from PB0 to pin 9 of of NAND gate U26 and so comes out to the TTY Out line.
Note that PB5 is connected via an inverter to NAND gate U15. The other input is TTY IN. Making PB5 high will make the TTY input PA7 deaf.
Note PB5 is also Audio out.

Suppress echo in software

The solution to suppress the echo is making output PB0 low. The NAND gate out will now stay high, ignoring any changes on the other input, which is the incoming serial character.
Only when receiving a character PBO should be made high. Also any incoming character will now not be echoed unless the program wants to receive a character!

Example program

In this routine the standard KIM-1 GETCH routine at $1E5A is encapsulated in a subroutine that prevents the echo by setting PB0. Note that this is not a complete block of the echo, it is only active when the program calls the blocking EGETCHAR. When the program sends out charactersto a dispaly, anything typed at the keyboard will also appear at the display.
The calling program is now responsible for the echoing!

0001   1000             echo .org $1000
0002   1000             ;
0003   1000             echoflag = $17E2 ; flag: 0 normal echo
0004   1000             SBD = $ 1742 ; KIM 6532 PIA B data register
0005   1000             GETCH = $1E5A ; KIM TTY Getch routine 
0006   1000             ;
0007   1000 AD E2 17    EGETCHAR LDA echoflag ; if not echoflag 
0008   1003 F0 08         beq normal ;  then normal echo 
0009   1005 AD CE 06      LDA SBD  ; else set TTY bit PB0 to 0 
0010   1008 29 FE         AND #$FE  
0011   100A 8D CE 06      STA SBD ; 
0012   100D 20 5A 1E    normal JSR GETCH ; get character from input
0013   1010 48            PHA ; save
0014   1011 AD CE 06      LDA SBD ; set TTY bit PB0 
0015   1014 09 01         ORA #$01 
0016   1016 8D CE 06      STA SBD 
0017   1019 68            PLA ; restore received character
0018   101A 60            RTS 
0019   101B               .end
0020   101B               tasm: Number of errors = 0

Does EGETCHAR work on the KIM-1 clones?

Micro-KIM and PAL-1: yes, the hardware is identical, IC numbers are different
Corsham Technology: yes, though the hardware for audio is not there, there is still a NAND gate IC17C coupling PA7 and PB0.

Enhanced solution: always deaf for input
If you study the hardware shown above you see PB5 also blocks the echo. The following routine tries to use this to make the input permanent deaf.

0001   1000             echo .org $1000
0002   1000             ;
0003   1000             echoflag = $17E2 ; flag: 0 normal echo
0004   1000             SBD = $ 1742 ; KIM 6532 PIA B data register
0005   1000             GETCH = $1E5A ; KIM TTY Getch routine 
0006   1000             ;
0007   1000             ; no echo when reading character
0008   1000             ; 
0009   1000 AD E2 17    EGETCHAR LDA echoflag ; if not echoflag 
0010   1003 F0 08         beq normal ;  then normal echo 
0011   1005 AD CE 06      LDA SBD  ; else set TTY bit PB0 to 
0012   1008 29 FE         AND #$FE 
0013   100A 8D CE 06      STA SBD ; 
0014   100D 20 5A 1E    normal JSR GETCH ; get character from input
0015   1010 48            PHA ; save
0016   1011 AD CE 06      LDA SBD ; set TTY bit PB0 
0017   1014 09 01         ORA #$01 
0018   1016 8D CE 06      STA SBD 
0019   1019 68            PLA ; restore received character
0020   101A 60            RTS 
0021   101B             ;
0022   101B             ; no echo only at wish if reading character
0023   101B             ; note that using tape I/O will leave PB5 low
0024   101B             ; 
0025   101B AD E2 17    DGETCHAR LDA echoflag ; if notechoflag 
0026   101E F0 05         beq dnormal ;  then normal echo 
0027   1020 AD CE 06      LDA SBD  ; else set TTY bit PB0 to 
0028   1023 29 FE         AND #$FE ; PB0 low
0029   1025 29 DF       dnormal AND #$DF ; PB5 low
0030   1027 8D CE 06      STA SBD ; 
0031   102A 20 5A 1E      JSR GETCH ; get character from input
0032   102D 48            PHA ; save
0033   102E AD CE 06      LDA SBD ; set TTY bit PB0 and PB5
0034   1031 09 21         ORA #$21 ; high
0035   1033 8D CE 06      STA SBD 
0036   1036 68            PLA ; restore received character
0037   1037 60            RTS 
0038   1038               .end
0039   1038               
0040   1038               tasm: Number of errors = 0

Note that using tape I/O will leave PB5 low, allwoing echo, only set high when the program calls DGETCHAR.

Does DGETCHAR work on the KIM-1 clones?

Micro-KIM and PAL-1: yes, the hardware is identical, IC numbers are different
Corsham Technology: no, PB5 is not used.


Convert to Papertape V2.2

On the Utilities page I have two programs to convert to MOS Technology papertape format: KIMpaper, a command line utility, and ConvertHexFormat, a GUI app.

All in Freepascal/Lazarus source format, and tested on Linux (Raspberry PI OS) and Windows 10 64 bit. So the programs will run everywhere Lazarus is available (MS DOS, WIndows, Linux Mac OS).

KIMPAPER  is written at the time the Micro-KIM appeared. CLI utility.  Supports Binary to/from Papertape.  Still runs fine on all platforms supported by Freepascal (Windows, MS DOS, Linux etc) after a recompilation, source available.

ConvertHexFormat is a more recent GUI utilitilty with many more 8 bit hex formats as input and output.

There were some bugs of course in older versions. V2 added the ability for multipart hex formats, records having a non-consecutive load address. That seems to wok fine since V2.1
In 2.2 a bug in MOS Papertape format for bigger files is fixed, the end-of-file record (record type 00, total line count) had a bug in the checksum calculation. KIMPAPER is and was correct in the calculation.
But in ConvertHexFormat it was wrong (as it still  is in the well known srec utility in the Unix world!).


PC utilities updated

The PC utilities page has seen an update of th4 Conversion hex formats utility.

Programs to manipulate the binary and hex formatted files of interest for SBC owners. Intel hex, MOS papertape, Motorola S-record, binary, hex conversion fort eh 8 bit world.
Runs on Windows, Linux, Mac due to Lazarus and Freepascal. Source included.


Adding I/O to the KIM-1

By Bob Applegate

Adding I/O devices that don’t need much address space. On the KIM-1, the space from 1400-17FF is grouped into the K0 block but only 17xx are used, leaving 1400-16FF open for use. To decode that range into four blocks of 256 bytes is easy using a single chip and a few signals from the KIM Clone expansion bus:

Everyone has a 74LS138 in their parts collection, so just connect a few signals from the expansion bus and use one of the three signals from the 138 to decode which block you want to use. Use the A0-A7 address lines to decode into smaller pieces.


Using KIM Clone I/O

By Bob Applegate

KIM Clone I/O Not Receiving Serial Data

While testing the KIM Clone I/O Board I was using a real ASCII terminal and everything was working exactly as it should. After the board was in product a dedicated tool was written to run complete tests of the board and the serial port was no longer receiving data.

As it turns out, it is possible to set the various jumpers on the board so that the DCD line on the 6850 is floating, and it tends to float to a state where it ignores incoming data. My test jig simply loops back pins 2 and 3, leaving DCD unconnected.

The easiest solution is to pull the jumper off JP8, then place it between pins 6 and 7 on JP10. This forces the DCD to ground, which allows the receiver to work as expected.

Depending on your application, whatever is connected to the DB-9 might pull DCD to the active state which also allows the receiver to work properly.

Future revisions of the board will have a pull-down resistor on both DCD and CTS so unconnected inputs will default to the proper levels for normal operation of the ACIA.

Using I/O lines

Like the original KIM-1, there are 16 I/O lines on the KIM Clone that can be used for your own projects. They are brought to the connector labeled “SD SYSTEM” along the top edge of the board and were meant to plug into one of our SD Card Systems for program storage. However, they are general purpose I/O lines which can be freely used for other things if the SD system is not used.

This is a portion of the schematic showing which pins on the 6532 are connected to which pins on the connector:

Don’t worry about the signal names associated with the various lines, they are the names of those signals when an SD Card System is attached.

As you can see, there are 16 IO lines, 2 ground lines, and 2 lines with +7.5… if you want to draw power from this connector for TTL/CMOS circuits then you need to add your own +5 volt regulator! D2 prevents back-feeding power from the connector back into the KIM Clone.

On the circuit board, pins 1 and 2 are labeled but are covered by the connector, so here is a reference:

All of the odd numbered pins are on the “bottom” row while even numbered pins are on the top. Ie, the top row has pins 2, 4, 6, etc, while the bottom row has 1, 3, 5, etc. Displaying the circuit board traces on the bottom layer of the board you can clearly see the ground and power lines connected to the pins on the far right:

The datasheet for the 6532 RIOT chip is readily available here.

To program the chip you basically need to set the direction of each pin of the I/O port of interest (Port A or Port B), then set the data or read the data. The base address of the chip is 1700 (hex). There are four registers:

Address Use
1700 Data register A
1701 Data direction register A. Setting a bit to 1 makes it an output bit, 0 makes it an input.
1702 Data register B
1703 Data direction register B. Setting a bit to 1 makes it an output bit, 0 makes it an input.

An Example
I needed to test experimental address decoder logic and found it was easier to just plug it into the I/O ports and write some code on the KIM Clone to simulate the addresses and display what the decoder logic did:

Port A simulates address lines A11-A16 and port B has the three decoder outputs (/RAM, /IO, /EEPROM). A small program simulates all possible values of the five address bits, displays the address, reads the decoder inputs and then displays which are active. In about an hour I was able to fix one minor bug in the decoder design and perform a full unit test on how it works. Certainly not a fancy example of using I/O ports, but sometimes it far faster to build a small circuit and use software to test it rather than building a lot of hardware and manually debugging it all.

KIM Clone software


Look at the KIM-1 software page for a wide offer of KIM-1 software, suitable also for the KIM Clone.

KIM Monitor

The Corsham variant of the KIM Monitor is for the most part made up of the code in the 6530-002 ROM. The 6530-003 (audio cassette save/load) ROM was removed.
Placed in the main ROM of the KIM Clone.

List of changes to the original KIM-1 ROMs:

  1. Removal of the (6530-003) code to save/load from cassette tape.
  2. Lunar Lander (First Book of KIM) added.
  3. Farmer Brown (First Book of KIM) added.
  4. New X command from TTY to enter the Corsham Technologies xKIM extended monitor.
  5. L command also loads Intel hex file (from input, send file in terminal emulator, like you can do with papertape files)

There is no technical reason why you could not load the original KIM 6530-002 and 6530-003 ROMs into the KIM Monitor EPROM. The Corsham KIM Monitor is a bit more convenient.

Source of Corsham KIM Monitor

xKIM Monitor
Placed in the extra EEPROM

Extra commands in teletype mode.

  ? ........... Show this help
  D ........... Disk directory
  E xxxx ...... Edit memory
  H xxxx xxxx . Hex dump memory
  J xxxx ...... Jump to address
  K ........... Go to KIM monitor
  L ........... Load HEX file
  M xxxx xxxx . Memory test
  P ........... Ping disk controller
  T ........... Type disk file
  ! ........... Do a cold start

Source of Corsham KIM Monitor

Corsham eXtended KIM Monitor Manual
Source of Corsham KIM Monitor

Microsoft 8K BASIC
Download the original KB9 binary, dumped from official Micro-soft (no typing error, original name!) cassette audio tape, and documentation from this site.

Or build your own version from the pagetable blog (for which my KB9 was the KIM-1 version as input!) Install the CC65 package, then run the command, then look at the file tmp/kb9.bin, You’ll need to convert that raw binary image to a file suitable for downloading to the KIM, see the KIM-1 tools for a utility. All of these needs at least 12K of RAM starting at $2000 in the KIM-1

Binaries of KB9

Here is a file suitable for downloading onto a KIM-1. It loads at $2000 but to run it you’ll need to start at $4065. Use the L command in KIM-1’s monitor, then upload the file. I strongly suggest that you change your terminal emulator so it adds a 200 ms pause at the end of each line. Once it loads, run it by going to 4065 and running it.
4065 G
To see the easter egg, answer “A” when it asks for memory size.

Original KIM-1 Microsoft BASIC KB9

This is still experimental but I have a version which uses functions in the xKIM monitor (present on the KIM Clone or on the 60K RAM/EPROM board) to save/load from the SD Card System. It also has a DIR command. This is an Intel HEX file and must be loaded from the xKIM “L” command:

Download hex file xkim

This loads and runs at $2000.

Tom Pittman’s Tiny BASIC
Tom distributed a very small BASIC that needed about 3K to run, and was available on paper tape for $5!!! He has quite a bit about it at:

Here is the source code, listing, and binary to my disassembly which includes a lot of comments and notes from Tom Pittman:
Tiny Basic source
Tiny Basic listing

A ready-to-run binary which loads at $0200 and should have RAM up to $13FFL
Tiny Basic hex file

Bob’s Tiny BASIC
by Bob Applegate

All the early issues of Dr Dobb’s Journal discussed using using an intermediate language (IL) to write a general interpreter, then writing a BASIC interpreter using the IL language. Nobody used this except for Tom Pittman. I liked the idea and about five years ago wrote my own BASIC using that approach. It is buggy, but the sources are on the Corshams github so anyone can take them, hopefully debug things, and put fixes back in place. My version also has commands to save/load programs to/from a Corsham Technologies’ SD Card System.

Source and documentation of Bob’s Tiny Basic

And a binary version that can be run starting at address 0200

AS65 assembler

The software above was assembled with the AS65 Kingwoods assembler, a command line utility for Windows (including 10).

Download here AS65

A typical build for a bianry and hex output would be:

REM Build xKIM
as65 -l -s2 xKIM.asm
as65 -l xKIM.asm

Type “as65 ?” for help

Memory Test

by Bob Applegate
This memory test was originally based on Jim Butterfield’s memory test program in the First Book of Kim, but has grown a bit. This now tests every memory location using a rolling 9-bit pattern. Ie the pattern repeats every 9 bytes, so this will detect most shorted address line problems. I use this to test memory boards, so it will run forever unless an error is detected. At the end of each pass, a ‘.’ is printed.

This does output to the TTY port, so if you’re only using the default KIM display, the output functions will need to be tweaked. Not hard to do, but I didn’t need it.

Written February 2006 by Bob Applegate, but it uses some bits of code from Jim Butterfield, and Ross Archer
Memory test soource and hex file

Microchess Peter Jennings
Adapted for KIM clone by tennyson.neil

Source and hex file Microchess for the KIM clone


Corsham KIM Clone peripherals

KIM Clone Motherboard

KIM Clone Motherboard User Manual
KIM Clone Motherboard schematic

KIM Clone Proto Board

KIM Clone Proto Board User Manual

KIM Clone I/O board

KIM Clone I/O Board Manual
KIM Clone I/O board Rev 3 Schematic

KIM-1 I/O Board

KIM-1 I/O Board Manual
KIM-1 I/O Board schematic

KIM-1 60K RAM/ROM Board

KIM 60K RAM ROM Manual
KIM 60K RAM ROM Schematic

KIM Clone information

KIM Clone User Manual Rev 2
KIM Clone Rev 2 Circuit Diagram
KIM Clone User Manual Rev 5
KIM Clone Rev 5 Circuit Diagram
Building a KIM Clone, Tech tips

Fix for KIM Clone Single-Step Problem

Rev 1B and rev 2 boards have a problem where single-step mode does not work. It works for old 6502s but not for newer ones nor 65C02. The solution was very simple: add a .001 uf capacitor across U16 pins 7 and 8. All assembled KIM Clones now have the modification and future revisions of the board will have the capacitor on the motherboard.