|
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.
Ans: Change blo start to blo begin
Ans: Change staa
list,x to stab list,x
Ans: Because the indexed store (ldab list,x) starts at( list + x ) which is (2 + 15) because x is initialized with ldx #$000F.