******************************************************************
; Set up the Pincode buffer to store the code the user enteres from keypad
ORG 0 ; Store Pincode in RAM
Pincode RMB 4 ; Pincode 4 byte buffer
******************************************************************
* <<< MAIN PROGRAM LOOP >>>
******************************************************************
ORG PROG
START
; Load the Pincode array with the value 1234, with each digit being in it's own byte of the array
ldaa #1
staa Pincode
ldaa #2
staa Pincode+1
ldaa #3
staa Pincode+2
ldaa #4
staa Pincode+3
*******************************************************************
*CONVERT BCD TO A the 16bit binary decimal NUMBER
*******************************************************************
BCDBIN
clra
clrb ; clears D
std BINVAL ; Clear BINVAL
thousands
tst Pincode
beq hundrends
addd #1000
dec Pincode
bne thousands
hundrends
tst Pincode+1
beq tens
addd #100
dec Pincode+1
bne hundrends
tens
tst Pincode+2
beq processpin
addd #10
dec Pincode+2
bne tens
processpin
; take care of units
addd Pincode+3
std BINVAL ; BINVAL now equal to 16bit binary equiv
ldx BINVAL
cpx SECRET
beq SUCCESS
swi ;end program
SUCCESS
ldx #msg11 ;point X to message ; Display you got the Pin correct!!!
jsr OUTSTRG ;output it