post

KIM-1 programs by Nils

Nils a.k.a. netzherpes typed in a number of KIM-1 programs to run on his PAL-1, the KIM-1 compatible clone.
Not only does he types them in in assembler, some even by contacting the original author!, tests the programs and also provides source and ready to run binaries or papertapes.
And he draws nice looking cover images!

On his github page he has the most recent versions and adds new programs regularly.
Also checkout his blog!

Here a summary of the programs:

Banner for KIM-1

KIM-1 Banner
by Jim Zuber
from KIM USER NOTES #18

Download here!

Battleship

You have 20 shots to detect a 3×1 ship on a 8×8 grid. The ship can be aligned horizontal, vertical or diagonal.
How to play: Enter the coordinated and fire (Button F). If you hit the ship, the mostright counter will jump to 01.
If you hit all 3 coordinates of the ship, you won, the display will show “dEAd” and the number of shots used.
(c) 1978 Roland Kushnier (orig)
(c) 1979 Jody Nelis (bugfix)

Download here!

Target 1 for KIM-1

Little shooting game for the KIM-1
June 18th, 1979
(C) Fer Weber

Download here!

Target 6 for KIM-1

The 6 column Version of Fer Webers Target1 Shooter Game (https://github.com/netzherpes/Target1-for-KIM-1)
Author Fer Weber
published in KIM Kenner 8 on 18.06.1979

Download here!

Telefonbuch for KIM-1

original title: “Datensuche”
by Herwig Feichtinger
(c) 1981 in Anwendungsbeispiele für den Mikroprozessor 6502

Download here!

Phonebook 2.0 for KIM-1

original title: “Datensuche”
by Herwig Feichtinger
(c) 1981 in Anwendungsbeispiele
für den Mikroprozessor 6502

Download here!

Pocket Calculator for KIM-1

by Siep de Vries, KIM Club The Netherlands
INPUT/OUTPUT IS EITHER TELETYPE
OR KIM KEYBOARD AND DISPLAY

Download here!

Tunesmith for the KIM-1

(c) 1979 Anthony T. Scarpelli
found in micro 6/79

Download here!

KIM-Piano

a silly small Piano for your KIM-1
KIM Piano
(c) by Peter Engels 1979 *

plays whole notes from C to D
by pressing the buttons 0-F.
Download here!

LEDIP a text editor for the KIM-1

The author of the program, Kiumi Akingbehin, Professor at the Michigan University

Download here!

KIM-1 Dungeons and Dragons Dice Simulator

(c) 29.7.80 Myron A. Calhoun
Manhattan, KS

Download here!

TTY rapid Dump/Load

an extension to M.Gönners hex Loader by Bruce Nazarian

Located in Compute II June 1980
Download here!

Baseball-for-KIM-1

‘Bob’ Leedom published another game called Baseball in the KIM user notes issue 16

Download here!

MatchThis-for-KIM-1

by Gino F. Silvestri
A Simon says game for the KIM-1

Download here!

KIM Venture walktrough

This is a walkthrough of one of the most amazing computer games in history.
KIMventure is a (colossal cave like) adventure game for the KIM-1 that fits in only 1 (ONE) KB of RAM. It offers 24 room to explore with a lot of traps and riddles to solve. It was programmed in 1979 by Robert Leedom with pen and paper (no assembler etc.)

Download here!

Hexpawn – another KIM-1 game from 1978


Download here!

post

Books for the 6502: KIM-1 and more

KIM-1, AIM-65, SYM-1 and other 6502/65C02/65C816 related books.

A mix of English, German and Dutch books.

On my bookshelf I have quite a collection of books on the 6502 family.

Note that manuals and books that come with systems are shown on the pages of the corresponding system!

Microprocessor Systems Engineering
R.C. Camp, T.A. Smay, C.J. Triska
AIM 65 System 65 parts
6502 Software Gourmet Guide and Cookbook
6502 Users Manual
AIM 65 Laboratory Manual And Study Guide
Anwendunsgbeispiele fûr den Microprozessor 6502
Microprocessor_Fundamentals KIM-1
Best of Micro Volume 1 1978
Best of Micro Volume 2 1979
Best of MICRO 3, AIM 65 SYM-1 KIM-1 part June 1979 May 1980
Compute’s Machine Language for Beginners
Compute’s The Second Book of Machine Language
Programming a Microcomputer 6502
Programmieren von Mikrocomputern CPU 6502 (Skriptum)
How to Build a Microcomputer .. and really Understand It!
Mikrocomputer ohne Ballast
Micro Principles KIM-1 user guide chapter 8
Digitaalschakelen met de KIM-1
6502 Assembly Language Programming
6502 Programmieren in ASSEMBLER
Microcomputer Experimentation with the MOS Technology KIM-1
6502 Machinetaal Subroutines
6502 Assembly Language Subroutines
Microcomputer experimentation with the AIM 65
Machine Language Programming Cookbook part 1
Machine Code for Beginners
Microcomputer Systems Principles Featuring the 6502 KIM
Beyond Games: System Software for your 6502 Personal Computer
Assembly Language Programming
Using 6502 Assembly Language
6502 Machine Code for Humans
Programming the 65816 including the 6502, 65C02 and the 65802
Programming the 65816 including the 6502, 65C02 and the 65802
Forth Programming
Programming the 65816
Programming and Interfacing the 6502 with Experiments
Synertek 1981-1982 Data Catalog
Synertek DataBook 1983
Third Book of OSI
TSC 6502 Games Package 1
TV Typewriter Cookbook
Zaks 6502 Anwendungen
6502 Games
6502 Applications
Advanced 6502 Programming
Fortgeschrittene 6502 Programmierung
Programmierung des 6502
Programming the 6502
6502 Applications book
Programmeren van de 6502
Microprocessor Interfacing Techniques
Microprocessor Concepts and Applications
Publisher: Lab-Volt
6502 Assembler-Kurs für Beginner
6502 Machine Code For Beginners
A low-lvel language for use on the MOS 6502 Microcomputer
6502 Microcomputer Programmierung
Programmieren in Maschinensprache 6502
The Giant Handbook of Computer Projects
First Book of KIM
The First Book of KIM-1 in PDF format
The First Book of KIM-1, part in text format
The First Book of KIM-1 in HTML format
Sources of The First Book of KIM-1 in source and papertape format, Jeff Tranter
First Book of KIM-1 for SYM-1
Rockwell Produktübersicht in deutsch
Rockwell Microelectronic Data Devices Catalog 1979
1981 Rockwell Electronic Devices Division Data Book
1984 Rockwell Data Book
1985 Rockwell Data Book
1987 Rockwell Controller Products Databook

KIM-1 Simulator breakpoints and watches

The KIM-1 Simulator is updated to version 0.10.1.

Changes in this version are an extension to the “Run to” execution

    • up to 10 breakpoints are now possible instead of one
    • up to 10 watch points addresses. When the CPU accesses the watch point execution stops
    • Save file to memroy bug fixed (thank Nils!)

Watch and breakpoints can be enabled or disabled at will, even while the program is running.

Telefonbuch

Found in Hobbycomputer #1 (c) 1980 Herwig Feichtinger (of EMUF fame!) improved by Nils Andreas, a phonebook
In fact, it is a searchable text database. Full article here

The program is written, probably by hand, Herwig Feichtinger in the German magazine Hobbycomputer, Issue 1.

On the github page of Nils you can find source and executables.

Hobby Computer magazine

A German magazine, from Franzis Verlag. Sonderheft der ELO Funkschau Elektronik


Hobbycomputer 1

KIM-1 articles llike Telefonbuch. See also the page on Telefonbuch restauration.

 

 

 

 

 

 

Hobbycomputer 2

KIM-1 and more general 6502 articles.

 

 

 

 

 

 

Telefonbuch

Found in Hobbycomputer #1 (c) 1980 Herwig Feichtinger (of EMUF fame!) improved by Nils Andreas, a phonebook

On the github page of Nils you can find source and executables.

In fact, it is a searchable text database.

The program is written, probably by hand, Herwig Feichtinger in the German magazine Hobbycomputer, Issue 1. Available on archive.org.

I took the source as typed in by Nils, added the comments from the (see below) listing in the article and made sure it was binary compatible with the listing. There are some problems with the first entry in the database.

Source, listing, article, binary, papertape of original version of Telefonbuch

; Target assembler: TASM 
;*****************************
;* Telefonbuch               *
;* (c) 1979                  *
;* Herwig Feichtinger        *
;*****************************
; typed in and checked by Nils Andreas
; comments entered from German listing into source
; checked for being binary compatible with original listing in HobbyComputer 1 1979
;
; Note that getch in KIM-1 returns with Y = $FF, used in this program to save two bytes?
; Testcase for the KIM-1 Simulator, which now emulates this getch behaviour
;
; Hans Otten, 15 december 2021
; 
CR     =       $0d             ; carriage return
esc     =       $1b             ; escape

crlf    =       $1e2f           ; KIM-1 print cr 
getch   =       $1e5a           ; KIM-1 read char for tty
space   =       $1e9e           ; KIM-1 print space tty
outch   =       $1ea0           ; KIM-1 print car on tty
incpt   =       $1f63           ; increment pointer
;
; zeropage
;
savy    = $f9
tablep  = $fa                   ; pointer into table 
bufferp = $df                   ; buffer
table   = $0200                 ; table starts here
;
         .org    $0000
;
start:   lda     #(table & $ff) ; low byte table address
         sta     tablep
         lda     #(table >> 8)  ; high byte table address 
         sta     tablep + 1     ; 
         ldx     #$17           ; 17 bytes clear
         lda     #$00
buffer:  sta     bufferp,x      ; clear buffer
         dex
         bne     buffer
;         
read:    jsr     getch          ; get ascii character
         cmp     #esc           ; escape? 
         bne     chkend         ; no
         iny                    ; yes, y = 0
chkfre:  jsr     incpt          ; increment table pointer 
         lda     (tablep),y     ; query buffer
         bne     chkfre         ; free space in buffer?
input:   jsr     getch          ; get ascii character
         iny                    ; y=0
         cmp     #esc           ; escape?
         beq     start          ; yes, back to begin
         sta     (tablep),y     ; no, store in table
         jsr     incpt          ; increment table pointer
         jmp     input          ; and again

chkend:  cmp     #CR            ; return?
         beq     zzz            ; yes, line ready
         sta     bufferp +1,x   ; no, store char in buffer
         inx                    ; increment buffer index
         cpx     #$15           ; is $15?
         bne     read           ; next character
;
zzz:     nop                    
         nop
;
newline: jsr     incpt          ; table after return
         ldy     #$00           ; search for character
         lda     (tablep),y     ; in table           
         beq     printquest     ; 
         cmp     #CR            ; found?
         bne     newline        ; no, search again
found:   ldx     #$00           ; yes, compare character in table
compbuf: iny                    ; with character in buffer
         lda     bufferp +1,x   ; no, compare table and buffer
         beq     printline      ; show it
         lda     (tablep),y
         cmp     #CR            ; return?
         beq     zzz
         cmp     bufferp +1,x   ; next character
         bne     found
         inx
         bne     compbuf
;         
         nop
         nop
;
printline:
         jsr     crlf           ; new line
         ldy     #$01
loadchar:
         lda     (tablep),y     ; load character from table
         beq     printquest     ; zero is ready
         cmp     #CR            ; return?
         beq     zzz            ; end of table entry
         sty     savy           ; save Y
         jsr     outch          ; and print character
         ldy     savy
         iny                    ; increment Y, next
         bne     loadchar       ; load new character
printquest:
         jsr     crlf           ; print return
         lda     #'?'           ; print ?
         jsr     outch          ; 
         jsr     space          ; print space
         jmp     start          ; return
;
        .end

Here the pages where the program is described and the listing shown.

Update to the KIM-1 Simulator

Nils, a very enthousiast PAL-1 user discovered in an old German magazine, 1979, HobbyComputer 1, a small phonebook program for the KIM-1.
It is a command line utility, extremely small and quite clever. See the post about it here.

So he entered the code in assembler and did some tests on his PAL-1 (it worked) and in the KIM-1 Simulator, which was not working.
He found the ‘database’ corrupted.

Of course I had to look at it and see what was going on. It had to be something about using zeropage pointers into the database.
And it was. In the source an instruction appeared:

INY  ; Y = 0

followed by an indirect addressing, Y into the database and preceded by a call to getch, reading a character from the keyboard.
Y was not used in the program before, so in the Simulator it was uncertain what the value was.

GETCH is known to destroy the Y register, delivering the character in register A. How is unspecified.
In the KIM-1 Simulator the KIM-1 GETCH is patched to the ACIA routines of the emulated 6850 serial interface.
Those routines do not use Y, so it is left untouched.

So time to study the KIM-1 routines. In the delay a bit routine the Y register is filled with the final state of a counter, TIMH.
It looks like the decrement ends with the value $FF, when the BPL becomes false, the whole purpose of the use of Y seems to determine that end of the loop?

 1ED4  AD F3 17  DELAY   LDA   CNTH30                           
 1ED7  8D F4 17          STA   TIMH
 1EDA  AD F2 17          LDA   CNTL30
 1EDD  38        DE2     SEC   
 1EDE  E9 01     DE4     SBC   #$01 
 1EE0  B0 03             BCS   DE3  
 1EE2  CE F4 17          DEC   TIMH
 1EE5  AC F4 17  DE3     LDY   TIMH
 1EE8  10 F3             BPL   DE2
 1EEA  60                RTS

Anyway, the KIM-1 Simulator 0.9.4. GETCH routine now returns with Y=$FF and the phonebook program seems to work.

Microsoft Basic for the KIM-1 KB-6

I know KB6 existed. The ‘6’ stands for the precision in digits of the floating point number. In the documentation KB-6 is described.
Never seen a version in the wild. I know KB6 existed. The ‘6’ stands for the precision in digits of the floating point number. In the documentation KB-6 is described. Never seen a version in the wild. So the reconstruction here is not checked with the original, addresses in the reconstruction from the linker differ from the documentation.”>So the reconstruction here is not checked with the original, addresses in the reconstruction from the linker differ from the documentation.

Microsoft Basic for the KIM-1: KB9 update

More information on KB9 and a new faster and smaller version

Microsoft KB-9 Basic

Microsoft Basic for the KIM-1 (KB-9)

On this page you will find:


KB-9 stands for Microsoft Basic V1.1 for the KIM-1  with 9 digits precision. Actually, when you run it, it is called MOS Tech 6502 Basic v1.1 Copyright 1977 by Microsoft Co.
The ‘9’ stands for 9 digit precision floating point numbers. A KB-6 (6 digits precision) existed, but no copy ever turned up.

Downloads

Scanned manual
Scanned manual alternative version (incomplete)
The original KIM-1 KB-9 Microsoft Basic V1.1, cassette audio wave, binary and papertape format
The updated (see below) KIM-1 KB-9 Microsoft Basic V1.2, binary and papertape format
The reconstructed KIM-1 KB-6 Microsoft Basic V1.2, binary and papertape format
How to use, read this! Clear decimal, set vectors!

Resources

Articles on KB9 in the clubmagazine KIM/6502 Kenner:
– KIM Kenner 4 Siep de Vries Evaluatie 8K Basic, test of accuracy of KB-9, Dutch
– KIM Kenner 5 Uwe Schroder, English, Some Basic problems solved
– KIM Kenner 6 S. Woldringh Patches op 8K Basic Load and Save commands
– KIM Kenner 10 p 10 Microsoft Basic, Hans Otten.
– KIM Kenner 11 p 15 S. Woldringh Patches op 8K Basic part 2
– KIM Kenner 11 p 19 W. van Gelderen Read and Write on cassette for 8K Basic
– KIM Kenner 12 p 15 Patches Microsoft Basic, Hans Otten. Trace mode Renumber
– KIM Kenner 14 p 39 Patches Microsoft Basic, Hans Otten. Calculated line numbers
– 6502 Kenner 16 p 49 Patches Microsoft Basic, W. Blonk Corrections on KIM Kenner 12
– 6502 Kenner 19 p 34 Patches Microsoft Basic, Hans Otten. Speed up Basic 10% with ROR
– 6502 Kenner 22 p 12 Patches Microsoft Basic part 1, van Nieuwenhove Koen, adapt KB-9 to Elektor Junior
– 6502 Kenner 23 p 12 Patches Microsoft Basic part 2, van Nieuwenhove Koen, adapt KB-9 to Elektor Junior
– 6502 Kenner 24 p 14 Patches Microsoft Basic part 3, van Nieuwenhove Koen, adapt KB-9 to Elektor Junior
– 6502 Kenner 25 p 6 Patches Microsoft Basic part 4, van Nieuwenhove Koen, adapt KB-9 to Elektor Junior
– 6502 Kenner 29 p 33 KB-9 Basic on Acorn SYSTEM-1
– 6502 Kenner 32 p 21 W. L. van Pelt KB-9 Basic Tokenized keywords and addresses

All the KB9 KIMKenner articles in one PDF here

Language lab section in the 6502 User Notes:
– Vol 13 Basic tips, Renumber Page 1, Page 2
– Vol 14, Tips, Paging, Automatic Line numbers, the GET statement, USR function
Page 1, Page 2, Page 3, Page 4
– Vol 15 USR Dispatch, Load/save Basic arrays Page 1, Page 2, Page 3
-Vol 16 Line Editor Page 1, Page 2, Page 3, Page 4
-Vol 17 IEEE, Save Load cassette
Page 1, Page 2, Page 3, Page 4

Basic V3.0

After I bought MOS Basic for the KIM-1 in 1978 a lot of study went into understanding and adapting the interpreter. In the Dutch club magazine the KIM Kenner (see above) I and others published my work on it, like tape I/O in hypertape format, calculated goto’s, trace mode, paged output and such.

I modified it later on to suit a bit better to my system, that moved from the KIM-1 I/O to keyboard input via a ASCII keyboard, output to video terminal and a parallel matrix printer Heathkit H14. Even later a real serial interface (ACIA 6850) was used for I/O. I also replaced the startup routine, from destructive to reusable and no questions asked.

Here the Micro Ade source of the patches to V3.0 (Parallel keyboard, video output, H14 printer) and nothing asked non-destructive startup routine. I should rewrite that to the current KB-9 V2 to also include the GET and Backspace patches. V1.3 perhaps?

Sources of KB-9 Microsoft Basic v1.1

Adapt KB-9, first step make it faster and smaller

In the previous section the pagetable article was shown, with resources to recreate from source many 6502 Basic’s, like KB-9.

Here an example how I, quick and dirty, used this to create a KB-9 named V1.2 which is smaller and faster than the original.

This is how to prepare for it (Windows, can be done also on Linux)

  1. Download and unpack the archive of pagetable in a folder on your PC.
  2. Download and unpack the CC65 package, a C compiler, from which only the assembler and linker is used. I used the Windows binaries.
  3. Copy CA65.EXE, LD65.EXE and longbranch.mac from the CC65 package to the folder where you unpacked the MS Basic source.

Do the adaptations as described below or your own:

  1. To save you the work I have collected the adaptations described above in this archive for your convenience here.
  2. Change whatever you like in the source. It is quite a complicated construction, with macros for every variant, so look carefully at the listing file what really is produced.
    Start with no adaptations and then go on studying the listing file and testing. The KIM-1 Simulator is a good tool for testing! Load the symbol table file to see what is where.
  3. Assemble and link with this simple batch file makekb9v2.bat, resulting in an object, a binary, a listing file and a symbol label file.
ca65 -D kb9 msbasic.s -o tmp/kb9v2.o -l tmp/kb9v2.lst
ld65 -C kb9.cfg tmp/kb9v2.o -o tmp/kb9v2.bin -Ln tmp/kb9v2.lbl
  • Repeat step 4 and 5 until you are satisfied with the adaptations. The article listed above are a good source of inspiration.
  • First example: use the ROR instruction and suppress nulls sent to the terminal and Clear decimal and fix GET
    I changed this:

      • In define_kim.s make a comment of the following two lines:
    CONFIG_NULL := 1                     
    ;CONFIG_ROR_WORKAROUND := 1             ; patch HO 2021
    
    • In init.s add this line at label COLD_START
      COLD_START:
      .ifdef SYM1
              jsr     ACCESS
      .endif
      .ifdef KBD
        .
        .
        .
      .else
        .ifndef CBM2
              cld                     ; patch for KIM-1 HO 2021
              ldx     #$FF
              stx     CURLIN+1
      
    • do the fix in the “GET handling (see below)
    • Add backspace handling to correct typing errors
    • Change the version number in inline.s line 493 to “MOS TECH 6502 BASIC V1.2

    Assemble and link with the batch file makekb9v2.bat, this will deliver in the folder tmp/
    – kb9v2.bin file : load as usual at $2000
    – kb9v2.lbl text file
    – kb9v2lst textfile

    Start KB9 V2 now at location $3F8E, label COLD_START (used to be $4065, so we gained some RAM), see the lbl file.

    Here is an archive with all files mentioned above.

    And here the new KB-9 V1.2 executable, faster (no ROR instruction emulation) and a bit smaller.
    You can test all this with the KIM-1 Simulator (version 0.9.3 lets you load CC65 type of symbol files)

    KB-6

    I know KB-6 existed. The ‘6’ stands for the precision in digits of the floating point number. In the documentation KB-6 is described.
    Never seen a version in the wild. So the reconstruction here is not checked with the original, addresses in the reconstruction from the linker differ from the documentation.
    Perhaps the ROR workaround or the insertion of CLD in the init.s caused this.

    KB-6 can be ‘reconstructed’ since other versions of 6 digit Microsoft Basic are in the ‘pagetable sources’.
    It takes one define added in define_kim.s, changes on the original file are now:

    ; CONFIG_NULL := 1                      ; patch HO 2021
    ;CONFIG_ROR_WORKAROUND := 1             ; patch HO 2021
    CONFIG_SMALL := 1                       ; patch H0 2021
    

    Assemble and link as above, replace kb9v2 with kb6 in the batch file. See the archive for a working batch file.
    COLD_START moves to $3D50, size shrinks to 8K.
    Download KB-6 here.
    As you can see in the following screenshots it works! Note the number of digits is less, as expected. It should be faster also.

    Microsoft Basic for the KIM-1 KB-9

    Microsoft Basic for the KIM-1 KB-6, less precision, smaller program size


    The GET bug

    The bug was described and fixed first by an article in the KIM User note

    From the pagetable sources:
    BUG: The beq/bne L2AF8 below is supposed to be always taken. For this to happen, the last load must be a 0 for beq and != 0 for bne.
    The original Microsoft code had ldx/ldy/bne here, which was only correct for a non-ZP INPUTBUFFER. Commodore fixed it in CBMBASIC V1 by swapping the ldx and the ldy. It was broken on KIM, but okay on APPLE and CBM2, because these used a non-ZP INPUTBUFFER. Microsoft fixed this somewhere after KIM and before MICROTAN, by using beq instead of bne in the ZP case.

      .ifdef CBM1
         ldy  #>(INPUTBUFFER-1)
         ldx  #<(INPUTBUFFER-1)
      .else 
         ldx  #<(INPUTBUFFER-1)
         ldy  #>(INPUTBUFFER-1)
    ..
         beq 08
    

    You can easily fix this in KB9 by changing the branch in $2AEE from $D0 (bne) to $F0 (beq).
    I have fixed this in the source of KB9V2 (KB6 does not have the GET statement) .

    Use the backspace key to correct typing errors

    Correcting typing errors can be done with the _ key ($5F). On a video terminal, like we use nowadays it can be done with backspace.
    The way characters are handled by the input routine do not allow to just replace the compare with _ (C9 5F) with 08 for backspace.

    A trick by Jim W4JBM can be used to reuse the BELL handling (07) to a backspace.
    Replace in inline.s

    INLINAIM:
        .endif
        .ifndef CONFIG_NO_LINE_EDITING
            cmp     #$07
            beq     L2443
    

    with

    INLINAIM:
        .ifndef CONFIG_NO_LINE_EDITING
            cmp     #$08 
            beq     L2420
    
    In the original KB9.BIN you can do that with
    poke 9260,8
    poke 9262,241