Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;-------------------------------------------------------------------------------
- ; 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.
- ;array .word 2,3,4,5,6,4,4,5
- array .word 5,5,5,6,9,4,7,3
- size .word 9 ;; maybe this has to be 8?
- ;-------------------------------------------------------------------------------
- RESET mov.w #__STACK_END,SP ; Initialize stackpointer
- StopWDT mov.w #WDTPW|WDTHOLD,&WDTCTL ; Stop watchdog timer
- ;-------------------------------------------------------------------------------
- ; Main loop here
- ;-------------------------------------------------------------------------------
- mov #array, r4
- mov size, r5
- mov #0, r6 ;; this is the sum result
- mov #0, r7 ;; this is the index
- mov #0, r8 ;; this is the result of the division
- sumLoop:
- dec r5
- jz division
- add array(r7), r6
- incd r7
- jmp sumLoop
- division:
- sub #8, r6
- jl done
- inc r8
- jmp division
- done:
- jmp $
- nop
- ;-------------------------------------------------------------------------------
- ; Stack Pointer definition
- ;-------------------------------------------------------------------------------
- .global __STACK_END
- .sect .stack
- ;-------------------------------------------------------------------------------
- ; Interrupt Vectors
- ;-------------------------------------------------------------------------------
- .sect ".reset" ; MSP430 RESET Vector
- .short RESET
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement