**********
* Program BASE_1 (6811)
*
* Toggle switches - hi and low nibbles are X^1 and X^0 where
* X is any base in range 2 - 16.
* For example 44 (base 5) = 24 dec = $18
*
* No error checking. For example an entry of 50 in base 5 is
* not valid but it will not be caught by this routine.
*
* Switches converted to natural binary and displayed on discrete LEDs
*
* P. H. Anderson, MSU, 26 Sept 91; Jan 14, '93
**********
PSCT EQU $C000
DSCT EQU $D000
IDSCT EQU $D300
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
LDAA PORTC,Y * get switches
STAA TEMP * retain copy
ANDA #$0F * isolate low nibble
STAA RESULT
LDAA TEMP * get the switches again
LSRA
LSRA
LSRA
LSRA * hi nibble to lo nibble
LDAB BASE * multiply hi nibble by base
MUL
ADDB RESULT
STAB RESULT * hi * base + lo
STAB PORTB,Y * output
BRA TOP * repeat
ORG IDSCT
BASE FCB 10 * this may be 2 thru 16 decimal
ORG DSCT
TEMP RMB 1
RESULT RMB 1