This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Why use pointer?



On 03-Apr-2001 John wrote:
> Hi all,
> 
> I'm new to ecos.
> I see the following code in vectors.S of arm platform.
> It uses PTR(init_flag) to make a pointer.
> And then uses
>       ldr     r0,.init_flag
>       ldr     r1,[r0]
> to load data at address init_flag.
> Why not use
>       ldr     r1,init_flag
> like init_done below?
> Is the pointer for some special purpose or some reason?
> Thanks in advance.
> 
> 
>       .globl  start
> start:        
> 
>       LED 5
> 
>#if defined(CYG_HAL_STARTUP_RAM) && \
>     !defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS)
> // If we get restarted, hang here to avoid corrupting memory
>       ldr     r0,.init_flag
>       ldr     r1,[r0]
> 1:    cmp     r1,#0
>       bne     1b
>       ldr     r1,init_done
>       str     r1,[r0]

This is necessary because the 'init_flag' variable is in a different
section (data, not text) which is most likely too far away to be addressed
directly.  The variable 'init_done' is in the same segment and close
by, thus no indirect addressing is required.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]