**********
* Program BASE_2 (6811)
*
* Switches converted from natural binary to BCD and saved
* in DECIMAL.  No output on LEDs.  Illustrates use of DAA.
*
* 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

	CLR DECIMAL	* zero the decimal counter
	CLR DECIMAL+1

	LDAA PORTC,Y	* get natural binary quantity
	BEQ DONE	* if zero
	STAA BINARY

AGN
	LDAA DECIMAL+1	* add one in dec manner to low byte
	ADDA #$01
	DAA
	STAA DECIMAL+1
		
	LDAA DECIMAL	* pick up any carry
	ADCA #$00
	DAA
	STAA DECIMAL

	DEC BINARY	* dec binary counter
	BNE AGN		* repeat until counter at zero

DONE
	SWI	

	ORG DSCT

BINARY  RMB 1
DECIMAL	RMB 2

