After RESET the baudrate is determined by measuring the length of the start bit of an incoming serial character. This means any character is usable where the first data bit is the opposite of the start bit. The KIM-1 User manual suggest RUBOUT ($7F 1111111) but ENTER ($0D 0000 1101) also works fine. SPACE ($20 0010 0000) for example does not work, any character with an odd value is OK.
0612 1C2A A9 FF LDA #$FF ; COUNT START BIT
0613 1C2C 8D F3 17 STA CNTH30 ; ZERO CNTH30
0614 1C2F A9 01 LDA #$01 ; MASK HI ORDER BITS
0615 1C31 2C 40 17 DET1 BIT SAD ; TEST
0616 1C34 D0 19 BNE START ; KEYBD SSW TEST
0617 1C36 30 F9 BMI DET1 ; START BIT TEST
0618 1C38 A9 FC LDA #$FC
0619 1C3A 18 DET3 CLC ; THIS LOOP COUNTS
0620 1C3B 69 01 ADC #$01 ; THE START BIT TIME
0621 1C3D 90 03 BCC DET2
0622 1C3F EE F3 17 INC CNTH30
0623 1C42 AC 40 17 DET2 LDY SAD ; CHECK FOR END OF START BIT
0624 1C45 10 F3 BPL DET3
0625 1C47 8D F2 17 STA CNTL30
0626 1C4A A2 08 LDX #$08
0627 1C4C 20 6A 1E JSR GET5 ; GET REST OF THE CHAR,
0628 1C4F ; TEST CHAR HERE
What happens here:
– bit 7 (PB7) is tested until it becomes 0 (BIT SAD and BMI DET1 loop)
– the time is counted and kept in CNTH30 and CNTL30
– bit 7 is tested for becoming 1 (LDY SAD and BPL DET3)
– the rest of the character is read in by jumping into GETCH , the actual character received is not tested.
1006 1ED4 ;
1007 1ED4 ; DELAY 1 BIT TIME
1008 1ED4 ; AS DETERMINED BY DETCPS
1009 1ED4 ;
1010 1ED4 AD F3 17 DELAY LDA CNTH30 ; THIS LOOP SIMULATES
1011 1ED7 8D F4 17 STA TIMH ; DETCPS SECTIONS AND WILL DELAY
1012 1EDA AD F2 17 LDA CNTL30 ; 1 BIT TIME
1013 1EDD 38 DE2 SEC
1014 1EDE E9 01 DE4 SBC #$01
1015 1EE0 B0 03 BCS DE3
1016 1EE2 CE F4 17 DEC TIMH
1017 1EE5 AC F4 17 DE3 LDY TIMH
1018 1EE8 10 F3 BPL DE2
1019 1EEA 60 RTS
1020 1EEB ;
1021 1EEB ; DELAY 1/2 BIT TIME
1022 1EEB AD F3 17 DEHALF LDA CNTH30 ; DOUBLE RIGHT SHIFT OF DELAY
1023 1EEE 8D F4 17 STA TIMH ; CONSTANT FOR A DIVE 2
1024 1EF1 AD F2 17 LDA CNTL30
1025 1EF4 4A LSR A
1026 1EF5 4E F4 17 LSR TIMH
1027 1EF8 90 E3 BCC DE2
1028 1EFA 09 80 ORA #$80
1029 1EFC B0 E0 BCS DE4
The actual delay routines use the same logic as DETCPS. IN DEHALF the delay time is divided by 2 and jumped into DELAY.
KIM usernotes vol 06
Jim mcClahanan notes:
The PAL-1 (just like the KIM-1) uses a ‘soft UART’ or ‘bit banger’ for its serial I/O. I’m not a fan of this approach, but at the same time it demonstrates what could be accomplished with a minimial amount of hardware. The PAL-1 automatically figures out the appropriate delay between bits of the serial character when you press enter after a reboot. I have found that decreasing the value actually significantly improves the odds of an error-free load of larger punchtape format files. Below is a table for values found and suggest for $17F2.
Baud Found New
300 $EA $E8
1,200 $37 $35
2,400 $1A $18
4,800 $0B $0A
I haven’t tried to optimize the delay values. Right now I’m using 5 ms between characters and 500 ms between lines when doing 8K transfers and with the modified values I usually am successful. With the default values, it seemed like even with longer delays things would slip out of synchronization at some point more often than not on large transfers.
0979 1E9E ; PRINT 1 CHAR CHAR=A
0980 1E9E ; X IS PRESERVED, Y RETURNED = FF
0981 1E9E ; OUTSP PRINTS 1 SPACE
0982 1E9E ;
0983 1E9E A9 20 OUTSP LDA #$20
0984 1EA0 85 FE OUTCH STA CHAR
0985 1EA2 86 FD STX TMPX
0986 1EA4 20 D4 1E JSR DELAY ; 10/11 BIT CODE SYNC
0987 1EA7 AD 42 17 LDA SBD ; START BIT
0988 1EAA 29 FE AND #$FE
0989 1EAC 8D 42 17 STA SBD
0990 1EAF 20 D4 1E JSR DELAY
0991 1EB2 A2 08 LDX #$08
0992 1EB4 AD 42 17 OUT1 LDA SBD ; DATA BIT
0993 1EB7 29 FE AND #$FE
0994 1EB9 46 FE LSR CHAR
0995 1EBB 69 00 ADC #$00
0996 1EBD 8D 42 17 STA SBD
0997 1EC0 20 D4 1E JSR DELAY
0998 1EC3 CA DEX
0999 1EC4 D0 EE BNE OUT1
1000 1EC6 AD 42 17 LDA SBD ; STOP BIT
1001 1EC9 09 01 ORA #$01
1002 1ECB 8D 42 17 STA SBD
1003 1ECE 20 D4 1E JSR DELAY ; STOP BIT
1004 1ED1 A6 FD LDX TMPX ; RESTORE INDEX
1005 1ED3 60 RTS
A subroutine that sends out an 8 bit character via the serial TTY output followed by one stop bit via bitbanging to PB7. Contrary to GETCH this allow 8 bits characters.
The receiving device should be set to 8N1 (8 databits, no parity, 1 stopbit)
Timing is done with the 1 bit DELAY routine.
A and Y are lost, X preserved.
What happens here?
– The character to send is stored at zeropage CHAR.
– save X
– A 1 bit delay, just to be sure
– set PB7 to the start bit 0
– a 1 bit delay
– get current value of PB7 (LDA SBD and AND #$FE)
– shift databit into carry (LSR CHAR)
– set carry to PB7 (ADC #$00 and STA SBD)
– delay 1 bit
– repeat for 8 databits
– set stop bit 1
– delay 1 bit, leave PB7 in rest state
– restore X
Compensate for timing
The KIM-1 character routines are quite primitive and not rebust : bit-banged, not interrupt driven, no hardware handshake so no buffering and it is CPU intensive.
When you sent characters quite fast to the KIM-1 (and that means any baud rate from 1200 to 9600, and the KIM-1 also has to do some processing like storing the record just received, it is to be expected the KIM-1 will be too late reading the next record, skip a record and sync at the next and leave the program received in chaos.
So we need to give time to the poor KIM-1.
1200 baud, 20 ms character delay, 200 ms line delay is conservative but reliable for me. It is slow ..
An example for Teraterm is shown here:
KIM usernotes vol 06
Jim McClanahan
Serial Interface
The connector that came with mine is a male DB-9. Most USB serial interfaces (or interfaces on older computers) are also male DB-9 wired as the DTE device. The PAL-1 has the pinout of a DCE, which would normally have a female DB-9 connector. To get things connected, I used a “gender changer” (DB-9 female-to-female with pins 2, 3, and 5 connected straigt through).
The PAL-1 (just like the KIM-1) uses a ‘soft UART’ or ‘bit banger’ for its serial I/O. I’m not a fan of this approach, but at the same time it demonstrates what could be accomplished with a minimial amount of hardware. The PAL-1 automatically figures out the appropriate delay between bits of the serial character when you press enter after a reboot. I have found that decreasing the value actually significantly improves the odds of an error-free load of larger punchtape format files. Below is a table for values found and suggest for $17F2.
Baud Found New
300 $EA $E8
1,200 $37 $35
2,400 $1A $18
4,800 $0B $0A
I haven’t tried to optimize the delay values. Right now I’m using 5 ms between characters and 500 ms between lines when doing 8K transfers and with the modified values I usually am successful. With the default values, it seemed like even with longer delays things would slip out of synchronization at some point more often than not on large transfers.
The hardware and the software in the KIM-1 work closely together. The tiny program, less than 2KB in the two ROMs, together with the simple hardware is very clever designed.
The KIM-1 is a complete computer with two user interfaces and data storage with a simple namespace. It is one of the first 6502 computers, and many clones or derived 6502 SBC systems are designed with more or less KIM-1 copied parts of the software and hardware. On this site you can find many examples!
On the following pages I will try to explain how all this is working together. It will not be a rewrite of the KIM-1 user manual, please read that first, but more a deeper personal dive into the software and hardware of what the makes the KIM-1 tick. It also will expect a basic knowledge of the 6502, the 6530 and digital electronics.
The KIM-1 monitor software exists of two separate parts. The 6530-002 RRIOT ROM, called KIM as separate IC, RRIOT and the 6530-003 RRIOT ROM.
The two are not written as one program, the 6530-002 routines do not need the 6530-003.
One could speculate the 6530-002 software was developed together with the LED/keyboard display and TTY interface hardware. And when that design was done,
the need for data storage for the user arose and the 6530-003 was added.
The 6530-003 only has audio tape read and write routines and uses the ports of the 6530-002 for the audio bit streams.
The 6530-002 can be used to build a standalone computer, the 6530-003 is an addon for a 6530-002 based system.
Besides sharing RAM locations in the zeropage and the RAM area in the 6530-002 RRIOT the two do not use each others routines. The 6530-003 routines only know the address of the 6530-002 START routine.
– architecture
CPU
RAM
RRIOTs
memory decoding
expendability and external access
– memory layout
– KIM-1 startup
– RESET routine
– TTY/KB selection
– the two user interfaces of the KIM-1
– TTY
hardware
routines
CLI
– LED display and keyboard
hardware
routines
CLI
– the KIM-1 file system and namespace
– the audio tape read
– the audio tape write
– missed opportunities in the KIM-1 design
– integration of main CLIs and tape routines
– tape read and write not callable as subroutines
The KIM-1 hardware is hardware echoing incoming serial characters to the output, no echo in software involved, so you cannot influence what appears on screen. Very annoying!
The KIM-1 GETCH routine is blocking, no way to check for a character coming in, like a Break. waiting.
Also quite annoying if porting other software to the KIM-1 or you want the program interruptable.
While a program is running something CPU intensive and you type something the program is not really waiting for, the characters appear on screen. Because the KIM-1 does hardware echoing of TTY input, this is unavoidable it seems
Here I present solutions for these problems in software, made possible by the genius hardware design of the KIM-1 TTY I/O.
You can have serial input wihout echo, non-blocking and even make the TTY input deaf for unwanted input.
Are they perfect? Maybe not, it is still bitbanging the incoming serial signal. It can miss the correct starting point for the incoming character bit stream.
If you want a perfect solution, you will need interrupt driven ringbuffered serial I/O with a dedicated IC like the 6850, 6511 etc.
Without this extra hardware you can achieve acceptable results with these routines.
Q-Chess 1.0 is a chess program for the KIM-1, from around 1980. The programs requires memory expansion of 8K at $2000.
The chess board is displayed at a TVT-6 (Don Lancaster) video display alongside the KIM LED Display and Keypad.
In 1981 Fer Weber, a member of the Dutch KIM User Club published an adaptation to use the program with a (video)terminal attached to the KIM TTY interface in the Dutch magazine the KIM Kenner Issue 17.
Binaries on tape and the documentation of Q-Chess were acquired in 1981 from Fer.
In March 2025 Hans Otten translated the source of the adaptations from Dutch to English in TASM format. This makes Q-Chess playable again!
COMAL is an interpreted structured language. A version for the KIM-1, Junior and DIS65 is available, distributed by the KIM Gebruikers Club Nederland as KGN COMAL in the 80ties.
KIM-1 version March 2025 by Hans Otten.
KGN COMAL V1 for the KIM-1 and clones, Elektor Junior and DOS65.
A product distributed and adapted to the Junior by the KIM Gebruikers Club The Netherlands in 1985-1987.
KGN COMAL V1.0 is for the enhanced Elektor Junior.
KGN COMAL V2.1 is for the DOS65 system.
In 2015 I saved KGN COMAL 1.0 and 2.1 binaries from Junior tapes and DOS65 disks.
With DOS65 came a very compact COMAL user manual.
In the Club Magazine KIM Kenner a Amazing Maze program is found.
Based upon these binaries and documents KGN COMAL is adapted to the KIM-1.
In this archive:
– KGN COMAL V2.1 DOS65
– binary as DOS65 program
– binary stripped, DOS65 preamble removed, binary only
– KGN COMAL
– Junior binary (load at 2000, start at 3000)
– comal junior dis.txt A partial disassembled and commented source of KGN COMAL Junior
– KGN COMAL KIM-1
– papertape of KGN COMAL KIM-1 (loads at 2000, start at 3000)
– binary of KGN COMAL KIM-1 (loads at 2000, start at 3000)
– User manual
– KGN COMAL User Manual
New, written in March 2025. Based upon the Dutch COMAL manual and observation made with the COMAL interpreter.
Word and PDF versions
– scans of the original material
4 february 2025 2025 I have built the PAl-2 kit, now designing and building a I/O card.
This information is based upon the available documentation: User manual, Schematic, BOM.
The PAL-2 is for sale by Liu Ganning at Tindie
Just followed the interactive BOM, passive components first, ICs last.
Nothing special to note, compare yours with the photo on the PAL-2 Tindie site.
Orientation of IC sockets and IC’s, check twice!
Check your soldering joints, not too much sodler, but covered with the right color solder.
And the three slider switches,: the SST keyboard one has a higher slider that the other two!
Please be careful with the Dupont power cables, double check the polarity! If in error: magic smoke!
I do not like the Dupont wires for power, serial, TTY switch. Too easy to make a mistake in the power connection.
I am now designing and building a simple I/O card for the Application connector, experimenters print, point to point wires, male pin connector to PAL-2, on board female connector for USB to Serial, power switch, TTY/Keypad switch.
That may grow later to SD or 1541 or Corsham SD card interfaces.
Video of PAl-2 #4, by Nils, running!
What is a PAL-2?
The PAL-2 is a kit for an SBC in the now large family of KIM-1 clones. Ranging from the Micro-KIM to the PCB exact replica by Eduardo Casino, all share the KIM-1 ROMs, LED display and TTY interface and the 6532 RIOT instead of the 6530 RRIOT.
What makes the PAL-2 unique:
It is a real and complete KIM-1 clone.
Available as a DIY kit with high quality components.
The layout is close to the KIM-1.
The good looking keypad is very close to the KIM-1
Application and Expansion connector with all relevant KIM-1 signals.
Lots of RAM in many configurable options.
Both RRIOTS 6532 on board.
TTY interface on TTL level, USB to TTL adapter included in the kit, quality serial!
Power can come from the USB to TTL adapter or from external 5V supply (same as for the KIM-1)
The PAL-2 differs from a KIM-1
No Audio cassette interface for file I/O circuit, but see below for a solution
Application and Expansion connector as 22×2 pinheader instead of PCB edge connectors
The signals on the Application connector are not all identical: no audio, TTY instead of 20 mA loop, decoding lines added
Not the same size PCB
The PAL-2 differs from the PAL-1:
The many quality improvements and enhancements make the base PAL-2 kit more expensive then a base PAL-1 kit.
If you expand the PAL-1 to the level of a PAL-2 you need to spend money on a motherboard, a RAM 32K, a second RRIOT kit, an RS232 cable and gender changer and a 9V power supply.
Improved keypad, with labels and look of the KIM-1
No need for a Motherboard
No external RAM module required
No external RRIOT required
E000-FFFF can be used freely from ROM expansion
The vectors (Reset, NMI, IRQ) can be placed in external ROM.
RAM decoding
The PAL-2 has a very flexible RAM memory layout, as shown in the next parts of the schematics:
Internal ROM and external ROM
The PAL-2 has a 2K ROM with the KIM-1 monitor. Since there is no audio in and out circuitry, the ROM from 1800-1BFF could be used for other programs, like the KIM Clone by Corsham Technology (Which also did not have the audio circuitry). The 28C16 is easy to program.
One of the first expansions that is to be expected is an external 8K ROM. The decoding for this ROM, e.g. an 28C64 is already present on the connectors and in the decoding circuit.
The decoding signals are 8K7_SELECT (CE on 28C64) and 8K7_ROM (OE on 28C64). Just the 28C64 IC has to be connected to address and data lines.
DIP Switches
The PAL-2 has a full 64K address decoder onboard, while the KIM-1 has only a 5K onboard address decoder for expansion. These two DIP switches on the PAL-2 are designed both to expand the KIM-1’s RAM and to maintain compatibility with its basic configuration.
On the PAL-2, the 4-bit DIP switch enables the onboard K1 to K4 RAM spaces, with each bit controlling 1K of memory. The K1 to K4 naming follows the definitions in the KIM-1 user manual, covering the address range from $0400 to $13FF. If all four DIP switches are set to ON, the entire 5K RAM space becomes available to the system.
The 8-bit DIP switch controls the “big segment decoder,” with each bit corresponding to an 8K memory block. These blocks range from 8K0 to 8K7, with 8K0 ($0000 to $1FFF) being the KIM-1’s default occupied address space. Since the PAL-2 is a KIM-1 replica, if you want to use it as a KIM-1 system, 8K0 must be set to OFF to allow the onboard KIM-1 logic to function. However, if you’re building a completely new system on the PAL-2, you can set 8K0 to ON to bypass the KIM-1’s onboard logic for the lowest 8K of memory.
The 8K1 block starts at $2000, controlling an 8K space beyond this address, and so on. If a bit is set to ON, the KIM-1 system will be able to access the corresponding address space, which will function as RAM. If a bit is set to OFF, the KIM-1 system will still work, but with reduced available address space. When performing expansion or add-on modifications on the PAL-2, you may need to disable certain address spaces to prevent the onboard logic from accessing the RAM chip.
The 8K7 block, representing the highest 8K memory segment, offers additional flexibility on the PAL-2. If 8K7 is set to ON, you can choose how to use this space—either as RAM or ROM—by adjusting the 8K7 SEL switch. For example, if you write a program (such as a tiny OS for the KIM-1) and burn it onto a ROM chip—similar to the well-known Jim’s ROM (but smaller)—you can connect the ROM to the PAL-2 (with some additional hardware, which is still under development). To boot from your ROM chip, use the VECTOR SEL switch to select ROM, allowing the system to retrieve the top three vectors from the ROM chip instead of the onboard KIM-1 ROM.
Application and Expansion connectors
KIM-1 Application connector
Differences on the Application connector with the KIM-1:
AUDIO IN -> 8k7_SELECT
AUDIO OUT LO -> 8K7-ROM
TTY in and out now at TTL level for USB to TTL converter
TTY PTR and KYBD, +1wV, AUDIO OUT LO not connected
This means, even if the edge to pin connector issue is solved, the standard KIM-1 I/O boards will not work for TTY and audio.
The expansion connector is identical to the KIM-1.
KIM-1 Expansion connector
Power supply
Power has to be applied in the standard KIM-1 manner to the application connector Pin 1 = GND, pin A = 5V. Note that reversing these pins will mean the dead of the PAL-2!
Expansion
As a first suggestion for a PAL-2 extension I see a board connected to Application and Extension connectors with:
Power switch
28C64 (or bigger, switchable in 8K chunks) EEPROM
Connector for the USB to TTL
External power connector, switchable between this and USB to TTL connector
TTY/LED keyboard switch
connector for the Application I/O ports PA0-PB7
Power switch
Optional:
Pin connector for PAL-1 Cassette Interface audio board
The KIM-1 has hardware and software in the 6530-003 ROM to save and dump files on audio tape.
Not used by most KIM clone users, so it is not present on the Corsham KIM Clone and the PAL-2.
But it is possible to have the audio in/out with one patch wire between pin 11 of U12D and the application connector!
KIM-1 Audio and TTY circuit
PAL-2 Audio and TTY circuit
On the KIM-1 circuit you can see the audio I/O is seen by the CPU at pin PB7 of the 6530-003. It is either an input or an output under control of the audio routines in the ROM.
The U26 (also present on the PAL-2 as U12d) is an open collector NAND feding PB7. On one input of U26 is PB5 from the 6530/32 (inverted by U16 (KIM-1_ or U10D (PAL-2), on the other is the output of the audio circuit generating TTL pulses from the audio sound input. This way PB7can be used both as input and output.
The PAL-2 and the KIM-1 has on the extension connector the signal PLL(_TEST), which is connected to U126/U12D. This is on the KIM-1 the output of the audio circuit.
So we have audio in (at TTL level) on the PAL-2 covered!
Audio out is available at PB7 at TTL level. With a patch wire between PB7 (or pin 11 of the U12D) to the application connector.
With the PAL-1 Cassette interface we can have the PAL-2 read and write KIM-1 audio cassette files this way. PLL_TEST to TAPE and a wire from PB7 to PB7 is all you need to connect to the Cassette Interface (and GND and +5V ofcourse).
Leaving R9 out of the Cassette Interface may be a good idea, there is already a pullup in the PAL-2 of 1K.
Physical Dimensions
The connector on the PAL-2 is a 2.54 mm pitch 2×22 female pin header connector.
The dimensions of the PAL-2 PCB are 168 mm x 218 mm.
Next two images show the connector, first shows the distance between the two connectors, while the second shows the distance from the PCB edge to the connector’s outer side.