Quiz 6.1

From Class Wiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
r4 = 0x8100, r5 unchanged
r4 = 0x8101, r5 = 0x0001
r4 = 0x0003, r5 = 0x0001
r4 = 0x0003, r5 = 0x0004
r4 = 0x0003, r5 = 0x8101
r4 = 0x0006, r5 = 0x8101
r4 = 0x0006, r5 = 0x8103
r4 = 0x0006, r5 = 0x0004

You can play with this program below, and see it yourself. Just remember that #tab1 is 0x4400 on the MSP430F5529.

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

	 	.byte 1,2
      		.byte 3,4
      		.byte 5,6
      		.byte 7,8
tab2: 		.word tab1+0
      		.word tab1+1
      		.word tab1+2
      		.word tab1+3
      		.word tab1+4
      		.word tab1+5
      		.word tab1+6
      		.word tab1+7
            
;-------------------------------------------------------------------------------
            .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
;-------------------------------------------------------------------------------
			mov.w #tab1,r4
			mov.b @r4+,r5
			mov.w #3,r4
			mov.b tab1(r4),r5
			mov.w tab2(r4),r5
			add.w r4,r4
			mov.w tab2(r4),r5
			mov.b @r5,r5
			jmp $

                                            

;-------------------------------------------------------------------------------
; Stack Pointer definition
;-------------------------------------------------------------------------------
            .global __STACK_END
            .sect   .stack
            
;-------------------------------------------------------------------------------
; Interrupt Vectors
;-------------------------------------------------------------------------------
            .sect   ".reset"                ; MSP430 RESET Vector
            .short  RESET