Sample program for Lab 2


                   1 ; 68HC11 demo program
                   2 ; Bill Rison
                   3 ; 1/2/96
                   4 
                   5 ; This program takes a table of data, and creates
                   6 ; new table which is the original table divided by 2
                   7 
                   8          .title  LAB 1 Demo Program
                   9 
0000              10 EVBRAM   =  0x0000        ;0x0000 is start of user ram
0000              11 DATARAM  =  EVBRAM
0100              12 PROG     =  EVBRAM+0x100  ;start program above BUFFALO
0002              13 COUNT    =  2             ;number of entries in table
                  14 
                  15          .area   CODE  (ABS)
                  16 
                  17          .org    PROG     ;set prog counter to 0x0100
0100 C6 02        18          ldab    #COUNT   ;ACC B = num entries left
0102 CE 00 00     19          ldx     #table1  ;Reg X points to next entry
0105 A6 00        20 repeat:  ldaa    0,x      ;Get table1 entry into ACC A
0107 47           21          asra             ;Divide by 2
0108 A7 02        22          staa    COUNT,x  ;Save in table2
010A 08           23          inx              ;REG X points to next entry
010B 5A           24          decb             ;Decrement number left
010C 26 F7        25          bne     repeat   ;If not done, do next entry
010E 3F           26          swi              ;Done -- Exit
                  27 
                  28 
                  29          .area   DATA  (ABS)
                  30 
                  31          .org    DATARAM
                  32 ;initialize table1 (COUNT bytes long)
0000 07 AE        33 table1:  .db     0x07,0xae
0002              34 table2:  .ds     COUNT    ;reserve space for table2


Symbol Table

 COUNT       =  0002 
 DATARAM     =  0000 
 EVBRAM      =  0000 
 PROG        =  0100 
  1 repeat      0105 R
  2 table1      0000 R
  2 table2      0002 R


Cycle by cycle execution of above program



ADDR DATA|    |  A  | B  |  X   |  PC  | addr |data|R/W| cycles
 ---- -- |    |-----|----|------|------|------|----|---|-------
 0000 07 |    |     |    |      | 0100 | 0100 | C6 | R |   1
         |    |     | 02 |      |      | 0101 | 02 | R |   2
 0001 AE |    |     |    |      | 0102 | 0102 | CE | R |   3
         |    |     |    |      |      | 0103 | 00 | R |   4
 ---- -- |    |     |    | 0000 |      | 0104 | 00 | R |   5
         |    |     |    |      | 0105 | 0105 | A6 | R |   6
 0100 C6 |    |     |    |      |      | 0106 | 00 | R |   7
         |    |     |    |      |      | FFFF | ?? | R |   8
 0101 02 |    | 07  |    |      |      | 0000 | 07 | R |   9
         |    |     |    |      | 0107 | 0107 | 47 | R |  10
 0102 CE |    | 03  |    |      |      | 0108 | A7 | R |  11
         |    |     |    |      | 0108 | 0108 | A7 | R |  12
 0103 00 |    |     |    |      |      | 0109 | 02 | R |  13
         |    |     |    |      |      | FFFF | ?? | R |  14
 0104 00 |    |     |    |      |      | 0002 | 03 | W |  15
         |    |     |    |      | 010A | 010A | 08 | R |  16
 0105 A6 |    |     |    |      |      | 010B | 5A | R |  17
         |    |     |    | 0001 |      | FFFF | ?? | R |  18
 0106 00 |    |     |    |      | 010B | 010B | 5A | R |  19
         |    |     | 01 |      |      | 010C | 26 | R |  20
 0107 47 |    |     |    |      | 010C | 010C | 26 | R |  21
         |    |     |    |      |      | 010D | F7 | R |  22
 0108 A7 |    |     |    |      |      | FFFF | ?? | R |  23
         |    |     |    |      | 0105 | 0105 | A6 | R |  24
 0109 02 |    |     |    |      |      | 0106 | 00 | R |  25
         |    |     |    |      |      | FFFF | ?? | R |  26
 010A 08 |    | AE  |    |      |      | 0001 | AE | R |  27
         |    |     |    |      | 0107 | 0107 | 47 | R |  28
 010B 5A |    | D7  |    |      |      | 0108 | A7 | R |  29
         |    |     |    |      | 0108 | 0108 | A7 | R |  30
 010C 26 |    |     |    |      |      | 0109 | 02 | R |  31
         |    |     |    |      |      | FFFF | ?? | R |  32
 010D F7 |    |     |    |      |      | 0003 | D7 | W |  33
         |    |     |    |      | 010A | 010A | 08 | R |  34
 010E 3F |    |     |    |      |      | 010B | 5A | R |  35
         |    |     |    | 0002 |      | FFFF | ?? | R |  36
              |     |    |      | 010B | 010B | 5A | R |  37
              |     | 00 |      |      | 010C | 26 | R |  38
              |     |    |      | 010C | 010C | 26 | R |  39
              |     |    |      |      | 010D | F7 | R |  40
              |     |    |      |      | FFFF | ?? | R |  41
              |     |    |      |      | 010E | 3F | R |  42