Showing posts with the label 6502

Micro-KIM Tutorial: The Memory Map

Let’s revisit the Micro-KIM memory map, introduced in the third tutorial. +-----------+ | 2K EPROM  |$1fff | monitor   | | program   |$1800 +-----------+ | 6532 RIOT |$17ff | I/O, timer| | and RAM   |$1740 +-----------+ | optional  |$173f | I/O, timer| | and RAM   |$1400 +-----------+ |           |$13ff | 5K RAM    | |           |$0000 +-----------+ Since the default kit (without any expansion) only uses the lower address bits to access 8K, memory repeats itself every 8K. You can verify this by storing and inspecting values in, for instance, addresses $0000 and $2000. Any value stored in one address will show up in the other. Although an interesting factoid, there is no reason to let Micro-KIM programs address anything outside the range $0000-$1fff. Addresses $0000-$13ff contain 5K free RAM (another interesting factoid: the Micro-KIM actually wastes 3K of its 8K RAM chip to keep compatibility with the original KIM-1). This memory region can be used to store da

Micro-KIM Tutorial: Available as Single PDF

If you were following (and hopefully enjoying) the Micro-KIM tutorial, you may have noticed a rather long silence after the last posting. Unfortunately, my day job and a move plus remodeling claimed most of my spare time. However, I plan to continue the tutorial really soon again! In the meanwhile, I have made all previous tutorials available as a single PDF on my Micro-KIM website , where you can also find the source code of all examples. Future tutorials will be added to this PDF to keep the collection available as a single file.

Micro-KIM Tutorial: Brightness of LED Display

A demo is a program that shows off the abilities of a computer or programmer, sometimes even beyond the limits of an original architectural design. For example, a well-known demo theme on the Commodore 64 consists of rendering sprites in the border, i.e. outside the area originally destined for rendering sprites. This tutorial presents demos that use the LED display beyond its (probable) original purpose: adjusting the brightness of characters or even segments. As shown in the previous tutorial, a refreshing loop is necessary to show all 6 characters on the LED display. Here, the refreshing rate directly defines the brightness of these characters. Simply looping around yields maximum brightness, while lowering the refresh rate dims the screen. This idea can also be used to adjust the brightness of parts of the LED screen (characters or even individual segments within the characters). To illustrate this effect, let's modify the program of the previous tutorial (the source

Micro-KIM Tutorial: The LED Display

The following schematic illustrates what is fun about retro computing: the complete schematic of a microcomputer fits on a single page (a higher resolution PDF can be downloaded from the Briel Computers website). Micro-KIM Schematic. Courtesy Vince Briel - Briel Computers The schematic shows that the 6 character LED display is controlled through some selection logic by the data ports of the 6532 RIOT. Because the 16 pins of the two 8-bit data ports A and B would not have sufficed to control all characters in the LED display simultaneously, instead a few bits of B select one character (value 9 selects the first, value 11 the second, etc.) while the lower 7 bits in A are used to control the 7 segments of that particular character (bit 0 controls the top segment, bit 1 upper right segment, etc.). Note that with this scheme, it is possible to set one character and "go on with the program", as I showed in an earlier tutorial by displaying a very bright 8 in the

Micro-KIM Tutorial: The Monitor Program

A simplified memory map of the Micro-KIM is shown below. This tutorial explores the 2K EPROM,  leaving a more detailed exploration of the free RAM and 6532 RIOT for later.  Address space $1400   to   $173f  is unused i n the standard Micro-KIM kit configuration.    +-----------+   | 2K EPROM   |$1fff   | monitor   |   | program   |$1800   +-----------+   | 6532 RIOT |$17ff   | I/O, timer|   | and RAM   |$1740   +-----------+   | optional  |$173f   | I/O, timer|   | and RAM   |$1400   +-----------+   |           |$13ff   |  5K RAM   |   |           | $0000   +-----------+ Addresses  $1800 through  $1fff  are taken by the 2K EPROM, which is a read-only memory area that stores the 6530-003 and 6530-002 parts of the monitor program. You can, of course, inspect all  individual bytes in the address mode on the Micro-KIM kit, but I recommend reading the assembly listing of the monitor program in the appendix of the Setup and User's Manual of Briel Computers. The c

Micro-KIM Tutorial: A First Assembly Program

At the lowest level, the 6502 executes numerical machine code. For example, the following bytes in hexadecimal format constitute a simple program that displays a single 8 on the LED display of the Micro-KIM.   a9 ff 8d 40 17 a9 09 8d 42 17 4c 0a 02 Let's enter this program into the memory of the Micro-KIM. Power on the kit with jumper JP2 off and press the RS key. Then enter 0200 to set the address and press DA to go into data mode. Next, enter the numbers above pressing the + key after each number pair (so, enter A9 + FF + etc.). Before running, I strongly recommend checking the values. Use AD to go back into address mode. Press 0200 again and use + repeatedly to check all entered values. Once satisfied, press 0200 and GO. If all goes well, you will see a very bright 8 as first digit on the LED display (in later tutorials I will explain why). Displaying a single digit on the Micro-KIM Obviously constructing and entering programs this way is tedious and error-prone.

Micro-KIM Tutorial: Getting Started

Perhaps reminiscing the past is a sign of getting older, but I cannot help but look back fondly at the times I learned programming machine code on the Commodore 64 in the eighties. Therefore, it is probably no surprise I still occasionally enjoy programming 6502 on the Micro-KIM, which is a modern replica of the seventies KIM1 microcomputer, made available by the well-known retro computer kits provider  Briel Computers . In fact, I am having so much fun with this board, I decided to write a series of tutorials on operating and programming the Micro-KIM. In this series, I assume you have already some experience with the Micro-KIM and 6502 machine code, and have read the basic documentation that is shipped with the kit. Other than that, I hope to give additional information on various topics, such as developing assembly programs, programming the display, using the RS232 port or keypad, setting up timer-based interrupts, using a cross-assembler to generate programs in paper tape fo


The Micro-KIM arrived today! I did some initial experimentation with my 6502 cross-assembler and was happy that the paper tape format l recently added could be uploaded to the device without any problems. What better first program to write than "HELLO WORLD" (except only HELLO fits on the display)? It was fun figuring out how to control the display using low level 6502 programming.

Paper Tape Format Disassembler

I have extended my cross-assembler with a built-in disassembler that can directly read from paper tape format (and a few other formats). For example, the following test assembly program       .org $0200       ldx #100 loop  dex       bne loop       brk is, under option -P, assembled into paper tape format (text representation): ;060200A264CAD0FD0003A5 ;0000010001 Option -dP activates the disassembler on paper tape format represented as text, which disassembles the format above back to: $0200 a2 64  ldx #$64 $0202 ca     dex $0203 d0 fd  bne $0202 $0205 00     brk

Paper Tape Format

As a present, my wife ordered the Micro-KIM from Briel Computers for me, which is a modern replica of the KIM-1 microcomputer. Even though I learned machine code on the 6510 of the Commodore 64, I remember seeing the KIM-1 in an electronics store much earlier, and I was intrigued right away. I can't wait for it to arrive to do some vintage programming. In anticipation of the Micro-KIM's arrival, I extended my 65xx cross-assembler (available for Windows, Linux and MacOS) with the paper tape format , either in the original binary format (option -p) or in a text representation (option -P) so that its output can feed directly into the Kim's terminal interface. I simply generated the format based on old documentation and it is still untested. If someone is interested in trying it out, I would appreciate early feedback. Otherwise, I will report back when I get my Micro-KIM. For example, using the assembler on this little test assembly program: .org  $0100 .byte $FF $E

Soft6502 and H6X file format

Charles Bond wrote a nifty 6502 simulator, called Soft6502 , which I find useful for testing small programs written for the 65xx microprocessor family. The simulator supports the full 6502 instruction set and two 8-bit ports for input and output.   Programs can be entered one byte at the time through the keyboard or, more conveniently, loaded from file. The simulator uses the H6X file format , which is a simple, but surprisingly versatile way of representing 6502 code (essentially an ASCII representation of addresses followed by bytes). I have extended my 65xx cross-assembler (available for Windows, Linux, and MacOS) to support this H6X file format, so that its output can be directly fed into Soft6502.

6502 Microcomputer

It is nice to hear that others sometimes find my toy projects useful. As I reported in an earlier blog entry , a while back I implemented a 6510 cross-assembler to relive the good old times of programming a Commodore 64. Today I got an email from Antonino Brisindi who is using this assembler to burn an EPROM for his home-made 6502-based microcomputer. Below you see a picture of his impressive project in progress.