401
27.9 | SOLVED EXAMPLES
ORG 0000
; initialize 8255
START: MOV DPTR, #0003H ; load DPTR by addr of CWR of 8255
MOV A, #89H ; port A and B output, port C input, all mode 0
MOVX @DPTR, A ; send comman word in CWR of 8255
; turn off all LEDs
MOV A, #0FFH
MOV DPTR, #0000H ; address of port A of 8255
MOVX @DPTR, A ; turn off red LEDS
INC DPTR ; address of port B of 8255
MOVX @DPTR, A ; turn off green LEDs
; look for key pressing
ANYKEY: MOV DPTR, #0002H ; address of port C of 8255
KLOOP: MOVX A, @DPTR ; read port C
CPL A ; complement reading
JZ KLOOP ; no key pressed. Keep looking for it.
; some key pressed
CPL A ; get original key status
MOV DPTR, #0001H ...