Code: Select all
ZPFPLED EQU $00 ;Zero page location holds status of fp leds
FPLED EQU $A002
FBSWTCH EQU FPLED
org $E000 ;Begining of ROM
;
;
;
SWCHTBL dw 0xE0D0 ;Look up table for fp switches
dw 0xB070 ;End lookup table
SWCHLUP dw 0x0804 ;Look up table for mask
dw 0x0201 ;End lookup table
SWCHCOM dw 0xF7FB ;Compliment of SWCHLUP table
dw 0xFDFE ;End lookup table
dw 0x0000
dw 0x0000
Reset01 ;Initialise machine
;
CLC ;Clear carry flag
CLD
SEI ;disable interupts
;
LDX #$FF
TXS ;Initialise Stack pointer
;
LDX #$0F
;
STX ZPFPLED ;Initialise zero page location holds status of leds
;
;
TXA
STA FPLED ;Make sure all leds are off
;
;
CLI
;
;
CLC
Labelend: LDA FBSWTCH ;read switch on front pannel
AND #$F0 ;Clear lower four bits
CMP #$F0 ;Key pressed at all?
BEQ NEXT001 ;If no key pressed exit
LDX #$03
NEXT002: CMP SWCHTBL,X ;Which Key was pressed
BEQ NEXT004
DEX
BNE NEXT002 ;Loop until we find match
NEXT004: TXA ;X holds index to key pressed
;
;
; Lamp control routine.
; that toggles individual Led's on or off.
;
TAX ;
LDA SWCHLUP,X ; Get mask for from table according to index
;
BIT ZPFPLED ;Test bits
;
BNE NEXT005
;Bit result is zero. Led is on need to switch off
LDA ZPFPLED
ORA SWCHLUP,X
STA ZPFPLED
BRA NEXT003
NEXT005: ; Bit is set. Led is off need to switch it on.
LDA ZPFPLED
AND SWCHCOM,X
STA ZPFPLED
;
;
NEXT003: LDA ZPFPLED
STA FPLED ;Output to panel leds
NEXT001: NOP
;
;
JMP Labelend