ECEN 3213

Spring 2001

Quiz 3

28 March 2001

 

 

Solution

 

 

Consider the following Program:

 

count    equ             $0001

list        equ            $0002

temp     equ            $0003

            org      $E000

start      ldaa            #$00

            ldx            #$000F

            staa            count

begin    ldab            $1004            ;load value from port E into Register B

            stab            temp     ; store value into memory

            inx                    ; increment Register X for storing a value

            inca                            ; increment count of number of values read.

            staa            count

            staa            list,x              ; store read value into memory.

            ldaa            count

            cmpa            #100            ; check for count hitting 100.

            blo            start     

            stop                  ; count hit 100, all done.

            org $FFFE

            dc.w start

            end

    _____________________________________________________________

The program above assembled with no errors.  However, it ran forever, not stopping after reading 100 values on Port E.  Also, when the memory was inspected as I stepped through it, I noticed it was NOT saving the correct value on Port E.

  1. (35pts) What single statement needs to be changed, and to what does it need to be changed, to get the program to properly stop after 100 values have been read?

   Ans:  Change blo start to blo begin

 

  1. (35pts) What single statement needs to be changed, and to what does it need to be changed, to get the program to properly store the input value into the memory?

    Ans: Change staa list,x   to  stab list,x

 

  1. (30pts) Why does it work Properly to have “list equ $0002”?  In other words, why doesn’t the indexed addressing cause a value to be accidentally confused with temp, which is in location $0003?

Ans: Because the indexed store (ldab list,x) starts at( list + x ) which is (2 + 15) because x is initialized with ldx #$000F.