CS2 Real-Time Course 1985: The 6809 microprocessor kits Introduction The CS2 Motorola M6809 kits are small microprocessor systems which demonstrate the basics of assembler programming and device handling. Each kit consists of a small box with two removable boards. The top board contains the necessary circuitry to support a Motorola M6809 processor, 1Kb of RAM and up to 2Kb of ROM (mounted in the Zero Insertion Force [ZIF] socket). The bottom board contains two 6850 ACIA serial line drivers, a 6840 Programmable Timer Module [PTM] and a software controllable baud rate generator. One of the ACIAs is used to drive the VDU and keyboard, the other auxillary ACIA is used in the experiments and to down-load programs into the kits. Downloading of programs is performed from the APM or VAX using a monitor program resident in the ROM. This avoids having to blow EPROMS and transport them to the kits - the only other way of mounting software. The monitor program operates in three modes. When the kit is first switched on, the monitor passes all characters except one from one ACIA to the other and vice versa and is said to be in transparent mode. The exception is that the character with ASCII value 2 (STX) signals to the kit that a loadable program follows. The kit loads the program then enters its command mode and waits for further instructions. The S6809 utility on the VAX or APM handles the loading procedure so as far as you are concerned the monitor is either in transparent mode, command mode, or is running your program. If you want a good example of hairy assembler code, have a look at the monitor. It lives in CS2RTS:CS2MON.ASM. Interrupt & restart vectors The 6809 conventionally restarts and interrupts through locations FFF0 to FFFF. These locations have been grabbed by the monitor program so you are provided with pseudo- restart and interrupt vectors at locations 3F0 to 3FF. These correspond exactly with the real vectors - the mapping from one to the other is handled by the monitor program. Monitor SVCs Once loaded, your program may make use of the 23 monitor SVCs. You will probably have met some of these in the compiler exercise. The method of calling them is exactly the same... All require the stack pointer to be valid and the stack to contain at least 32 free bytes. They are called through a software interrupt which is followed by the index of the required service. E.G. The following code calls the print symbol routine 'prtsym': ldaa #'A' swi fcb 9 ; prtsym index no Return is to the location following the index number. To make calling easier the file CS2RTS:STDSVCS.ASM contains symbol definitions for each service which includes the swi opcode. To use the definitions you just plant the appropriate double byte constant in line. E.G. The following calls 'lshift' the double length dynamic left shift routine: ldd #7 fdb lshift Note that the monitor program maintains an input buffer, so functions such as NEXTS are possible. Do not attempt to drive the ACIA 'hands-on' yourself while driving it with these routines. You will experience curious side-effects (why?) Method of working 1) Your program should not attempt to write implicitly or explicitly to addresses outside the range 0 to 3FF. This includes 'rmb' declarations but not 'equ' declarations. 2) You must set up your stack pointer yourself. 16_368 is a suitable initial value. 3) Remember to set up reset and possibly interrupt vectors in locations 3f0-3ff. 4) Make sure the M6809 kit is connected between the VDU and the APM or VAX. The ribbon cable to the VDU should be so marked. It is driven by the ACIA to the backplane side of the lower card. Switch it on if not on already then press the reset (red) and adjacent start (grey) buttons in turn. The monitor should now be in transparent mode. You should be able to edit and assemble your program on the VAX or APM as if the M6809 kit were not present but if you want to use the VAX/APM for long periods without loading into the kit, please make way for those who do. The other two buttons are halt (grey) and single-step (blue) by the way. 5) When you have what you think is a working program, assemble it using the M6809 command then send it to the kit with the command S6809. M6809 takes parameters ,/list=, where and are optional. Default extension for is asm. S6809 takes parameter and requires the full object filename to be specified. Once the monitor program has seen the STX character indicating start of load, it will clear the screen and put up the message 'CS2 M6809 System V1.x'. Wait for the prompt 'Which Service?' before typing anything (It should take 20 seconds or so). This indicates that your program has loaded successfully and that the monitor is in command mode. 6) Enter one of four commands... s(Start) Runs your program r Dumps the values of the registers. d Dumps all of RAM to the VDU (use with caution - still some bugs here) q Returns to transparent mode. If you start your program, it will continue until.. a) You press the blue NMI button on the top of the kit, which will return you to command mode b) You invoke the STOP, WAIT or DISREG SVCs (see below) which also return you to command mode. c) You restart the monitor program which will return you to transparent mode Note that your program must either loop indefinitely or must terminate with a STOP SVC call. There is nothing in the assembler to prevent your program running off the bottom and attempting to execute whatever follows it in store unless you put something there. Microprocessor kit Memory Map 0000-0367 RAM available to user program 0368-03E7 RAM used by Monitor program 03E8-03EF Unused 03F0-03FF Pseudo interrupt and reset vectors for use by user 1000 PTM Control register 1/3 1001 PTM Control register 2 1002-1003 PTM Timer register 1 1004-1005 PTM Timer register 2 1006-1007 PTM Timer register 3 1008-1009 ACIA Baud rate registers 100A VDU ACIA status register 100B VDU ACIA data register 100C Auxillary ACIA status register 100D Auxillary ACIA data register 100E-100F Empty F800-FFFF Monitor program ROM 14 February 1985