******
** DIAL_2.ASM  (68HC11)
**
** Illustrates Indirect Table Lookup.
**
** Dials tel number identified by toggle switches.
**
** Toggle switches are mapped into a pointer which points to the
** address of the desired telephone number.
**
** Note that subroutines DIAL, PULSE, etc are not included.  See
** Program DIAL_2.
**
** P. H. Anderson, MSU, 14 April 93
*******

PSCT            EQU $C000
DSCT            EQU $D000
IDSCT           EQU $D300

REG_BASE        EQU $1000
STACK_TP        EQU $0045

PORTB  EQU $04
PORTC  EQU $03
DDRC   EQU $07

          ORG PSCT

          LDS #STACK_TP
          LDY #REG_BASE
          CLR DDRC,Y      * portc configured as input

          BCLR PORTB,Y %00000001  * release dial relay

          LDAA PORTC,Y  * form pointer
          STAA TEMP
          CLRA
          LDAB TEMP
          LSLD
          STD OFFSET    * OFFSET now contains 2 * SW

          LDD #PTR_BASE
          ADDD OFFSET

          XGDX          * X now points to pointer which points
*                       * to first location of desired tel number.
          LDX 00,X      * be sure you understand this
* this is not a trivial concept
          BSR DIAL      * address passed in X

          SWI

DIAL
*         See Program DIAL_1
          RTS

          ORG DSCT

TEMP      RMB 1
OFFSET    RMB 2

          ORG IDSCT

PTR_BASE

        FDB TEL_0               * pointer cross reference table
        FDB TEL_1
        FDB TEL_2

TEL_0
* 9 1 201 949 2007
       FCB 09, 01
       FCB 02, 00, 01
       FCB 09, 04, 09, 02, 00, 00, 07
       FCB $FF
TEL_1
* 3911
       FCB 03, 09, 01, 01, $FF

TEL_2
* 9 893 8762
       FCB 09, 08, 09, 03, 08, 09, 03, 08, 07, 06, 02
       FCB $FF

