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,
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.9.1/html_node/as_84.html#SEC86 http://developer.apple.com/documentation/DeveloperTools/gcc-4.0.1/cpp/Macros.html#Macros Martin Thomas
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
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.1/html_chapter/ld_3.html
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,
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,
> 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.
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
Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
Log in with Google account
No account? Register here.