Assignment 2 - Addressing Modes, Hand-assembly

Addressing Modes

Name:

Section:

Documentation:

All answers should be in little-endian, hex format.

  1. (10pts each) For each of the following instructions, identify the addressing modes being used. For the indicated instructions, write the hand-assembled machine code that corresponds to that instruction.
    swpb    r7
    Addressing mode used for source:


    Addressing mode used for destination:


    hand-assembled machine code (in little-endian, hex format):



    xor     @r12+, 0(r6)
    Addressing modes used for Source:


    Addressing mode used for destination:


    hand-assembled machine code (in little-endian, hex format):



    nop
    Addressing mode used for source:


    Addressing mode used for destination:


    hand-assembled machine code (in little-endian, hex format):



    mov.w   @r12, &0x0200
    Addressing mode used for source:


    Addressing mode used for destination:


    hand-assembly of mov @r12, r6:



  1. (5pts) Consider the following code snippet:
             jmp     TARGET      ; address is 0xc000
    ...
    TARGET:     nop                 ; address is 0xc024
    What addressing mode do relative jumps use (if any)?






  1. (20pts) Consider the following code snippet: mov.w #0xFF, P1OUT ;P1OUT is 0x0021
    a) (5pts) What addressing modes are being used here?


    Addressing mode used for source:


    Addressing mode used for destination:


    b) (10pts) The programmer wants this code to move 0xFF into P1OUT, but the code isn't working. Why not?
    Hint: talk about the assembly / linking process.










    c) (5pts) How would you change the code snippet to fix the problem?










  1. (10pts) Consider the following code snippet: mov.w r10, @r9 a) (5pts) This doesn't assemble. Why?










    b) (5pts) What's an equivalent replacement instruction?





  1. (5pts)What is the purpose of emulated instructions?










  1. (20pts)Use the MSP430x2xx Family User's Guide to answer the following questions:

    a) (5pts) What status bits does the TST instruction manipulate?




    b) (10pts) In the example code for the CMP instruction (page 77) what role do the R6 and R7 registers play?








    c) (5pts) In the Digital I/O section, how is it recommended that you should configure unused pins? In your own words, explain why is this course of action recommended.