Docstoc

Lab_1

Document Sample
Lab_1 Powered By Docstoc
					EEEN 3449
Lab # 1 Fall 2010
Addressing Mode

A) Type in the following assembly program:

       ORG               $2000                ;starting address is                   @ $2000
       LDD              #$BBCC                ;load constant $BBCC                   to Register D
       STAA              $1501                ;store accumulator A                   to location $1501
       STAB              $1502                ;store accumulator B                   to location $1502
       LDAA              $1501                ;[A] <= [$1501]
       LDAB              $1502                ;[B] <= [$1502]
       STOP
       END

With the AsmIDE, once you assemble the program, you will get a filename.lst file. Open the list
file, you will see the following:

as12, an absolute assembler for Motorola MCU's, version 1.2h

2000                     ORG            $2000           ;starting address is               @ $2000
2000   cc   bb   cc      LDD           #$BBCC           ;load constant $BBCC               to Register D
2003   7a   15   01      STAA           $1501           ;store accumulator A               to location $1501
2006   7b   15   02      STAB           $1502           ;store accumulator B               to location $1502
2009   b6   15   01      LDAA           $1501           ;[A] <= [$1501]
200c   f6   15   02      LDAB           $1502           ;[B] <= [$1502]
200f   18   3e           STOP
                         END

Executed: Thu Sep 13 22:09:52 2007
Total cycles: 28, Total bytes: 17
Total errors: 0, Total warnings: 0

The first column is for the Program Counter (PC).
Reset the MiniDragon+ and load the program to the development board.
Type BR 2006. That is to set the breakpoint at address $2006.
Type g 2000, you will see the following:

User Bkpt Encountered

PP   PC        SP    X   Y    D = A:B                    CCR = SXHI NZVC
38 2006       3C00 0000 0000     BB:CC                         1001 1000
Xx: 2006      7B1502       STAB $1502

At the cursor, type md 1500                Note: md stands for memory display

The display will be as the following:

1500 B9 BB FE 47 – 0E EB 4B 9E – 64 59 00 7D – E7 8F 34 22



            Texas A&M University-Kingsville, Electrical Engineering & Computer Science Department        1
The second number represents the address location $1501, the content in $1501 is $BB.
The instruction        STAA          $1501           ; [$1501] <= [A]
Similarly, you can set another breakpoint at location $2009 by type BR 2009, and check the
content in memory location $1502.

B) The following assembly program is to illustrate the different type of indexed addressing:
   You can cut and past from the WORD document to the AsmIDE.

      ORG     $2000     ;starting address is @ $2000
;loading data to the memory
      LDD     #$0011    ;load constant $0011 to Reg A:B
      STAA    $1500     ;[$1500] = $00
      STAB    $1501     ;[$1501] = $11
      LDD     #$2233    ;load constant $2233 to Reg A:B
      STAA    $1502     ;[$1502] = $22
      STAB    $1503     ;[$1503] = $33
      LDD     #$4455    ;load constant $4455 to Reg A:B
      STAA    $1504     ;[$1504] = $44
      STAB    $1505     ;[$1505] = $55
      LDD     #$6677    ;load constant $6677 to Reg A:B
      STAA    $1506     ;[$1506] = $66
      STAB    $1507     ;[$1507] = $77
      LDD     #$8899    ;load constant $8899 to Reg A:B
      STAA    $1508     ;[$1508] = $88
      STAB    $1509     ;[$1509] = $99
      LDD     #$AABB    ;load constant $AABB to Reg A:B
      STAA    $150A     ;[$150A] = $AA
      STAB    $150B     ;[$150B] = $BB
      LDD     #$CCDD    ;load constant $CCDD to Reg A:B
      STAA    $150C     ;[$150C] = $CC
      STAB    $150D     ;[$150D] = $DD
      LDD     #$EEFF    ;load constant $EEFF to Reg A:B
      STAA    $150E     ;[$150E] = $EE
      STAB    $150F     ;[$150F] = $FF
;5-bit Constant Offset Indexed Addressing (offset is between -16 ~ +15)
      LDX     #$1509
      LDAA    5,X
      LDAB    -8,X
;9-bit Constant Offset Indexed Addressing (offset is between -256 ~ +255)
     LDY      #$1590
      LDAA    -140,Y
      LDY     #$1490
      LDAB    $76,Y
;16-bit Constant Offset Indexed Addressing
     LDX      #$1000
     LDAA     $50F,X
     LDY      #$2000
     LDAB     -$AF6,Y
;16-bit Constant Indirect Indexed Addressing



            Texas A&M University-Kingsville, Electrical Engineering & Computer Science Department   2
      LDD     #$1505
      STAA    $1515                  ;[$1515] = $15
      STAB    $1516                  ;[$1516] = $05
      LDX     #$152D
      LDAA    [-$18,X]               ;$152D - $18 = $1515
;note: [$1505] = $55
      LDD     #$1508
      STAA    $1545                  ;[$1545] = $15
      STAB    $1546                  ;[$1546] = $08
      LDX     #$152D
      LDAB    [$18,X]                ;$152D + $18 = $1545
;note [$1508] = $88
      STOP
      END

At the end of each Offset Index Addressing, set your breakpoint. Verify the content in either
Accumulator A or B.

Keep in mind the address content for md 1500 is declared in the beginning as the following:

1500 00 11 22 33 – 44 55 66 77 – 88 99 AA BB – CC DD EE EE

Modify the offset for each of the indexed addressing, and verify & record two different offsets
for each type of the indexed addressing.

C) Modify the loading data to memory for the above assembly program. Use Auto Pre/Post-
   Increment Indexed Addressing., e.g,     LDAA         1, Y+

   Verify the contents in each of the address location.

You can use the provided registers map to illustrate the content in certain memory locations.




            Texas A&M University-Kingsville, Electrical Engineering & Computer Science Department   3
EEEN 3449
Registers Map                                                                 Name:




                                               Address                   Address                  Address
 A                                       B      $1500       $00
 D                                              $1501       $11
                                                $1502       $22
 X                                              $1503       $33
                                                $1504       $44
 Y                                              $1505       $55
                                                $1506       $66
 SP                                             $1507       $77
                                                $1508       $88
 PC                                             $1509       $99
                                                $150A       $AA
       S X H I N Z V C                          $150B       $BB
CCR                                             $150C       $CC
                                                $150D       $DD
                                                $150E       $EE
                                                $150F       $FF




                                               Address                   Address                  Address
 A                                       B      $1500       $00
 D                                              $1501       $11
                                                $1502       $22
 X                                              $1503       $33
                                                $1504       $44
 Y                                              $1505       $55
                                                $1506       $66
 SP                                             $1507       $77
                                                $1508       $88
 PC                                             $1509       $99
                                                $150A       $AA
       S X H I N Z V C                          $150B       $BB
CCR                                             $150C       $CC
                                                $150D       $DD
                                                $150E       $EE
                                                $150F       $FF



          Texas A&M University-Kingsville, Electrical Engineering & Computer Science Department             4

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:8
posted:10/31/2011
language:Icelandic
pages:4