Exam 1

Microprocessors Lab
Spring 1998

Closed book/closed notes. Answer each question completely. Each problem has several parts, therefore answer as much of any question as you can to receive maximum partial credit.
 
  1. For each of the M68000 instructions given below
    1. indicate the addressing mode used in the source operand
    2. give the instruction's RTL equivalent

    1. ADD.B D3,D5
      1. register direct
      2. D5(0:7) <-- D5(0:7) + D3(0:7)
    2. AND.B $1004,D1
      1. memory direct or absolute
      2. D1(0:7) <-- D1(0:7) ^ M[$1004]
    3. SUB.B #$12,(A4)
      1. immediate
      2. M[A4](0:7) <-- M[A4](0:7) - $12
    4. ADD.W (A5)+,D4
      1. address register indirect with postincrement
      2. M[A5](0:15) <-- M[A5](0:15) + D4(0:15)
        A5 <-- A5 + 2

  2. Write a M68000 program that uses the TUTOR functions to prompt the user to type characters by printing string to the screen and then display any character typed if it is a capital letter (A-Z) and its ASCII value is even.  The program should exit to TUTOR if the ESC key is pressed or after twenty characters have been displayed.
     
                     org      $1000
          
          charin     equ      247
          charout    equ      248
          stringout  equ      243
          tutorexit  equ      228
          escape     equ      $1B
          
    
                     lea      prompt,a5
                     lea      endprompt,a6
                     move.w   #tutorexit
                     trap     #14
          
                     move.b   #20,d3
    
          read       move.w   #charin,d7
                     trap     #14
    
                     cmp.b    #escape,d0
                     beq      exit
                     cmp.b    #'A',d0
                     blt      read
                     cmp.b    #'Z',d0
                     bgt      read
    
                     move     d0,d1
                     and.b    #$01,d1
                     bne      read
    
                     move.w   #charout,d7
                     trap     #14
    
                     sub.b    #1,d3
                     bne      read
    
          exit       move.w   #tutorexit,d7
                     trap     #14
          
          
          prompt     dc.b     'Please begin typing characters',$0D,$0A
          endprompt  dc.b     0
                     end      $1000
         

  3. Complete the following M68000 program below so that is sums the 16-bit numbers starting at the label vector and places the result in the longword labeled result. The number of values in the vector is equated to the label VEC_LENGTH.
                      org      $1000
    
          VEC_LENGTH  equ      10
          tutorexit   equ      228
    
          main        lea      vector,A1
    
          
                      move.l   #0,d1
                      move.l   #0,result
                      move.b   #VEC_LENGTH,d2
    
          sum         move.w   (A1)+,d1
                      add.l    d1,result
                      sub.b    #1,d2
                      bne      sum
          
           
          exit        move.w   #tutorexit,D7
                      trap     #14
    
          * examine the next two lines of errors
          vector      dc.w     45,6356,10,134,9012
                      dc.w     345,1753,926,213,10032
    
          result      ds.l     1
                      end      $1000
          
  4. Thoroughly compare the M68000 microprocessor to the M68HC11 microcontroller for each of the given criteria.
    1. Programmer's Model
    2. Word Size
    3. Instruction Set
    4. Addressing Modes
    5. Board space
    6. Control or Data Procesing Orientation
    7. Peripheral Architecture

  5. Answer the following questions about the MC68HC11 program segment given below.
                      org      $100
    
          main        ldaa     #5
                      ldab     #4
                      ldx      #10
          loop        jsr      addit
                      dex
                      bne      loop
    
          more_code   ...
    
          addit       pshb
                      aba
                      rts
          
    1. What is wrong with the subroutine addit? Explain the program's behavior if it is executed as written. Write a correct version of addit.

      Since the subroutine pushes the contents of ACCB onto the stack, but does not restore them, the stack pointer will incorrectly point to the return address of the instruction following the subroutine call. In this case, the correct address would be $010A. Without the pull, the processor would return to the instruction at address $0A04, which is obviously incorrect. A corrected version of the subroutine is given by removing the pshb instruction. Alternatively, a pulb could be added before the rts instruction.

      	    addit     aba
      	              rts
      	    
    2. What program structure (while...do, do...until, etc.) is used in the main loop?

      do...until

    3. Assuming that the subroutine addit is written correctly, what value would ACCA contain after execution of the main loop?

      45



| Home | EE Department | College of Engineering | USF Home |

John C. Sperandio <sperandi@eng.usf.edu >
Last modified: Sat Oct 24 15:17:20 EDT 1998