;-------------------------------------------------------------------------------
; MSP430 Assembler Code Template for use with TI Code Composer Studio
;
;
;-------------------------------------------------------------------------------
            .cdecls C,LIST,"msp430.h"       ; Include device header file


;-------------------------------------------------------------------------------
			.ref	WriteLed				; reference the extern function
			.ref	data					; reference the global variable

;-------------------------------------------------------------------------------
			.text
UARTISR		add.w	&UCA1IV, PC				; set PC to go to wanted label
			reti							; vector 0 - no interrupt
			jmp 	rxisr					; vector 2 - RXIFG
txisr		reti							; vector 4 - TXIFG
rxisr		push.w	R8						; save R8 value on stack
			push.w	R12						; save R12 value on stack
			mov.w	&UCA1RXBUF, R8			; read data into R8
			sub.w	#48, R8					; ASCII to digit value '0' = 48
			mov.b	R8, &data				; save digit value for later use
			mov.w	R8, R12					; move digit value to R12, argument register
			call	#WriteLed				; call function WriteLed with argument in R12
			pop.w	R12						; return R12 original value
			pop.w	R8						; return R8 original value
			reti							; back to the main loop

;-------------------------------------------------------------------------------
; Interrupt Vectors
;-------------------------------------------------------------------------------
            .sect   ".int46"                ; MSP430 USCIA1 Vector
            .short  UARTISR

