Download Example Programs for 6502 Microprocessor Kit

Transcript
Program6: Reading switch status
The kit has one bit that ties REP switch (S19). We can read the
status of this switch easily by reading it then write it to GPIO1
LED. Logic '1' means switch is opened, and logic '0' means switch
is closed. U13 is tri-state buffer used as the 8-bit input port.
Program is repeating loop read the byte from PORT0. REP key is
tied to bit 6 (PA6). We want to check status only this bit, so we
remove the rest bits with instruction AND #%01000000. Also we
invert it with EOR (Exclusive OR) EOR #%01000000.
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0000
0000
0000
0000
0200
0200
0200
0203
0205
0207
020A
020D
GPIO1
PORT0
.EQU 8000H
.EQU 8001H
.ORG 200H
AD
29
49
8D
4C
01 80
40
40
00 80
00 02
LOOP
LDA
AND
EOR
STA
JMP
$PORT0
#%01000000
#%01000000
$GPIO1
LOOP
15