**********
* Program BASE_3 (6811)
*
* Switches converted from BCD to natural binary and result displayed
* on LEDs.
*
* This is an alternative to the method illustrated in BASE_1
*
* Note that the DAA does not work for subtraction. A technique known as
* tens compliment addition is used.
*
* P. H. Anderson, MSU, 7 Oct 91; Jan 15, '93
**********
PSCT EQU $C000
DSCT EQU $D000
STACKTP EQU $0045
REG_BASE EQU $1000
PORTB EQU $04
PORTC EQU $03
DDRC EQU $07
ORG PSCT
LDS #STACKTP
LDY #REG_BASE
CLR DDRC,Y * port c configured as 8-bit input
TOP
CLR BINARY * zero the binary
LDAA PORTC,Y * get natural decimal quantity
BEQ DONE * if zero
STAA DECIMAL
AGN
INC BINARY
LDAA DECIMAL * subtract 1 in decimal manner
ADDA #$99
DAA
STAA DECIMAL
BNE AGN * until zero
DONE
LDAA BINARY
STAA PORTB,Y
BRA TOP
ORG DSCT
BINARY RMB 1
DECIMAL RMB 1