;****** Example of relocatable assembly and linking several .ASM files
;****** LED on PT1 should flash on and off at a 1/2 second rate
;****** See Lecture 6 Notes for explanation.
;
; export symbols  (to be referenced outside of this file)
            XDEF Entry
            XDEF Timer_word
            
; import symbols (defined outside of this file)
            XREF __SEG_END_SSTACK
            XREF WAITMS
            XREF INIT_PLL
            INCLUDE 'mc9s12c128.inc'
MY_EXTENDED_RAM: SECTION
Timer_word  ds.w 1

MyCode:     SECTION
Entry:
            LDS  #__SEG_END_SSTACK      ; Initialize the stack pointer
            BSET DDRT,$02               ; Make PT1 AN OUTPUT (LED on PT1)
            JSR INIT_PLL                ; Routine INIT_PLL is in another file
            MOVW #1000,Timer_word
FLASHAGN:   BSET PTT,$02                ; TURN ON LED
            
            JSR WAITMS                  ; Routine WTMS is in another file
                                        ; Waits number of ms in location
            BCLR PTT,$02                ; Timer_word 
            JSR WAITMS
            BRA FLASHAGN                ; TURN OFF LED
            END