Hardware Reference
In-Depth Information
User Bkpt Encountered
PP PC
SP
X
Y
D 5 A:B
CCR 5 SXHI
NZVC
38 1519
3C00
100F
0000
00:F0
1001
0000
xx: 1519
88F4
EORA
#$F4
+ md 1010
1010 22 24 26 28 - 00 F0 B9 A9 - 2A CA FA DB - AC DA 18 97 “$&(. . . .*. . . . . . .
.
The value of sum is still incorrect. Again trace the program up to the third instruction.
+ pc 1500
PP PC
SP
X
Y
D 5 A:B
CCR 5 SXHI
NZVC
38 1500
3C00
100F
0000
00:F0
1001
0000
xx: 1500
CE1000
LDX
#$1000
+ t 3
PP PC
SP
X
Y
D 5 A:B
CCR 5 SXHI
NZVC
38 1503
3C00
1000
0000
00:F0
1001
0000
xx: 1503
180300001014
MOVW #$0000,$1014
PP PC
SP
X
Y
D 5 A:B
CCR 5 SXHI
NZVC
38 1509
3C00
1000
0000
00:F0
1001
0000
xx: 1509
DD14
LDY
$0014
PP PC
SP
X
Y
D 5 A:B
CCR 5 SXHI
NZVC
38 150B
3C00
1000
000F
00:F0
1001
0000
xx: 150B
E630
LDAB
1,X 1
.
The third instruction intends to load the array count N into index register Y. Y should
receive the value of N , which is 20. The instruction trace shows that Y receives 15 ($F) instead
of 20. Again, this is due to the incorrect addressing mode. Change the instruction to ldy #N,
assemble, download, rerun the program, and display the contents of sum .
+ g 1500
User Bkpt Encountered
PP PC
SP
X
Y
D 5 A:B
CCR 5 SXHI
NZVC
38 151A
3C00
1014
0000
01:A4
1001
0000
xx: 151A
F421BD
ANDB
$21BD
+ md 1010
1010 22 24 26 28 - 01 A4 B9 A9 - 2A CA FA DB - AC DA 18 97 “$&(. . . .*. . . . . . .
.
This time the value of sum is $1A4 (420) and is correct.
M ISMATCH OF O PERAND S IZE
This is another common mistake made by beginners. For example, some people might
write the previous program as follows:
N
equ
20
; array count
org
$1000
array
dc.b
2,4,6,8,10,12,14,16,18,20
dc.b
22,24,26,28,30,32,34,36,38,40
 
Search WWH ::




Custom Search