public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] Why use pointer?
@ 2001-04-03  3:01 John
  2001-04-03  4:15 ` Gary Thomas
  0 siblings, 1 reply; 2+ messages in thread
From: John @ 2001-04-03  3:01 UTC (permalink / raw)
  To: ecos-discuss

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 865 bytes --]

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]

----
Á»¨­õ
John Hsieh
µo²{ªÌ°ê»ÚªÑ¥÷¦³­­¤½¥q
iMining Technology Co., Ltd.
john@imining.com.tw
TEL: 886-2-27235122
FAX: 886-2-27232287
www.imining.com.tw

^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: [ECOS] Why use pointer?
  2001-04-03  3:01 [ECOS] Why use pointer? John
@ 2001-04-03  4:15 ` Gary Thomas
  0 siblings, 0 replies; 2+ messages in thread
From: Gary Thomas @ 2001-04-03  4:15 UTC (permalink / raw)
  To: John; +Cc: ecos-discuss

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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-04-03  4:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-03  3:01 [ECOS] Why use pointer? John
2001-04-03  4:15 ` Gary Thomas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).