K-1008 Test programs

The manuals for the K-1008 contain test programs:

Links contain archives with source and binaries in papertape.

This is how the K-1008 Memory test program looks like in the KIM-1 Simulator

KIM-5

The KIM-5 ROM board can hold 8 6540 mask programmable ROMs.
Known are the 3x 6540 Resident Assembler/Editor ($200) and 1x 6540 KIMath (50$)

On this page:


Where is KIM Going?
Richard Simpson, KIM Forum, Kilobaud 1977

One of the questions most frequently asked me was “what are the future plans for KIM?” Most KIM owners are aware that MOS offers a KIM-2 4K RAM expansion board and a KIM-3 8K RAM expansion board. Either of these can be attached directly to a KIM-1. To expand further, a motherboard (KIM-4) must be added and MOS has planned a KIM-5 ROM expansion board, which will hold up to eight MCS6504 (2K by 8) mask-programmed ROMs (the ROMs are not provided with the KIM-5 but must be purchased separately). At present, there are two sets of software which are planned for release in ROMs – KIMath and a resident assembler/editor.

KIMath
KIMath will occupy a single ROM and consists of a set of subroutines for doing floating-point arithmetic. All calculations are done in BCD to avoid the round-off errors which are inherent in binary floatingpoint routines. The subroutine user can specify the precision (in decimal digits) of any calculation. The more precision specified, of course, the longer the computation time. The package will handle a maximum of sixteen decimal digits of precision plus a two digit exponent so numbers in the range of ±1 times 10E±98 can be handled. The subroutines occupy memory locations F800-FFF8 and were written so they could be used with any 650Xbased system – not just KIM. The subroutines include code for addition, subtraction, multiplication, division, square roots, logs, exponents, tangents and arctangents. All the other trig functions can be generated through the use of trigonometric identities. A subroutine is also provided for evaluating user-specified polynomials, so any continuous function can be approximated.The KIMath ROM should be available by the time you read this. If you don’t want to pay $50 for the ROM, the Programming Manual for KIMath is available for $15 and it includes a complete listing of both source and object code. The manual also contains thirtyseven pages of information on using the subroutines, including a worked-out sample application. If you want to use the ROM but balk at paying $80 for the KIM-5 board to hold it, you’ll be happy to know that the 6540 ROM can be attached directly to the KIM address and data busses, although you’ll need a couple of extra ICs to send the right signal to the KIM-1 Decode Enable line. I’ll provide an interface schematic for this in a future issue of the KIM forum.

The Resident Assembler /Editor
To create any large-scale software on a microcomputer, an assembler is a necessity. Industrial microcomputer users can use the crossassemblers available on several commercial timesharing systems, but the expense of going this route is too much for any but the most affluent hobbyist. Thus, the introduction of the KIM resident assembler should facilitate user software generation and make a lot more software available. The assembler and text editor are available as a set of three MCS6540 ROMs – a total of 6K of code. The $150 which MOS charges for the set may seem exorbitant until you realize that you don’t have to buy 6K of RAM to store it in (which would cost as much or more) and you’ll never have to load it or have it clobbered by errant statements in the program you are developing. Like KIMath, the Assembler/ Editor will work on any 650X-based system. Since the program has to do terminal I/O, locations are reserved in memory page zero to contain the address of the terminal input and output routines. These locations are automatically initialized for KIM owners; users of other 6500 systems (JOLT, TIM, Apple, Baby!, OSI, etc.) can preset those locations with the addresses for the device service routines of their own system. The Editor/Assembler occupies the memory space from E000 to F7FF; thus the editor, assembler, and KIMath fit together in the top 8K of memory.The text editor is a standard line-numbered text editor; it provides much the same editing capability you would find in a BASIC system. You can enter or insert new lines, replace old lines, resequence the line numbers, dump the text file to audio cassette or paper tape, list out lines in the file, and locate lines in the file which contain any specified text string. There is also a special command (actually, any command which begins with an X) to allow you to jump to a user-written subroutine so that you can extend the editor’s capabilities to meet your own needs. Naturally, both the editor and assembler require that you have a terminal connected to the serial port on the KIM-1.The assembler is a singlepass assembler; if your source text is on paper tape or audio cassette, you only have to feed it through once. Normally your source text will be in memory and the assembled code is always written to memory. The source code, symbol table, and object code can be located anywhere in memory you wish. You may have several different source files in memory simultaneously. If you have insufficient memory space to store a large source program, you can break it into several segments, store each segment on audio tape, then bring back one segment at a time for assembly. The assembler will assemble the successive segments until it encounters an “END” statement. It will then put out the symbol table and terminate assembly. Although the editor is fairly limited (it has no capability to edit within a given line, for instance) it is quite sufficient for editing assembly language programs. The assembler is very fast and with good error diagnostics. Perhaps its only serious fault is that the printed symbol table is not sorted alphabetically and no crossreferences are given.


MOS 6540 ROM
The MOS Technology 6540 is a 16k (2KByte) ROM. Factory burned. Mask options for specification of chip select equations. 5! chip selects, requires Phi2 6502 system clock. 24 pin, very uncommon for a small ROM.
A strange and uncommon device, AFAIK only used in the KIM-5 Resident Assembler/Editor and early PET computers. Has a bad reputation, and there are many replacement solutions with standard E(E)PROMs for PET computers.
The 6540’s in the KIM-5 Resident Assembler/Editor on a KIM-5 ROM board are in an excellent condition, dumping with the Backbit Pro chip tester was very easy.

MOS Technology 6540 preliminary datasheet 1977




KIM-5 ROM board
The 3 KIM-5 Resident Assembler/Editor ROMs as placed on the KIM-5 ROM board.
Besides the sockets for the ROMs is some glue logic, 2x 74125 buffers, 2x 7485 address decoders, a 7402 TTL IC and some DIP switches.
The KIM-5 ROM board is to be placed in the KIM-4 Motherboard. The manual is not available alas.

KIM-5 Resident Assembler/Editor available!

MOS Technology, part of Commodore in 1977, not only sold the KIM-1 SBC but added hardware and software as KIM System Products.

Not only hardware, a Motherboard (KIM-4), RAM memory expansions (KIM2, -3, -3B) and a prototype board (KIM-6) but also software, like KIM Math subroutines (KIMath), TIM (RRIOT + document).
This has been documented for quite some time now on this website with photos and manuals.

I have been looking for years for the KIM-5 Resident Assembler/Editor. Manuals on Assembler and Editor are already known. The software, delivered in 3 ROMs of type 6540, on a KIM-5 ROM board was never dumped before, and the existence, besides the pricelist shown here and some advertisements, doubted by many, including old Commodore employees.
Many years I searched on the internet on fora, websites and friends in the retro world, it did not lead to a dump of the KIM-5 ROMs.

A couple of years ago I saw a listing on ebay.de of a lot with a a KIM-5 with ROMs and a KIM-3B board. I was too late to bid. I could not contact the seller or buyer afterwards. But now I knew the KIM-5 did exist, and had some photos as proof.

A year later Stefan Hamann approached me to ask for information on KIM-1 material he bought from ebay. He was the buyer of the lot!
Stefan was so nice to lent me the KIM-5 (and KIM-3B) and the EPROMs he obtained. I have finally a KIM-5 in my hands with ROMs!

The ROMS have been dumped, tested in the (updated KIM-1 Simulator to 1.5.1) and source recreated. The KIM-5 Resident Assembler/Editor is preserved!

Read all about this on the newly organized and enhanced KIM System Products pages.


Resident Assembler/Editor at 9000-A7FF

KIM-3B

KIM-3B, a 16K memory module with 2114 SRAM ICs.

KIM-3B (Stefan Hamann)

KIM-3B (Stefan Hamann)

KIM-3B

User’s Manual Memory Expansion Module KIM-3B
User’s Manual Memory Expansion Module KIM-3B

KIM-2 KIM-3

KIM-2 offers 4K RAM with 2102 SRAM ICs. The KIM-3 has 8K RAM, also with 2102 SRAM ICs.

< MOS KIM-2-3-4 User Manual Expansion Modules

KIM-2 (photo by glitch)

KIM-3

KIM-5 Resident Assembler/Editor

On this page:


The KIM-5 Resident Assembler/Editor is a 6502 version of the MOS Technology Cross Assembler. See the pages on the MOS Technology/Commodore assemblers on pagetable.com

The Resident Assembler was written by Michael Corder (of MOS contractor COMPAS Microsystems) by hand-assembling the Cross-Assembler FORTRAN code to native 6502 assembly.
Consequently, both assemblers were compatible in that they understood the same source format, with the same math features and the same directives and options. That way, they defined the basic format supported by all future Commodore assemblers. This means that the Resident Assembler took uppercase ASCII source files.

John Feagans on the origin of the KIM-5 Resident Assembler/Editor:
As a grad student at Iowa State University, Ames, I had access to all the development of these KIM boards as the local contractor for MOS was Compass Microsystems. The original 6502 assembler was written in Fortran and available on Tymshare. First Michael Corder (aka The Cordless Electric Programmer) hand compiled the Fortran to 6502 assembler. Even the Fortran line numbers were used as labels. This became the basis of the MDT 650, an ICE for 6502, and the KIM assembler. Compass developed another product called the MiniMac–a 6502 development system on a plugin for a DEC PDP-11. I took Corders 6502 assembler and hand translated line by line from 6502 assembler to PDP-11 assembly. When I joined Commodore I ported the assembler one more time to become the PET assembler and later C64 assembler.

In 1977, Commodore announced the Resident Assembler/Editor for the KIM-1, which shipped in the form of the KIM-5 ROM board with three 6540 ROM chips (6 KB total) containing the assembler and a simple editor.
The manuals (see below) from 1977 do not mention the .DBYTE, .PAGE and .SKIP directives. In the source (see below) they seem to be recognized and lead to an error.
The assembler could read source from cassette tape or paper tape, but it could not write OBJ files; instead, it would write the binary to RAM.
If the source was too big to be placed in memory, the assembler could read source files from tape until the .END directive was encountered.



All described in the two manuals that I found:

MOS KIM Assembler Manual Preliminary (KIM-5)
MOS KIM Text Editor User Manual (KIM-5)


The KIM-5 Resident Assembler/Editor ROMs
Many years I searched on the internet on fora, websites and friends in the retro world, it did not lead to a dump of the KIM-5 ROMs. It was even doubted the KIM-5 with Assembler/Editor was ever sold, despite the adverts in magazines of that period.

A couple of years ago I saw a listing on ebay.de of a.o. a KIM-5 and a KIM-3B board. I was too late, could not contact the seller or buyer, but I knew the KIM-5 did exist!
A year later Stefan Hamann approached me to ask for information on KIM-1 material he bought from ebay. He was the buyer!
Stefan was so nice to lent me the KIM-5 (and KIM-3B) and the EPROMs he obtained. I have finally a KIM-5 in my hands with ROMs!
The KIM-5 Resident Assembler/Editor is placed in three 2K ROMs of type MOS 6540, and the KIM-5 board configured to show these in memory at E000-E7FF.

With the excellent Backbit Pro Chip Tester I managed to dump the 6540-007, -008, and 009 ROMs. 6540 are strange ROMs, see below. To my surprise the ICs were in excellent condition.
In the other EPROMs (2x 4K 2532) I found a copy of the KIM-5 Resident Assembler/Editor ROMs, nearly identical to the 6540’s. So the dumps are reliable.

ROM dump archives

This archive has the ROM dumps of the KIM-5 Resident Assembler/Editor for KIM-1 Mos Technology Commodore:

  • Dumps of original KIM-5 2K ROMs
    • 6540-007 E000 – E7FF
    • 6540-008 E800 – EFFF
    • 6540-009 F000 – F000
  • Combined to one binary
    (suitable for KIM-1 Simulator 1.5.1 or KIM-1 with ROM/RAM at E000-F7FF

    • kim5.bin E000-F7FF
  • EPROM dump (4K ROMs) (has valid KIM-1 Reset/NMI/IRQ vectors at high memory)
    Small changes like jmp to tape dump routine in the ROM (see sources)
    • KIM E000
    • KIM F000
  • Combined to one binary
    • kim e000-ffff

With the binaries dumped I have

  • loaded in the KIM-1 Simulator (version V1.5.0. with RAM at E000-F7FF added) and started the Editor. See the screenshots below (in which I did not configure the symbol table as instructed in the manual!).
  • disassembled and recreate assembler source which assembles to identical binary and documented as much as possible with the assembler sources on pagetable (PET, AIM 65)

Source of KIM-5 Resident Assembler/Editor
Recreated source of KIM-5 Resident Assembler/Editor with the aid of TASM32, result is binary identical with the ROM dumps.
Tables, data, jump tables, all recreated. A lot is commented, the editor part needs some attention. Assembles fine.
Eduardo Casino helped me to find the last location dependent statements, and now the program runs at other locations like $9000 after adjusting the .org directive and reassembly.
Eduardo Casino created a CC65 version of the source: Recreated source in CC65 Assembler format of KIM-5 Resident Assembler/Editor

Symbol table at $3000

Resident Assembler/Editor at 9000-A7FF


Assembling branch instructions
While working with the assembler Eduardo found weird behaviour by the assembler of the code generated.
Backward branches are done in the usual way. Forward branches generate an extra NOP instruction.
It is not doing any damage, it just wastes space and execution time.

See the next screenshots.


RNB VAK-1 photos

Thanks to Eric Dennison I can show photos of the RNB Enterprises VAK-1 motherboard.

The large motherboard and the huge case with homebuilt 16K static RAM memory card are representative for the KIM-1 systems then!

Photo by Eric Dennison

Photo by Eric Dennison

Instant Assembler for the KIM-1

A program by Alan Cashin.

The following text and other files are by (the ‘I’) Alan Cashin.

I am currently looking through old material that has been in storage for many years. I came across a listing of my ‘instant assembler’ written for the basic KIM-1 with 1kB (plus a bit) memory. It was written in about 1979 to help enter assembler programs, saving the task of converting mnemonics to hex code. The tape with it on is long gone, so I coded it for the acme assembler then ran it in your excellent simulator and it works.

post

Instant Assembler for the KIM-1

A program by Alan Cashin.

The following text and other files are by (the ‘I’) Alan Cashin.

Here an archive with all sources and binaries and images

I am currently looking through old material that has been in storage for many years. I came across a listing of my ‘instant assembler’ written for the basic KIM-1 with 1kB (plus a bit) memory. It was written in about 1979 to help enter assembler programs, saving the task of converting mnemonics to hex code. The tape with it on is long gone, so I coded it for the acme assembler then ran it in your excellent simulator and it works.

The acme assembler was retrieved from https://web.archive.org/web/20150520143433/https://www.esw-heim.tu-clausthal.de/~marco/smorbrod/acme/ – there is a later version (I believe) in GitHub.

Because there was not much memory, it is small, around 350 bytes (actually smaller as it has an unused block in the middle, which could be the stack if loaded into page 1 or the data bytes if loaded into page 0). It is in 2 parts, a code page around 240 bytes and a set of lookup tables around 100 bytes. It also uses a number of ROM subroutines and it uses the monitor data area as its data area.
It has one failing – no error checking. There was a version that didn’t place the instructions into memory, but passed them to a disassembler. If the original input and the disassembled instruction didn’t match, then it was an error. I don’t have the listing for it.

I’ve included a screen shot run in the emulator. The first entry usually is *<4 hex address> otherwise it overwrites itself.
An instruction is entered as mnemonic (e.g. STA). If it is an immediate (TXS PHP etc) the byte is immediately put in memory. If there are different address modes, the cursor moves to accept the operand, entered as
For conditional branches enter the absolute 4 hex address, it is converted to an offset address
The other possible inputs are:

 / ... return to KIM
 < ... cancel this line (after making a typing error for instance)
 #<2 hex> ... a data byte

There may be original documentation but I haven’t found it. I also don’t remember how I got the listings as they were created over 40 years ago. As I recall, I wrote the assembler with the code in page 0 and the tables loaded into the 6530 RAM ($1780 – $17E6). This made sense as people didn’t ordinarily put code in page 0. I found part of a printout with the code in page 0, probably done when the assembler was first entered. There’s also a more complete disassembly that includes the tables, written to load at $2000. I don’t know how that happened as the original KIM-1 purchase didn’t have extra memory. But that is the listing I used to create the source. I didn’t own the KIM-1, it was owned by a group. I bought an Ohio Superboard a year later so did most programming with it.

The assembler is now just a curiosity, there are much easier ways of creating 6502 programs. But in those days the first programs (including the instant assembler) were created in several steps:
1. Write the program as if it were for a proper assembler, with labels for data and program locations.
2. Go through the written version allocating addresses to everything (not hard if one counts in hex and knows the length of the instructions)
3. Substitute real addresses for all the labels
4. Work out relative offsets for all the branch instructions (not so easy)
5. Translate all the op codes to hex (tedious)
6. Enter the hex
7. dump the memory to tape

The instant assembler took the information prepared in stage 3 and allowed it to be entered, so saving steps 4,5,6

The assembler uses tables to convert the mnemonic to a binary op code.
1. Each character of the mnemonic is used to access the character table (25 bytes as Z is not used). Each byte in the table has three components, 2 bits, 3 bits, 3 bits – |cc|aaa|bbb| for the mnemonic abc – these are used to create an index into a second table – the index is aaa000+bbb+cc which yields a unique number between 0 and 61 for each mnemonic. This took a lot of juggling to make work.
2. The number is used as an index to look up the base op code. Implied instructions can only be one byte (TAX, PHA, etc) so the assembler does not expect an operand and goes directly to output the op code
3. For instructions that have an operand, a second index is required. The operand can only have a limited set of characters – , # ( ) X Y or hex. These are given values:
, -> 0 (can be left out)
# or a hex digit -> 1
( -> 2
) or X -> 3
Y -> 4

By adding up the value for each part of the operand, a unique index is created. hh=2; #hh=3; hhhh=4; hh,X=5; hh,Y=6; hhhh,X=7; hhhh,Y=8; (hhhh)=9; (hh,X)=10; (hh),Y=11
Some instructions can have an operand or not (eg ROL). If there is no operand, the index is 0.
There are exceptions so there is more manipulation to get the final index. The index is used to look up a modifier to the base op code to get the final op code.
4. The bytes placed into memory for most instructions are (2+hex digits input)/2. Relative branches are modified. If a data byte is input (using #hh) it is treated like an implied op code.

Also, I have tested the idea of writing the assembler in its own format – the assembler can assemble itself (overwriting itself as it runs). This is using the facility for console input from a file.

I’ve now gone through the source (for the acme cross assembler) and put in a lot more documentation. The cross assembler source could be set up to locate the binary anywhere. For no particular reason it is set up to load at 0x0200.

A simple “Hello World” that can be input to the console after 0200 G – assembles then runs it at 0100

*0100 JSR1E2F LDX#0C LDA0110,X JSR1EA0 DEXBNE0102 JMP1C16 #21#64#6C#72#6F#57#20#6F#6C#6C#65#48/0100 G

The source of the Instant assembler (included in the archive above):

		*= $0200		; set program counter
		!to "org0200.o", plain	; set output file and format
; define some KIM-1 ROM addresses
	open = $1fcc
	crlf = $1e2f
	prtpnt = $1e1e
	outsp = $1e9e
	getch = $1e5a
	getbyt = $1f9d
	prtbyt	= $1e3b
	incpt = $1f63
	pack = $1fac
	gokim = $1c16


	jmp	x200b	; convenience, start address same as load point
x2003	jsr	x20de	; gets a character and calls pack
x2006	beq	x2003	; A=0 it was a hex character, try for another
	jsr	open	; not a hex character, set current location to INL,INH
x200b	ldx	#$ff	; set the stack empty
	txs
	jsr	crlf	; CR LF print the current location and 3 spaces
	jsr	prtpnt
	ldx	#$03
	jsr	x20e6
	stx	$f5	; x=0 on return, initial instruction length
	ldx	#$03
	stx	$f6
x201f	jsr	x20d6	; get a character
	cmp	#'/'
	bne	x2029
	jmp	gokim	; if /, return to monitor
x2029	cmp	#'*'
	beq	x2006	; if *, get a new location
	cmp	#'#'
	bne	x2037	; if #, a data byte
	jsr	getbyt
	jmp	x20a5
; assume it's an instruction - get 3 letters
x2037	tay	
	lda	x2100-$41,y ; lookup pattern for character
	and	x215f-1,x ; apply mask for 1st,2nd or 3rd character of mnemonic
	sta	$f6,x ; save
	dex
	bne	x201f
	asl	; a - got 3 characters, create index into instructions
	rol	; a
	rol	; a
	adc	$f8
	adc	$f9
	tax
	lda	x2119,x ; get the basic instruction code
	sta	$f7
	ldx	#$02
	and	#$05 ; work out what type
	lsr	; a
	sta	$f4 ; instruction modifier lookup
	sta	$f5
	bne	*+4
	bcs	x209f ; an immediate - go to output
	pha
	jsr	x20e6
x2061	jsr	x20de
	bne	*+4
	inc	$f5 ; final instruction length
	ldx	#$07
x206a	cmp	x2157,x ; possible operand components (X, Y, brackets etc) 
	bne	x2077
	txa
	lsr	; a
	adc	$f4 ; add to modifier lookup
	sta	$f4
	bne	x2061 ; if a legal component was found, get more
x2077	dex
	bpl	x206a ; didn't match, try the next one
	pla
	bne	x2087
; convert absolute to relative address for branches
	lda	$f8
	sec
	sbc	#$02
	sec
	sbc	$fa
	sta	$f8
; some instructions are not consistent - special processing
x2087	ldx	$f4
	lda	$f7
	cmp	#$34
	bne	*+4
	ldx	#$0d
	and	#$08
	beq	x20a0
	cpx	#$0a
	beq	x209f
	cpx	#$05
	bne	x20a0
	dex
	dex
x209f	dex
; modify base code according to address mode
x20a0	eor	x20c8-1,x
	eor	$f7
x20a5	sta	$f7
	lda	$f6
	eor	#$0f
	tax
	lsr	$f5
	jsr	x20e6
x20b1	jsr	outsp
	lda	$f7,x
	jsr	prtbyt
	ldy	#$00
	sta	($fa),y
	jsr	incpt
	inx
	cpx	$f5
	bmi	x20b1
x20c5	jmp	x200b
;
; op code adjustment table
x20c8	!8 $01, $04, $0c, $00, $0c, $08, $10, $10
	!8 $18, $1c, $28, $04, $14, $00

x20d6	jsr	getch
	cmp	#'<'
	beq	x20c5
	rts
x20de	inc	$f6
	jsr	x20d6
	jmp	pack
x20e6	inc	$f6
	jsr	outsp
	dex
	bne	x20e6
	rts
;
	!fill 17
; character lookup table - 
x2100	!byte $32, $4b, $60, $97, $77, $00, $00, $00
	!byte $1e, $00, $40, $1c, $00, $3a, $11, $d6
	!byte $c0, $7e, $ad, $c3, $00, $c3, $00, $80
	!byte $c1
;
; base instruction patterns
x2119	!byte $8b, $99, $9b, $44, $ab, $a9, $34, $bb
	!byte $30, $90, $b0, $d0, $50, $70, $10, $01
	!byte $49, $24, $f0, $09, $69, $00, $05, $29
	!byte $c6, $cb, $89, $e6, $e9, $c9, $46, $a5
	!byte $00, $ae, $ac, $c5, $59, $19, $d9, $b9
	!byte $ec, $cc, $00, $85, $e5, $86, $84, $79
	!byte $39, $f9, $45, $00, $25, $06, $00, $00
	!byte $65, $26, $66, $41, $eb, $61
; lookup operand characters
x2157	!byte ',', '#', 0, '(', $ff, ')', 'X', 'Y'
; masks used on data retrieved from character lookup
x215f	!byte $c0, $07, $38

I’ve included a scan of 1 page, the handwritten notes were made a long time ago. I think I was trying to figure the total bytes used including the monitor routines. Is it the smallest 6502 assembler written?

KIM programs

Downloads:
KIM Programs

– Farmer Brown
– Lunar Lander
– Sample extension for XKIM

;=====================================================
; A sample extension for the Extended KIM monitor.
; This is a very simple example of how to write an
; extension (adding a new command) for the
; Extended KIM monitor.
;
; How can you test this? Easy. First, use the “?”
; command in the extended monitor and verify the
; “Z” command is not listed, then load the binary
; version of this file. Do “?” again and you’ll see
; the new command has been added and can be used.