EmbDev.net

Forum: ARM programming with GCC/GNU tools newbies questions about ARM ASM


Author: iostrym (Guest)
Posted on:

Rate this post
0 useful
not useful
Hi everyone, I would like to know the difference between

#define STACK_ADR 0x1000

and

.equ  EBI_BASE,0xFFE00000

I know the fisrt one is used in C and the second is ASM but the two one
are in a same file because GCC can compile ASM and C. So I would like to
know if these two instructions are identical.

Thanks and Regards,

Author: Martin Thomas (Guest)
Posted on:

Rate this post
0 useful
not useful
iostrym wrote:
> Hi everyone, I would like to know the difference between
>
> #define STACK_ADR 0x1000
>
> and
>
> .equ  EBI_BASE,0xFFE00000
>
> I know the fisrt one is used in C and the second is ASM but the two one
> are in a same file because GCC can compile ASM and C. So I would like to
> know if these two instructions are identical.

They are not identical. But both methods can be used for certain task
like defining a constant value for say LDR reg, #const. Be aware that
the internal processing is very different.

.equ sets the value of an assembler symbol

#define creates a C-preprocessor macro. The C-preprocessor is used if
the assembler file has the .S (captial S) extension.

Read the fine manuals:
http://www.gnu.org/software/binutils/manual/gas-2....
http://developer.apple.com/documentation/Developer...

Martin Thomas

Author: Armand Iostrym (iostrym)
Posted on:

Rate this post
0 useful
not useful
Thanks very much it's very helpful and it confirms what I thought.

I have others basics questions if someone have time to answer it should
be very quick.

I would like to check if assembler control directive (.data, .text,
.bss, .end, .global, etc.) are GCC specific or not?

Also, I know that .data and .text are used to specify in wich section
the following statement will be but where exactly is specified the
adresses of the data section and the text section? is it in a .S file or
is it specified to GCC with another file with the needed parameters ?

Thanks for your help,

iostrym

Author: Stefan Brueck (Guest)
Posted on:

Rate this post
0 useful
not useful
armand iostrym wrote:
> Also, I know that .data and .text are used to specify in wich section
> the following statement will be but where exactly is specified the
> adresses of the data section and the text section? is it in a .S file or
> is it specified to GCC with another file with the needed parameters ?

This is the task of the linker command script. Examine some example
projects. You will see a reference to <linker command script>.ld in the
makefile and in the project directories.

Overview:
http://www.embedded.com/2000/0002/0002feat2.htm

Reference:
http://www.gnu.org/software/binutils/manual/ld-2.9...

Author: Armand Iostrym (iostrym)
Posted on:

Rate this post
0 useful
not useful
thanks for your help,

however there is still something I don't understand. What is the
difference between using the directive

.section .bss

and unsing the directive .bss

it's seems to be the same, isn't it ?

Best regards,

Author: Armand Iostrym (iostrym)
Posted on:

Rate this post
0 useful
not useful
Hi,

I would like to know if there is a difference between

        ldr  r12, PtInitRemap  /* get the real jump address (after 
remap)
*/
  mov  pc, r12      /* jump and break the pipeline */

InitRemap:
  bl  init_sections    /* copy fastram+data sections */
  b   start

PtInitRemap:
  .long  InitRemap         /* address where to jump after REMAP */

and

        ldr  r12, InitRemap
        mov  pc, r12

InitRemap:
  bl  init_sections    /* copy fastram+data sections */
  b   start

Best regards,

Author: Martin Thomas (Guest)
Posted on:

Rate this post
0 useful
not useful
> I would like to know if there is a difference between
>
>         ldr  r12, PtInitRemap  /* get the real jump address (after remap)
> */
>   mov  pc, r12      /* jump and break the pipeline */
>
> InitRemap:
>   bl  init_sections    /* copy fastram+data sections */
>   b   start
>
> PtInitRemap:
>   .long  InitRemap         /* address where to jump after REMAP */
>
> and
> [...]

Yes, there is a difference. And the reason for the first approach is
described well in the comments which are already there.

Author: Stefan (Guest)
Posted on:

Rate this post
0 useful
not useful
REMAP is hard to understand for a newbie like me too.

We have to learn that our code is running from 0x0 but in ROM first,
then we do a REMAP and some of our code should run e.g. from 0x01000000
in ROM and some essential code (exception handlers like reset...) is
running from 0x0 in RAM until power off...

OK. First time when ROM-code runs, the code has to do init_sections to
get data... from ROM into RAM.

But when the same code (which is part of the reset code) is used after
REMAP, the init_sections should not be called!

How can you do this? We have to change the code flow. Therefore when
this code is called in RAM (e.g. when a RESET occurs) PtInitRemap has
another content than the first time. Who changes the content? E.g.
init_sections can change the content.

The essential of the indirect access to the jump address in the first
case is, that you are able to modify the jump address easily because it
is data value (access with a pointer). Otherwise you would have to
produce self-modifying code by patching adguments of code instructions.

Stefan

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.