hi, following is the code for the stop watch design, plz message me if the code can be optimized: the file is attached
***************************************************************
**THIS STOPWATCH WILL BE ABLE TO COUNT FROM TENTH SECOND TO 99
**SECONDS USING THE I/O PORTS OF 68HC11 MICROCONTROLLER. THE
**TENTH AND SECOND DIGITS WILL DISPLAY ON THE PORTB REGISTER.
**THE TEN SECOND DIGIT WILL DISPLAY ON THE PORTP'S BIT 0 TO
**BIT 3. BIT 4 TO BIT 7 OF PORT C REGISTER WILL BE USE AS
**INPUT BITS.
**************************************************************
*SYMBOL DEFINITION
***************************************************************
*68HC12 REGISTERS
PORTT EQU $240 OUTPUT PORT T REGISTER
DDRT EQU $242 DATA DIRECTION REGISTER T
PORTP EQU $258 I/O PORT P REGISTER
DDRP EQU $25A DATA DIRECTION REGISTER P
*MASK
BIT7 EQU %10000000 “START” BOTTON
BIT6 EQU %01000000 “PAUSE” BOTTON
BIT5 EQU %00100000 “RESET” BOTTON
*****************************************************************
**DATA SECTION
*****************************************************************
ORG $2000
NTYS EQU $2001 TEN SECONDS DIGIT LIMIT
TSS EQU $2002 TENTH AND SECOND LIMIT
TSCNT EQU $2003 TENTH SECOND COUNTER
TENSC EQU $2004 TEN SECONDS COUNTER
*****************************************************************
**MAIN PROGRAM
*****************************************************************
ORG $2200
*----------------------------------------------------------------
*SET UP THE LIMIT FOR TEN SECOND DIGIT
LDAA #$09
STAA NTYS
*SET UP THE LIMIT FOR TENTH AND SECOND DIGITS
LDAA #$63
STAA TSS
*INITIALIZE PORT P & PORT T
* SET BITS 0-3 AS OUTPUTS & 4-7 AS INPUTS
LDAA #$0F
STAA DDRP
* SET PORT T AS OUTPUT PORT T
LDAA #$FF
STAA DDRT
* INITIALIZE OUTPUTS TO ZEROS
RESET CLR PORTP
*INITIALIZE PORT T TO ZEROS
CLR PORTT
*RESETTING COUNTERS
CLR TSCNT
CLR TENSC
*-------------------------------------------------------------------
*IS “START”/”RESET” BOTTON PUSHED?
BPTST BRSET $258,BIT5 RESET IS “RESET” BOTTON PUSHED?
BRSET $258,BIT7 DELAY “START” COUNTING IF “START” BOTTON IS PUSHED
BRA BPTST RECHECK THE PUSH BOTTONS
*-------------------------------------------------------------------
*IS “PAUSE” BOTTON PUSHED?
PAUSE BRSET $258,BIT6 BPTST
BRA DELAY
*--------------------------------------------------------------------
*CHECKING IF IT HAS REACHED 9.9 SECONDS
CHECK LDAA TSCNT
CMPA TSS
BEQ INTENS
*INCREMENTING TENTH SECOND DIGIT
INC TSCNT
LDAA TSCNT
DAA
STAA PORTT
BRA PAUSE
*-------------------------------------------------------------------
*INCREMENTING TEN SECONDS DIGIT
INTENS CLR TSCNT “RESET” TENTH SECOND COUNTER
CLR PORTT “RESET” PORT T DISPLAY TO 00
*CHECKING IF TEN SECONDS COUNTER HAS REACHED 90 SECONDS
LDAA TENSC
CMPA NTYS
BEQ RTENSC
INC TENSC INCREMENTING TEN SECOND COUNTER
LDAA TENSC
STAA PORTP
BRA PAUSE
*RESETTING TEN SECONDS COUNTER WHEN IT REACHED 90 SECONDS
RTENSC CLR TENSC
CLR PORTP SET OUTPUTS OF PORTP TO ZEROS
BRA PAUSE SET OUTPUTS OF PORTP TO ZEROS
*-------------------------------------------------------------------
**0.1 SECOND DELAY
*-------------------------------------------------------------------
DELAY LDY #$FFFF
NOP
WAIT DEY
BNE WAIT
LDY #$7FFF
NOP
WAIT1 DEY
BNE WAIT1
BRA CHECK