;***************************************************************** ;* This stationery serves as the framework for a * ;* user application (single file, absolute assembly application) * ;* For a more comprehensive program that * ;* demonstrates the more advanced functionality of this * ;* processor, please see the demonstration applications * ;* located in the examples subdirectory of the * ;* Metrowerks CodeWarrior for the HC12 Program directory * ;***************************************************************** ; export symbols XDEF Entry ; export 'Entry' symbol ABSENTRY Entry ; for absolute assembly: mark this as application entry point ;*** Example program that adds 10 bytes in the constant array "DatList" ;This program looks up code in switches on Port T, and puts ;decoded value in DecodedValue Result location. $00 put in result location if code not in table. ;Examples: Port T SW = $9A => DecodedValue = $0B ; Port T SW = $55 => DecodedValue = $00 DDRT EQU $242 PTT EQU $240 ORG $3800 DecodedValue: DS.B 1 ;Decoded Value put here, $00 if no code found ORG $4000 CodeTable: DC.B $12,$34,$56,$78,$9A,$BC,$DE CodeValue: DC.B $03,$05,$07,$09,$0B,$10,$13 Entry: LDX #CodeTable LDY #CodeValue CLR DDRT ;8 switches on Port T LDAA PTT ;Load in code word from switches LDAB #7 ;Seven elements in table CheckNxtEntry: DECB BEQ NoMatchFound CMPA B,X BEQ MatchFound BRA CheckNxtEntry MatchFound: LDAA B,Y STAA DecodedValue ;Put decoded value in result location (DecodedVaue) BRA Done NoMatchFound: CLR DecodedValue ;Put $00 in result location (DecodedValue) Done: BRA Done ;************************************************************** ORG $FFFE fdb Entry ; Reset