Silicon ChipProgramming the Motorola 68HC705C8 - October 1993 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: The technical aspects of modern blockbuster movies
  4. Feature: Darwin To Adelaide On Solar Power by Brian Woodward
  5. Feature: Electronic Engine Management; Pt.1 by Julian Edgar
  6. Feature: Mini Disc Is Here! by Leo Simpson
  7. Review: Magnet: S-621 2-Way Loudspeakers by Leo Simpson
  8. Project: Courtesy Light Switch-Off Timer For Cars by John Clarke
  9. Feature: Computer Bits by Darren Yates
  10. Order Form
  11. Project: Stereo Preamplifier With IR Remote Control; Pt.2 by John Clarke
  12. Serviceman's Log: Dead sets aren't always easy by The TV Serviceman
  13. Project: FM Wireless Microphone For Musicians by Branco Justic
  14. Feature: Amateur Radio by Garry Cratt, VK2YBX
  15. Project: Build A Binary Clock by Michael Vos
  16. Feature: Programming the Motorola 68HC705C8 by Barry Rozema
  17. Feature: Remote Control by Bob Young
  18. Product Showcase
  19. Vintage Radio: Those never-ending repair problems by John Hill
  20. Back Issues
  21. Market Centre
  22. Advertising Index
  23. Outer Back Cover

This is only a preview of the October 1993 issue of Silicon Chip.

You can view 36 of the 104 pages in the full issue, including the advertisments.

For full access, purchase the issue for $10.00 or subscribe for access to the latest issues.

Articles in this series:
  • Darwin To Adelaide On Solar Power (October 1993)
  • Darwin To Adelaide On Solar Power (October 1993)
  • The World Solar Challenge (November 1993)
  • The World Solar Challenge (November 1993)
  • The World Solar Challenge (January 1994)
  • The World Solar Challenge (January 1994)
Articles in this series:
  • Electronic Engine Management; Pt.1 (October 1993)
  • Electronic Engine Management; Pt.1 (October 1993)
  • Electronic Engine Management; Pt.2 (November 1993)
  • Electronic Engine Management; Pt.2 (November 1993)
  • Electronic Engine Management; Pt.3 (December 1993)
  • Electronic Engine Management; Pt.3 (December 1993)
  • Electronic Engine Management; Pt.4 (January 1994)
  • Electronic Engine Management; Pt.4 (January 1994)
  • Electronic Engine Management; Pt.5 (February 1994)
  • Electronic Engine Management; Pt.5 (February 1994)
  • Electronic Engine Management; Pt.6 (March 1994)
  • Electronic Engine Management; Pt.6 (March 1994)
  • Electronic Engine Management; Pt.7 (April 1994)
  • Electronic Engine Management; Pt.7 (April 1994)
  • Electronic Engine Management; Pt.8 (May 1994)
  • Electronic Engine Management; Pt.8 (May 1994)
  • Electronic Engine Management; Pt.9 (June 1994)
  • Electronic Engine Management; Pt.9 (June 1994)
  • Electronic Engine Management; Pt.10 (July 1994)
  • Electronic Engine Management; Pt.10 (July 1994)
  • Electronic Engine Management; Pt.11 (August 1994)
  • Electronic Engine Management; Pt.11 (August 1994)
  • Electronic Engine Management; Pt.12 (September 1994)
  • Electronic Engine Management; Pt.12 (September 1994)
  • Electronic Engine Management; Pt.13 (October 1994)
  • Electronic Engine Management; Pt.13 (October 1994)
Items relevant to "Courtesy Light Switch-Off Timer For Cars":
  • Courtesy Light Timer PCB pattern (PDF download) [05209931] (Free)
Articles in this series:
  • Computer Bits (July 1989)
  • Computer Bits (July 1989)
  • Computer Bits (August 1989)
  • Computer Bits (August 1989)
  • Computer Bits (September 1989)
  • Computer Bits (September 1989)
  • Computer Bits (October 1989)
  • Computer Bits (October 1989)
  • Computer Bits (November 1989)
  • Computer Bits (November 1989)
  • Computer Bits (January 1990)
  • Computer Bits (January 1990)
  • Computer Bits (April 1990)
  • Computer Bits (April 1990)
  • Computer Bits (October 1990)
  • Computer Bits (October 1990)
  • Computer Bits (November 1990)
  • Computer Bits (November 1990)
  • Computer Bits (December 1990)
  • Computer Bits (December 1990)
  • Computer Bits (January 1991)
  • Computer Bits (January 1991)
  • Computer Bits (February 1991)
  • Computer Bits (February 1991)
  • Computer Bits (March 1991)
  • Computer Bits (March 1991)
  • Computer Bits (April 1991)
  • Computer Bits (April 1991)
  • Computer Bits (May 1991)
  • Computer Bits (May 1991)
  • Computer Bits (June 1991)
  • Computer Bits (June 1991)
  • Computer Bits (July 1991)
  • Computer Bits (July 1991)
  • Computer Bits (August 1991)
  • Computer Bits (August 1991)
  • Computer Bits (September 1991)
  • Computer Bits (September 1991)
  • Computer Bits (October 1991)
  • Computer Bits (October 1991)
  • Computer Bits (November 1991)
  • Computer Bits (November 1991)
  • Computer Bits (December 1991)
  • Computer Bits (December 1991)
  • Computer Bits (January 1992)
  • Computer Bits (January 1992)
  • Computer Bits (February 1992)
  • Computer Bits (February 1992)
  • Computer Bits (March 1992)
  • Computer Bits (March 1992)
  • Computer Bits (May 1992)
  • Computer Bits (May 1992)
  • Computer Bits (June 1992)
  • Computer Bits (June 1992)
  • Computer Bits (July 1992)
  • Computer Bits (July 1992)
  • Computer Bits (September 1992)
  • Computer Bits (September 1992)
  • Computer Bits (October 1992)
  • Computer Bits (October 1992)
  • Computer Bits (November 1992)
  • Computer Bits (November 1992)
  • Computer Bits (December 1992)
  • Computer Bits (December 1992)
  • Computer Bits (February 1993)
  • Computer Bits (February 1993)
  • Computer Bits (April 1993)
  • Computer Bits (April 1993)
  • Computer Bits (May 1993)
  • Computer Bits (May 1993)
  • Computer Bits (June 1993)
  • Computer Bits (June 1993)
  • Computer Bits (October 1993)
  • Computer Bits (October 1993)
  • Computer Bits (March 1994)
  • Computer Bits (March 1994)
  • Computer Bits (May 1994)
  • Computer Bits (May 1994)
  • Computer Bits (June 1994)
  • Computer Bits (June 1994)
  • Computer Bits (July 1994)
  • Computer Bits (July 1994)
  • Computer Bits (October 1994)
  • Computer Bits (October 1994)
  • Computer Bits (November 1994)
  • Computer Bits (November 1994)
  • Computer Bits (December 1994)
  • Computer Bits (December 1994)
  • Computer Bits (January 1995)
  • Computer Bits (January 1995)
  • Computer Bits (February 1995)
  • Computer Bits (February 1995)
  • Computer Bits (March 1995)
  • Computer Bits (March 1995)
  • Computer Bits (April 1995)
  • Computer Bits (April 1995)
  • CMOS Memory Settings - What To Do When The Battery Goes Flat (May 1995)
  • CMOS Memory Settings - What To Do When The Battery Goes Flat (May 1995)
  • Computer Bits (July 1995)
  • Computer Bits (July 1995)
  • Computer Bits (September 1995)
  • Computer Bits (September 1995)
  • Computer Bits: Connecting To The Internet With WIndows 95 (October 1995)
  • Computer Bits: Connecting To The Internet With WIndows 95 (October 1995)
  • Computer Bits (December 1995)
  • Computer Bits (December 1995)
  • Computer Bits (January 1996)
  • Computer Bits (January 1996)
  • Computer Bits (February 1996)
  • Computer Bits (February 1996)
  • Computer Bits (March 1996)
  • Computer Bits (March 1996)
  • Computer Bits (May 1996)
  • Computer Bits (May 1996)
  • Computer Bits (June 1996)
  • Computer Bits (June 1996)
  • Computer Bits (July 1996)
  • Computer Bits (July 1996)
  • Computer Bits (August 1996)
  • Computer Bits (August 1996)
  • Computer Bits (January 1997)
  • Computer Bits (January 1997)
  • Computer Bits (April 1997)
  • Computer Bits (April 1997)
  • Windows 95: The Hardware That's Required (May 1997)
  • Windows 95: The Hardware That's Required (May 1997)
  • Turning Up Your Hard Disc Drive (June 1997)
  • Turning Up Your Hard Disc Drive (June 1997)
  • Computer Bits (July 1997)
  • Computer Bits (July 1997)
  • Computer Bits: The Ins & Outs Of Sound Cards (August 1997)
  • Computer Bits: The Ins & Outs Of Sound Cards (August 1997)
  • Computer Bits (September 1997)
  • Computer Bits (September 1997)
  • Computer Bits (October 1997)
  • Computer Bits (October 1997)
  • Computer Bits (November 1997)
  • Computer Bits (November 1997)
  • Computer Bits (April 1998)
  • Computer Bits (April 1998)
  • Computer Bits (June 1998)
  • Computer Bits (June 1998)
  • Computer Bits (July 1998)
  • Computer Bits (July 1998)
  • Computer Bits (November 1998)
  • Computer Bits (November 1998)
  • Computer Bits (December 1998)
  • Computer Bits (December 1998)
  • Control Your World Using Linux (July 2011)
  • Control Your World Using Linux (July 2011)
Items relevant to "Stereo Preamplifier With IR Remote Control; Pt.2":
  • IR Remote Control Stereo Preamplifier PCB patterns (PDF download) [01308931/2] (Free)
Articles in this series:
  • Stereo Preamplifier With IR Remote Control; Pt.1 (September 1993)
  • Stereo Preamplifier With IR Remote Control; Pt.1 (September 1993)
  • Stereo Preamplifier With IR Remote Control; Pt.2 (October 1993)
  • Stereo Preamplifier With IR Remote Control; Pt.2 (October 1993)
  • Stereo Preamplifier With IR Remote Control; Pt.3 (November 1993)
  • Stereo Preamplifier With IR Remote Control; Pt.3 (November 1993)
Articles in this series:
  • Amateur Radio (November 1987)
  • Amateur Radio (November 1987)
  • Amateur Radio (December 1987)
  • Amateur Radio (December 1987)
  • Amateur Radio (February 1988)
  • Amateur Radio (February 1988)
  • Amateur Radio (March 1988)
  • Amateur Radio (March 1988)
  • Amateur Radio (April 1988)
  • Amateur Radio (April 1988)
  • Amateur Radio (May 1988)
  • Amateur Radio (May 1988)
  • Amateur Radio (June 1988)
  • Amateur Radio (June 1988)
  • Amateur Radio (July 1988)
  • Amateur Radio (July 1988)
  • Amateur Radio (August 1988)
  • Amateur Radio (August 1988)
  • Amateur Radio (September 1988)
  • Amateur Radio (September 1988)
  • Amateur Radio (October 1988)
  • Amateur Radio (October 1988)
  • Amateur Radio (November 1988)
  • Amateur Radio (November 1988)
  • Amateur Radio (December 1988)
  • Amateur Radio (December 1988)
  • Amateur Radio (January 1989)
  • Amateur Radio (January 1989)
  • Amateur Radio (April 1989)
  • Amateur Radio (April 1989)
  • Amateur Radio (May 1989)
  • Amateur Radio (May 1989)
  • Amateur Radio (June 1989)
  • Amateur Radio (June 1989)
  • Amateur Radio (July 1989)
  • Amateur Radio (July 1989)
  • Amateur Radio (August 1989)
  • Amateur Radio (August 1989)
  • Amateur Radio (September 1989)
  • Amateur Radio (September 1989)
  • Amateur Radio (October 1989)
  • Amateur Radio (October 1989)
  • Amateur Radio (November 1989)
  • Amateur Radio (November 1989)
  • Amateur Radio (December 1989)
  • Amateur Radio (December 1989)
  • Amateur Radio (February 1990)
  • Amateur Radio (February 1990)
  • Amateur Radio (March 1990)
  • Amateur Radio (March 1990)
  • Amateur Radio (April 1990)
  • Amateur Radio (April 1990)
  • Amateur Radio (May 1990)
  • Amateur Radio (May 1990)
  • Amateur Radio (June 1990)
  • Amateur Radio (June 1990)
  • Amateur Radio (July 1990)
  • Amateur Radio (July 1990)
  • The "Tube" vs. The Microchip (August 1990)
  • The "Tube" vs. The Microchip (August 1990)
  • Amateur Radio (September 1990)
  • Amateur Radio (September 1990)
  • Amateur Radio (October 1990)
  • Amateur Radio (October 1990)
  • Amateur Radio (November 1990)
  • Amateur Radio (November 1990)
  • Amateur Radio (December 1990)
  • Amateur Radio (December 1990)
  • Amateur Radio (January 1991)
  • Amateur Radio (January 1991)
  • Amateur Radio (February 1991)
  • Amateur Radio (February 1991)
  • Amateur Radio (March 1991)
  • Amateur Radio (March 1991)
  • Amateur Radio (April 1991)
  • Amateur Radio (April 1991)
  • Amateur Radio (May 1991)
  • Amateur Radio (May 1991)
  • Amateur Radio (June 1991)
  • Amateur Radio (June 1991)
  • Amateur Radio (July 1991)
  • Amateur Radio (July 1991)
  • Amateur Radio (August 1991)
  • Amateur Radio (August 1991)
  • Amateur Radio (September 1991)
  • Amateur Radio (September 1991)
  • Amateur Radio (October 1991)
  • Amateur Radio (October 1991)
  • Amateur Radio (November 1991)
  • Amateur Radio (November 1991)
  • Amateur Radio (January 1992)
  • Amateur Radio (January 1992)
  • Amateur Radio (February 1992)
  • Amateur Radio (February 1992)
  • Amateur Radio (March 1992)
  • Amateur Radio (March 1992)
  • Amateur Radio (July 1992)
  • Amateur Radio (July 1992)
  • Amateur Radio (August 1992)
  • Amateur Radio (August 1992)
  • Amateur Radio (September 1992)
  • Amateur Radio (September 1992)
  • Amateur Radio (October 1992)
  • Amateur Radio (October 1992)
  • Amateur Radio (November 1992)
  • Amateur Radio (November 1992)
  • Amateur Radio (January 1993)
  • Amateur Radio (January 1993)
  • Amateur Radio (March 1993)
  • Amateur Radio (March 1993)
  • Amateur Radio (May 1993)
  • Amateur Radio (May 1993)
  • Amateur Radio (June 1993)
  • Amateur Radio (June 1993)
  • Amateur Radio (July 1993)
  • Amateur Radio (July 1993)
  • Amateur Radio (August 1993)
  • Amateur Radio (August 1993)
  • Amateur Radio (September 1993)
  • Amateur Radio (September 1993)
  • Amateur Radio (October 1993)
  • Amateur Radio (October 1993)
  • Amateur Radio (December 1993)
  • Amateur Radio (December 1993)
  • Amateur Radio (February 1994)
  • Amateur Radio (February 1994)
  • Amateur Radio (March 1994)
  • Amateur Radio (March 1994)
  • Amateur Radio (May 1994)
  • Amateur Radio (May 1994)
  • Amateur Radio (June 1994)
  • Amateur Radio (June 1994)
  • Amateur Radio (September 1994)
  • Amateur Radio (September 1994)
  • Amateur Radio (December 1994)
  • Amateur Radio (December 1994)
  • Amateur Radio (January 1995)
  • Amateur Radio (January 1995)
  • CB Radio Can Now Transmit Data (March 2001)
  • CB Radio Can Now Transmit Data (March 2001)
  • What's On Offer In "Walkie Talkies" (March 2001)
  • What's On Offer In "Walkie Talkies" (March 2001)
  • Stressless Wireless (October 2004)
  • Stressless Wireless (October 2004)
  • WiNRADiO: Marrying A Radio Receiver To A PC (January 2007)
  • WiNRADiO: Marrying A Radio Receiver To A PC (January 2007)
  • “Degen” Synthesised HF Communications Receiver (January 2007)
  • “Degen” Synthesised HF Communications Receiver (January 2007)
  • PICAXE-08M 433MHz Data Transceiver (October 2008)
  • PICAXE-08M 433MHz Data Transceiver (October 2008)
  • Half-Duplex With HopeRF’s HM-TR UHF Transceivers (April 2009)
  • Half-Duplex With HopeRF’s HM-TR UHF Transceivers (April 2009)
  • Dorji 433MHz Wireless Data Modules (January 2012)
  • Dorji 433MHz Wireless Data Modules (January 2012)
Articles in this series:
  • Programming The Motorola 68HC705C8 (July 1993)
  • Programming The Motorola 68HC705C8 (July 1993)
  • Programming the Motorola 68HC705C8 (October 1993)
  • Programming the Motorola 68HC705C8 (October 1993)
  • Programming The 68HC705C8 Microcontroller (December 1993)
  • Programming The 68HC705C8 Microcontroller (December 1993)
Articles in this series:
  • Remote Control (September 1993)
  • Remote Control (September 1993)
  • Remote Control (October 1993)
  • Remote Control (October 1993)
Lesson 2 Programming the Motorola 68HC705C8 microcontroller In Lesson 1, we discussed the following: (1) Programming Concepts; (2) Machine Code; (3) Mnemonics; (4) 6805 Programming Model; (5) Flowcharts. In this lesson, we will discuss Addressing Modes. To write a program for a micro­ controller, we need to go from a concept to machine code. The concept may be made easier to follow by using a flow chart, from which we can start writing mnemonics. The mnemonics and an addressing mode will enable us to arrive at the machine code which will ultimately run in our micro­ controller. Mnemonics The MC68HC705C8 has instructions that are one, two or three bytes long, depending on what they have to do. We refer to the differences in length of these instructions as addressing modes. The MC68HC705C8 has 62 basic instructions and 10 different ad­ dressing modes, giving a total of 210 different op-codes. Table 1 shows the 6805 CMOS mnemonics and addressing modes. It is usually referred to as the instruction set. If you count the mnemonics in the instruction set, you will get more than 62. This is because some of the mnemonics are repeated and some have the same op-code. When you write a program for a microprocessor, some mnemon­ i cs are straightforward and require need no further information; eg, Transfer Accumulator to indeX register (TAX), or CLear Carry bit (CLC). However, some instructions, like LoaD Accumulator (LDA) or STore Accumulator (STA), do need more information; eg, load with what or load/store from/to 80  Silicon Chip where? The added information, if any, and the length of the instruction (in bytes) is governed by the addressing mode. In this lesson, we will explain three of these addressing modes: (1) Inherent Addressing Mode Symbol for Inherent addressing: none. The CPU only requires one byte of data to process this in­struction. This byte is the opcode. All information required by the CPU is “inherently” known. In other words, the instruction needs no further information from the programmer. The first three addressing mode columns in Table 1 are inherent (INH), inherent accumulator (INHA) and inherent index register (INHX). The latter two are sometimes referred to as register addressing modes but in these lessons we will class them as inherent; eg, DECA, DECX, NOP, SWI, COMA, STOP, RORA and ROLX. (2) Immediate Addressing Mode Symbol for Immediate addressing: # The CPU requires two bytes of data to process this instruc­tion. The first byte is the op-code, while the second byte is the operand. The CPU requires the operand (byte) immediately follow­ing the op-code. This byte is known at the time the program is written and it becomes a permanent part of the program. The programmer uses the immediate byte for things like setting outputs, maths, logic and compare variables, etc; eg, ADD #, AND #, ORA #, EOR #, LDA #, LDX #, CMP # and CPX # (3) Extended Addressing Mode Symbol for Extended addressing: $$ or none. The CPU requires three bytes of data to process this in­struction. The first byte is the op-code, while the second and third bytes are the High and Low address (16-bit word) of the operand in memory. The CPU requires the operand (byte) which is extended any­where in mem­ ory. The memory location for this byte is known at the time the program is written. The extended address can be the address of an output or input port, a register in a timer/counter, or any address used by the microprocessor. In these lessons, we will use the “$$” symbol to indicate the extended addressing mode. Remember it as two hex 8-bit bytes which make a 16 bit word; eg, ADD $$, AND $$, ORA $$, EOR $$, LDA $$, STA $$ and LDX $$. The instruction set in Table 1 is presented in various forms. The MC68HC705C8 technical summary has the instruction set on page 30. It shows the mnemonics, addressing modes, op-code and number of bytes in a form similar to Table 1. It also shows the number of cycles each instruction takes to execute. Other Motoro­la publications show the instruction set in different forms again and the one you use is a matter of personal choice. As an exercise, try filling out Table 2 from the Motorola 6805 instruction set. If you want the number of cycles, you will need the MC68HC705C8 technical summary or some other 6805 in­struction set. This program, like most of the programs that are written for the MAL-4, starts at location $0030. This is the first RAM location – see page 18 of the manual for the memory map. This shows us all the memory locations in “map” form. We can determine which addresses are usable for RAM and where the input and output ports are, etc. Example program Let’s write a simple program to demonstrate the things we have covered so far. We will make the LEDs on the output port (port B) flash in an inward pattern at 0.5-second intervals. The first (and most important) task is to write a flow chart – see Fig.1. It shows us what to do in picture form. The steps for the program are as follows: (1). Turn off all the LEDS at the output port. (2). Wait for 0.5 seconds. (3). Turn on the four outside LEDs at the output port. (4). Wait for 0.5 seconds. (5). Turn on all the LEDs at the output port. (6). Wait for 0.5 seconds. (7). Go back and do it all again. Writing the code Program sheet Fig.1: the flow chart for our example program. The program first turns on the four outside LEDs at the output port, then waits 0.5 seconds before turning on the remaing four LEDs. The program has been written on the MAL-4 program sheet – see Table 3. A blank copy of this sheet comes with the MAL-4 manual and you should photocopy as many as you need for writing programs. An explanation of each column follows: Address: the address where the program is to be written. Code: the 1, 2 or 3 bytes of machine code. Label: A place for notes and program entry positions. Mnemonic: the instruction mnemonic. Operand: the operand byte or address. Comment: a place to write plain English comments. The first part of the program (comment box 1) is a load/store operation. The load part uses the mnemonic LDA. We want to clear the output port, so we load the accumulator with $00. Because this is known, we will use the Immediate addressing mode. If we look up the code for LDA # (immediate), it is $A6 and it is a 2-byte instruction. The first byte is $A6 and the second byte is $00 (because we want to load the accumulator with $00). The address location is then incremented by two to become $0032. In the Store part of the operation, the mnemonic used is STA. We want to store the contents of the accumulator at the output port (Port B). A look at the memory map shows port B at memory location $0001. Since this address is known, we use the Extended addressing mode. If you look up the code for STA $$ (Extended) it is $C7 and it is a 3-byte instruction. The second and third bytes are the address of the memory location, so it becomes C7 00 01. The address is now in­crement­ed by three and becomes $0035. Silicon Supply and Manufacturing 74HC11 $0.45 74HC27 .40 74HC30 .40 74HC76 .55 74HC86 .45 74HC138 .85 74HC139 .50 74HC154 3.15 74HC165 .85 74HC174 .65 74HC373 1.05 74F00 74F02 74F08 74F10 74F11 74F20 74F21 74F27 74F30 74F32 74F36 .40 .40 .40 .40 .40 .40 .40 .40 .40 .40 .85 74F38 74F151 74F163 74F169 74F175 74F241 74F244 74F257 74F258 74F353 74LS00 .65 .55 .70 1.92 .65 .95 .90 .60 1.80 1.45 .50 74LS01 74LS02 74LS03 74LS05 74LS11 74LS12 74LS13 74LS14 74LS20 74LS21 74LS27 MAIL ORDER SPECIALIST .50 .50 .45 .45 .50 .50 .85 .55 .55 .40 .40 74LS30 74LS33 74LS49 74LS73 74LS74 74LS83 74LS85 74LS90 74LS92 74LS109 74LS126 .40 .50 2.35 1.10 .45 .75 .60 .90 1.20 .90 .50 PO Box 92 Bexley North NSW Australia 2207 74LS138 74LS139 74LS147 74LS148 74LS151 74LS155 74LS158 74LS160 74LS164 74LS175 74LS191 Credit Cards welcome -Visa, Mastercard, Bankcard. Plus Sales Tax, packing and postage .60 .60 2.35 1.05 .50 .50 .70 .75 .75 .80 .80 74LS193 74LS196 74LS240 74LS241 74LS245 74LS257 74LS273 74LS366 74LS368 74LS373 74LS374 .80 1.35 .90 .95 .80 .60 .80 .55 .60 .80 .85 Ph.: (02) 554 3114 Fax: (02) 554 9374 After hours only bulletin board on (02) 554 3114 (Ringback). Let the modem ring twice, hang-up, redial the BBS number, modem answers on second call. October 1993  81 TABLE 1 Mnemonic Description Addressing Modes IMM DIR EXT IX0 IX1 IX2 ADC Add with carry INH A9 B9 C9 F9 E9 D9 ADD Add without carry AB BB CB DB EB DB AND Logical AND A4 B4 C4 F4 E4 D4 ASL Arithmetic shift left (same as LSL) 48 58 38 78 68 ASR Arithemtic shift right 47 57 37 77 67 BCC Branch if carry clear (same as BHS) BCLR 0 Clear bit 0 in memory 11 BCLR 1 Clear bit 1 in memory 13 BCLR 2 Clear bit 2 in memory 15 BCLR 3 Clear bit 3 in memory 17 BCLR 4 Clear bit 4 in memory 19 BCLR 5 Clear bit 5 in memory 1B BCLR 6 Clear bit 6 in memory 1D BCLR 7 Clear bit 7 in memory 1F BCS Branch if carry set (same as BLO) 25 BEQ Branch if equal 27 BHCC Branch if half carry clear 28 BHCS Branch if half carry set 29 BHI Branch if higher 22 BHS Branch if higher or same (see BCC) 24 BIH Branch if interrupt pin is high 2F BIL Branch if interrupt pin is low 2E BIT Bit test BLO Branch if lower (same as BCS) 25 BLS Branch if lower or same 23 BMC Branch if interrupt mask is clear 2C BMI Branch if minus 2B BMS Branch if interrupt mask is set 2D BNE Branch if not equal (to zero) 26 BPL Branch if plus 2A BRA Branch always 20 BRCLR 0 Branch if bit 0 is clear 01 BRCLR 1 Branch if bit 1 is clear 03 BRCLR 2 Branch if bit 2 is clear 05 BRCLR 3 Branch if bit 3 is clear 07 BRCLR 4 Branch if bit 4 is clear 09 BRCLR 5 Branch if bit 5 is clear 0B BRCLR 6 Branch if bit 6 is clear 0D BRCLR 7 Branch if bit 7 is clear BRN Branch never BRSET 0 Branch if bit 0 is set 00 BRSET 1 Branch if bit 1 is set 02 BRSET 2 Branch if bit 2 is set 04 BRSET 3 Branch if bit 3 is set 06 BRSET 4 Branch if bit 4 is set 08 BRSET 5 Branch if bit 5 is set 0A 82  Silicon Chip INH INH REL B5C BTB 24 A5 B5 C5 F5 E5 D5 0F 21 Mnemonic Description Addressing Modes INH INH INH IMM DIR EXT IX0 IX1 IX2 REL B5C BTB BRSET 6 Branch if bit 6 is set OC BRSET 7 Branch if bit 7 is set OE BSET 0 Set bit 0 in memory 10 BSET 1 Set bit 1 in memory 12 BSET 2 Set bit 2 in memory 14 BSET 3 Set bit 3 in memory 16 BSET 4 Set bit 4 in memory 18 BSET 5 Set bit 5 in memory 1A BSET 6 Set bit 6 in memory 1C BSET 7 Set bit 7 in memory BSR Branch to subroutine CLC Clear carry 98 CLI Clear interrupt mask bit 9A CLR Clear CMP Compare accumulator with memory COM Ones complement CPX Comapre index register with memory DEC Decrement EOR Exclusive OR ACC with memory INC Increment JMP Jump JSR Jump to subroutine LDA Load accumulator from memory A6 LDX Load index register from memory AE LSL Logical shift left (same as ASL) 48 58 LSR Logical shift right 44 54 MUL Multiply unsigned NEG Negate 40 50 NOP No operation ORA Inclusive OR ACC with memory ROL Rotate left 49 59 ROR Rotate right 46 56 RSP Reset stack pointer 9C RTI Return from interrupt 80 RTS Return from subroutine 81 SBC Subtract with carry SEC Set carry bit 99 SEI Set interrupt mask 9B STA Store accumulator STOP Enable IRQ, stop oscillator STX Store index register SUB Subtract SWI Software interrupt 83 TAX Transfer accumulator to index register 97 TST Test for negative or zero TXA Transfer index register to accumulator 9F WAIT Enable interrupt, stop processor 8F 1E AD 4F 43 4A 5F 3F A1 B1 A3 B3 53 33 5A C3 3A A8 4C C1 5C B8 C8 3C 7F 6F F1 E1 73 63 F3 E3 7A 6A F8 E8 D1 D3 D8 7C 6C BC CC FC EC DC BD CD FD ED DD B6 C6 F6 E6 D6 BE CE FE EE DE 38 78 68 34 74 64 30 70 60 FA EA 39 79 69 36 76 66 42 9D AA A2 BA CA DA B2 C2 F2 E2 D2 B7 C7 F7 E7 D7 B5 CF FF EF DF B0 C0 F0 E0 D0 7D 6D 8E A0 4D 5D 3D October 1993  83 Table 2 Opcode Mnemonic A. Mode No. Bytes No. Cycles A6 LDA IMM 2 2 LDA EXT SWI INH STA EXT JMP EXT 43 A3 11 Box 2 is the 0.5-second time delay. Microprocessors are de­signed to run very fast, so it is sometimes necessary to slow down their operation. We do this by making them count a large number down to zero and this requires a time delay loop. The MAL-4 has a number of time delays in its monitor pro­gram. They are in a form called subroutines. You use a subroutine by jumping to it and the program remembers the point to which it is to return. Subroutines and time delay loops will be covered in later lessons. Time delay subroutines The time delay subroutines in the MAL-4 use the accumulator to vary the length of the delay (delay x acc), so you must load the accumulator before jumping to the subroutine. The delay subroutines and their addresses are as follows: D10µs: Delay = 10µs x Accumulator – $1498 D100µs: Delay = 100µs x Accumulator – $14A1 D1ms: Delay = 1ms x Accumulator –$14BD D10ms: Delay = 10ms x Accumulator – $14D9 D100ms: Delay = 100ms x Accumulator – $14E6 D1sec: Delay = 1 sec x Accumulator – $14F3 D1min: Delay = 1 min x Accumulator – $1500 We want a 0.5 second delay so the D10ms delay subroutine will do. This box requires a load accumulator immediate (LDA #) and a Jump to SubRoutine extended (JSR $$). The op-code for LDA # is $A6. The second byte of code will need to be 50 in hex or $32, since 50 x the 100ms delay subroutine gives a delay time of 0.5ms. If you look up JSR extended, it is a 3-byte instruction and the op-code is $CD. The second and third bytes will be the high and low address bytes of the location of the D100ms subroutine, Table 3 ADDRESS CODE LABEL MNEMONIC OPERAND COMMENT 0030 A600 START LDA #$00 0032 C70001 STA $$0001 Clear accumulator & store at output 0035 A632 LDA #$32 0037 CD14D9 JSR $$14D9 003A A6C3 LDA #$C3 003C C70001 STA $$0001 003F A632 LDA #$32 0041 CD14D9 JSR $$14D9 0044 A6FF LDA #$FF 0046 C70001 STA $$0001 0049 A632 LDA #$32 004B CD14D9 JSR $$14D9 Set time delay 50 ($32) x ACC = 0.5 seconds 004E CC0030 JMP $$0030 Jump to start 84  Silicon Chip Set time delay 50 ($32) x ACC = 0.5 seconds Load accumulator & store at output Set time delay 50 ($32) x ACC = 0.5 seconds Load accumulator & store at output $14D9. Don’t forget that the address is incremented by one, two or three bytes as the instruction requires (in this case, it is incremented by three bytes – $37 + $3 = $3A). Box 3 is almost the same as box 1 but instead of clearing the output port, we now want to switch on the LEDs on bits 7, 6, 1 & 0. This pattern corresponds to 11000011 in binary or $C3 in hex. Box 4 is a 0.5-second time delay and is the same as box 2. Box 5 is almost the same as box 1 but instead of clearing the output port, we now want to switch on all the LEDs. This means that the immediate byte will be $FF (ie, 11111111 in binary). Box 6 is a 0.5 second time delay and is the same as box 2. Box 7 (which is not really a box) needs to be a jump in­struction. This tells the processor to jump to an address loca­tion, in this case to the start address ($0030). The mnemonic and addressing mode will be JMP $$ (Extended). If you look this up in the instruction set you will find it to be a 3-byte instruction with an op-code of $CC. The second and third bytes will be the high and low bytes of the destination address $0030. Load the program into the MAL-4 and run the program from location $0030. The output port LEDs should flash in the pattern described. If not, go back and check that the program has been entered correctly. Mode 2 (the disassemble) mode may help you find your mistake. Things to do (1). Rewrite the flow chart and the program to make the LEDs turn on in a smooth inward pattern. In other words, make the LEDs turn on one bit at a time instead of two. (2). Experiment with the time delay to give a better visual effect. (3). Rewrite the flow chart and the program to make a 8-bit “Kitt” scanner; ie, one LED on at a time switching from left to right and back again. This will take up lots of RAM and you may need to jump to the RAM located at $0150 (page 1) and back again. This done, try writing programs for other time delays and patterns. (4). Do further reading on instructions and addressing modes, especially if you can get detailed information on the 6805 instruction set from a SC Motorola text/reference book.