This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

[CM3]assembly language trouble

CORE: STM32F103ZET6

Hi,Pros.

     Here Monkey comes agian

I have met a problem with my code,see below:

/* --------- code here --------- */
     .section .data
_sp_usart:
     .word     _stack_usart
_stack_usart:
     .space     0x100,     0
...     // other code here
/* --------- code end here --------- */
and I wrote a ldscript looks like this:
/* --------- code here --------- */
SECTIONS
{
     ...     // other code here
     . =0x20000000;
     .data : {*(.data)}
}
/* --------- code end here --------- */


But what I read from ADDRESS 0x20000000 is a strange number,something like 0x2Exxxxxx,out of the RAM region.

I have no idea for this,how this happens?Can someone please help me?

Message was edited by: stupidMokey

Parents
  • The problem can be in your assembly file, it can be in your linker script.

    To find out whether it's one or the other, try first looking at the disassembly of the file...

    $ arm-none-eabi-objdump - Mreg-names-std -D -z yourfile.elf

    The linker map (.map file) might also give you a few hints.

    The linker map tells you where the linker expects to put things. If it says it will put the data at location 0x2exxxxxx, then the problem is with the linker script.

    In your assembly file, I suggest that you start with the following line:

                   .syntax     unified

    and  then on your command-line, add the following switch:

         -mimplicit-it=always

    (or -Wa,-mimplicit-it=always if you use the C Pre-processor).

    ... And just for finding out if your .data section is going where you expect it to go, try adding...

         .word 0xdeadbeef

    ...right after your .word _stack_usart; eg. before your .space 0x100, 0

    -Then try reading the contents of address 0x20000004

Reply
  • The problem can be in your assembly file, it can be in your linker script.

    To find out whether it's one or the other, try first looking at the disassembly of the file...

    $ arm-none-eabi-objdump - Mreg-names-std -D -z yourfile.elf

    The linker map (.map file) might also give you a few hints.

    The linker map tells you where the linker expects to put things. If it says it will put the data at location 0x2exxxxxx, then the problem is with the linker script.

    In your assembly file, I suggest that you start with the following line:

                   .syntax     unified

    and  then on your command-line, add the following switch:

         -mimplicit-it=always

    (or -Wa,-mimplicit-it=always if you use the C Pre-processor).

    ... And just for finding out if your .data section is going where you expect it to go, try adding...

         .word 0xdeadbeef

    ...right after your .word _stack_usart; eg. before your .space 0x100, 0

    -Then try reading the contents of address 0x20000004

Children