EE 308

Solutions to Exam 1


  1. 0xCD = 0b11001101
    0xCD = 205 (unsigned)
    0xCD = -51 (signed)
    Do the following operations on eight-bit numbers. Indicate the answer, and whether a carry (borrow) and/or overflow was generated:

    68
    + 57
    C5
    + 7B
    23
    + 4E
    D3
    + A4
    00
    - 6D
    Answer BF 40 71 77 93
    Carry (Borrow) No Yes No Yes Yes
    Overflow Yes No No Yes No


  2. Below are some data in the HC11 memory
         |  0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F
    -----|---------------------------------------------------------------
    0000 | 14  00  B7  23  B4  18  30  18  8F  FE  22  02  5C  E7  03  26
    0010 | 0F  CC  0D  10  8E  01  FF  DE  20  EC  02  BD  00  1E  3C  96
    0020 | 00  08  1A  94  10  18  38  39  A2  38  9A  05  F2  20  A5  ED 
    
    Show what will be in the registers (in hex) after each of the instructions. If the instruction does not change a register, you may leave that entry blank.
    Instruction A B D X Y SP Addressing
    Mode

    00000000000000000000
    lds #0x1ff




    01FFIMM
    ldx 0x0020


    0008

    EXT
    ldd 02,x22022202


    IND
    jsr 0x011e




    01FDEXT
    pshx




    01FBINH
    ldaa *0x002cF2
    F202


    DIR
    ldab #0x1a
    1AF21A


    IMM
    anda 0x001002
    021A


    EXT
    puly



    000801FDINH
    rts




    01FFINH


  3. Fill in the missing parts (a) through (l) of the assembly listing below. In parts (j) and (l) put in a label, not a number. All other parts should be filled in with hex numbers.
                                      1 ;
                                      2         .title  EE 308 Exam 1
       0004                           3 LEN = 0x04
                                      4 
                                      5         .area   DATA (ABS)
                                      6         .org    0x20
       0020     0A (a)                7 val1:   .db     10
       0021     C2 00                 8 val2:   .dw     0xc200
       0023     F0                    9         .db     0b11110000
       0024                          10 table:  .ds     LEN
       0028 (b) F6 (c)               11 count:  .db     -10
                                     12 
                                     13         .area   CODE (ABS)
                                     14         .org    0x0100
       0100     DE 21 (d)            15 start:  ldx     *val2
       0102     CC (e) 33 44         16         ldd     #0x3344
       0105     5C                   17         incb    
       0106     E7 04 (f)            18         stab    LEN,x
       0108 (g) 96 23 (h)            19         ldaa    *(val2+2)
       010A     B7 (i) 00 24         20         staa    table
       010D     7C 00 28             21         inc     count (j)
       0110     3F                   22 last:   swi
    
    
    ASxxxx Assembler V01.50  (Motorola 6811), page 1.
    EE 308 Exam 1
    Symbol Table
    
        LEN                             =  0004 
      1 count                              0028 
      2 last                               0110 (k)
      2 start                              0100
      1 table (l)                          0024
      1 val1                               0020
      1 val2                               0021
    
    
    
    (a) 0A     (b) 0028     (c)  F6       (d)   21
    (e) CC     (f) E7 04    (g)  0108     (h)   23
    (i) B7     (j) count    (k)  0110     (l)   table
    

  4. An HC11 is being used, among other things, as a temperature controller. It reads the temperature from Port C, and turns on and off the heater with Bit 3 of Port B. A subroutine for the HC11 should do the following:
    1. Read Port C
    2. If the value read from Port C (interpreted as an unsigned number) is greater than 7210, clear bit 3 of Port B. Otherwise, set bit 3 of Port B. Leave all the other bits of Port B unchanged.
    3. Repeat (i.e., go to (a)).
    Draw a flow chart and write the program to accomplish the control function. The temperature control part should be called as a subroutine.

    Here is a flowchart:

    Here is a program to implement the flowchart:

    PORTB      = 0x1004
    PORTC      = 0x1003
    PROG       = 0x0100
    STACK      = 0x01ff
    SET_POINT  = 72
    ;
                    .area   CODE (ABS)
                    .org    PROG
    
                    lds     #STACK         ;load stack pointer
    loop:           jsr     control_temp   ;execute temp control routine
                    bra     loop           ;repeat
    
    control_temp:   psha                   ;save ACC A
                    ldaa    PORTC          ;read Port C
                    cmpa    #SET_POINT     ;compare to set point
                    blo     heat_on        ;too cold; turn heat on
    heat_off:       ldaa    PORTB          ;too hot, turn heat off
                    anda    #0b11110111    ;clear bit 3 of Port B
                    staa    PORTB
                    bra     done           ;
    heat_on:        ldaa    PORTB          ;turn heat on
                    oraa    #0b00001000    ;set bit 3 of Port B
                    staa    PORTB
    done:           pula                   ;restore ACC A
                    rts                    ;all done
    
    
    


Bill Rison, <rison@ee.nmt.edu >