This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430G2553: Exchange a block of data using assembly language in msp430g2553

Part Number: MSP430G2553

Hello everyone,

I am trying a program to exchange a block of data  with another block.I compiled the program successfully but I can't see the o/p.The code is written below.

Please tell me if any change is required or not and how to check the output :-

-------------------------------------------------------------------------------
.cdecls C,LIST,"msp430.h" ; Include device header file

;-------------------------------------------------------------------------------
.text ; Assemble into program memory
.global RESET
.retain ; Override ELF conditional linking
; and retain current section
.retainrefs ; Additionally 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

mystr1; DB "Hello World\n"
mystr2; DB "Hiiiii\n"
;-------------------------------------------------------------------------------
; Main loop here
;-------------------------------------------------------------------------------
mov.w #mystr1, r9
mov.w #mystr2, r10

;

loop

mov.w r9, r11

mov.w r10,r9

mov.w r11,r10

;-------------------------------------------------------------------------------
; Stack Pointer definition
;-------------------------------------------------------------------------------
.global __STACK_END
.sect .stack

;-------------------------------------------------------------------------------
; Interrupt Vectors
;-------------------------------------------------------------------------------
.sect ".reset" ; MSP430 RESET Vector
.short RESET
.end

  • The strings you are attempting to declare are much longer than a word (two bytes) apiece in length, it will take more processing to switch the blocks of code accordingly since general-purpose registers are only the size of a word. Why are you using ASM instead of C, which would make this process much easier? You should use your IDE's debugging tools to validate whether your code performs the operation as you expect.

    Regards,
    Ryan
  • Hi Abishek,
    In your IDE, can you look at the memory view of the device after this code executes?
  • 1)But sir the first string which is "hello world\n" is 13 bits and the second string "hiiiii\n" is 8 bits both are less than 1 word or 16  bits.

    Is there any problem sir?

    2)Secondly the code compiled correctly without any error but in the Debug Window there are no changes in the Core Register values i.e r9, r10, r11 register values. I cannot see the strings which I have entered.

    How can I see the strings sir?

    3)Sir ,Is it possible that  I can see my o/p my in the Console Window? and also can I enter my  values in the Console Window?

  • 1)No sir I can't see anything.In the Debug Window when I opened the Core Registers r9,r10,r11 there were no changes occured when I ran the code.
    How to see the entered strings and the exchanged value sir?
    2)If I want to enter my values can I use the Console Window, if yes then how to use that means what code should I write in the Program?
  • Hi Abishek,

    your string is 13 bytes long and not 13 bits. With your declaration you should find the sting in the flash memory, not in the RAM. It is not possible to exchange the data of the FLASH in such a way.

    Best regards,

    Peter Weber

  • 1) Ok sir I reduced the size of the string now my string size is 2 bytes only.Even though I cannot get the o/p ?
    2) You told me that it is not possible to exchange the data of the Flash Memory in such away, so what is the correct way to exchange bulk data in flash or ram memory?
  • Hi Abhishek,
    Is there a reason that you are using assembly as opposed to C?

    What IDE are you using? If you are using CCS, you can view the memory contents opening the View menu, and clicking Memory Browser. This would be the easiest way to verify your program's function as opposed to printing to console from assembly.
  • Ok sir I don't need Console window now,I can see my o/p in memory window.But sir there are some instructions such as mov.w #0x0200h, 0x0202h or  mov.w #0x0200h,r5 or mov.w r5,0x0200h or mov.w @r5,0x0200h are not supported. If this instructions are not supported then sir how can I load the values into the memory?

    Can you tell me any memory related instruction where I can change the values of that memory location in SRAM? 

    Suppose if the values present in memory location 0x0200h is 00 then how can I change it to 10 or anything.And also if I want to write in memory locations after 0x0200h  such as 0x02001,0x0202h,0x0203h, then what will be the instructions?

**Attention** This is a public forum