Untitled

Anonymous
assembly_x86
02/18/2026 10:47 PM
14.5 KB
15
Indexable
;-------------------------------------------------------------------------------
; MSP430 Assembler Code Template for use with TI Code Composer Studio
;
;
;-------------------------------------------------------------------------------
            .cdecls C,LIST,"msp430.h"       ; Include device header file
                        
                        ;-------------------------------------------------------------------------------
                                    .def    RESET                   ; Export program entry-point to
                                                                                ; make it known to linker.
                                                                                ;-------------------------------------------------------------------------------
                                                                                            .text                           ; Assemble into program memory.
                                                                                                        .retain                         ; Override ELF conditional linking
                                                                                                                                                    ; and retain current section.
                                                                                                                                                                .retainrefs                     ; And retain any sections that have
                                                                                                                                                                                                            ; references to current section.

                                                                                                                                                                                                            ;-------------------------------------------------------------------------------
                                                                                                                                                                                                            RESET       mov.w   #__STACK_END,SP         ; Initialize stackpointer
                                                                                                                                                                                                            StopWDT     mov.w   #WDTPW|WDTHOLD,&WDTCTL  ; Stop watchdog timer


                                                                                                                                                                                                            ;-------------------------------------------------------------------------------
                                                                                                                                                                                                            ; Main loop here
                                                                                                                                                                                                            ;-------------------------------------------------------------------------------

                                                                                                                                                                                                            init:
                                                                                                                                                                                                            			bis.b	#01h, &P1DIR			;Set P1.0 (LED) as output
                                                                                                                                                                                                                        main:
                                                                                                                                                                                                                        			xor.b	#01h, &P1OUT			;Toggle LED

                                                                                                                                                                                                                                    			mov.w	#0FFFFh, R4				;load R4 with 0x0ffff
                                                                                                                                                                                                                                                delay:
                                                                                                                                                                                                                                                			dec.w	R4						;decrement R4
                                                                                                                                                                                                                                                            			jnz		delay					;Repeat until R4=0

                                                                                                                                                                                                                                                                        			jmp		main					;Stay in main-loop

                                                                                                                                                                                                                                                                                                                                

                                                                                                                                                                                                                                                                                                                                ;-------------------------------------------------------------------------------
                                                                                                                                                                                                                                                                                                                                ; Stack Pointer definition
                                                                                                                                                                                                                                                                                                                                ;-------------------------------------------------------------------------------
                                                                                                                                                                                                                                                                                                                                            .global __STACK_END
                                                                                                                                                                                                                                                                                                                                                        .sect   .stack
                                                                                                                                                                                                                                                                                                                                                                    
                                                                                                                                                                                                                                                                                                                                                                    ;-------------------------------------------------------------------------------
                                                                                                                                                                                                                                                                                                                                                                    ; Interrupt Vectors
                                                                                                                                                                                                                                                                                                                                                                    ;-------------------------------------------------------------------------------
                                                                                                                                                                                                                                                                                                                                                                                .sect   ".reset"                ; MSP430 RESET Vector
                                                                                                                                                                                                                                                                                                                                                                                            .short  RESET
                                                                                                                                                                                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                                                                                                                                                        
Editor is loading...
Leave a Comment