public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: I really need help!
@ 2001-10-17 19:37 mike stump
  2001-10-18  9:26 ` Davide Libenzi
  2001-10-22  6:46 ` Joern Rennecke
  0 siblings, 2 replies; 7+ messages in thread
From: mike stump @ 2001-10-17 19:37 UTC (permalink / raw)
  To: gavinux, gcc

> Date: Wed, 17 Oct 2001 17:47:49 -0700 (PDT)
> From: Gavin Li <gavinux@yahoo.com>
> To: gcc@gcc.gnu.org

> I am not sure if I should send this mail to here.

Kinda _not_ what this list is for.

> void start(void)
> {
> 	asm ("movl %esp, 0x5000");
> }

> My question is how can I get ride of the first two ASM
> instructions?

Go cheat off of newlib, or libc, or glibc, or netbsd, or freebsd...

> I want the compiler to compile my inlined ASM instruction as the
> first instruction in the start() function, and the other function
> just as general output.

Trivial:

void mystart() {
  asm("start:");
  asm("movl %esp, 0x5000");
}

or learn to code in assembler.

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

* Re: I really need help!
  2001-10-17 19:37 I really need help! mike stump
@ 2001-10-18  9:26 ` Davide Libenzi
  2001-10-22  6:46 ` Joern Rennecke
  1 sibling, 0 replies; 7+ messages in thread
From: Davide Libenzi @ 2001-10-18  9:26 UTC (permalink / raw)
  To: mike stump; +Cc: gavinux, gcc

On Wed, 17 Oct 2001, mike stump wrote:

> > Date: Wed, 17 Oct 2001 17:47:49 -0700 (PDT)
> > From: Gavin Li <gavinux@yahoo.com>
> > To: gcc@gcc.gnu.org
>
> > I am not sure if I should send this mail to here.
>
> Kinda _not_ what this list is for.
>
> > void start(void)
> > {
> > 	asm ("movl %esp, 0x5000");
> > }
>
> > My question is how can I get ride of the first two ASM
> > instructions?
>
> Go cheat off of newlib, or libc, or glibc, or netbsd, or freebsd...
>
> > I want the compiler to compile my inlined ASM instruction as the
> > first instruction in the start() function, and the other function
> > just as general output.
>
> Trivial:
>
> void mystart() {
>   asm("start:");
>   asm("movl %esp, 0x5000");
              ^^^^^^^^^^^^

The function startup code won't be the only one you're going to have with
this instruction, aka gcc swap intel syntax.



- Davide


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

* Re: I really need help!
  2001-10-17 19:37 I really need help! mike stump
  2001-10-18  9:26 ` Davide Libenzi
@ 2001-10-22  6:46 ` Joern Rennecke
  1 sibling, 0 replies; 7+ messages in thread
From: Joern Rennecke @ 2001-10-22  6:46 UTC (permalink / raw)
  To: mike stump; +Cc: gavinux, gcc

mike stump wrote:
> 
> > Date: Wed, 17 Oct 2001 17:47:49 -0700 (PDT)
> > From: Gavin Li <gavinux@yahoo.com>
> > To: gcc@gcc.gnu.org
> 
> > I am not sure if I should send this mail to here.
> 
> Kinda _not_ what this list is for.
> 
> > void start(void)
> > {
> > 	asm ("movl %esp, 0x5000");
> > }
> 
> > My question is how can I get ride of the first two ASM
> > instructions?
> 
> Go cheat off of newlib, or libc, or glibc, or netbsd, or freebsd...
> 
> > I want the compiler to compile my inlined ASM instruction as the
> > first instruction in the start() function, and the other function
> > just as general output.
> 
> Trivial:
> 
> void mystart() {
>   asm("start:");
>   asm("movl %esp, 0x5000");
> }
> 
> or learn to code in assembler.

Another option would be to implement the naked function attribute for i386,
or making naked [functions] attribute an attribute that has a default
implementation for all targets.

-- 
Joern Rennecke                  |            gcc expert for hire
amylaar@onetel.net.uk           |  send enquiries to: jwr_jobs@onetel.net.uk

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

* Re: I really need help!
  2001-10-17 18:15 ` Carlo Wood
@ 2001-10-22  6:46   ` Joern Rennecke
  0 siblings, 0 replies; 7+ messages in thread
From: Joern Rennecke @ 2001-10-22  6:46 UTC (permalink / raw)
  To: Carlo Wood; +Cc: Gavin Li, gcc

Carlo Wood wrote:
> 
> Did you try -fomit-frame-pointer ?

That is rather unsafe, since any register saves will still go on the
old stack, and a stack pointer will be used if alloca or friends have
been used.  If the function is kept to just the asm and the function
call, you might as well code it entirely in assembler.

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

* RE: I really need help!
  2001-10-17 17:47 Gavin Li
  2001-10-17 18:15 ` Carlo Wood
@ 2001-10-17 22:04 ` akbara
  1 sibling, 0 replies; 7+ messages in thread
From: akbara @ 2001-10-17 22:04 UTC (permalink / raw)
  To: Gavin Li, gcc

http://webster.cs.ucr.edu/Page_asm/ArtOfAsm.html

l8rz,
-akbara
; vertexabuse.cjb.net


> -----Original Message-----
> From: gcc-owner@gcc.gnu.org [ mailto:gcc-owner@gcc.gnu.org]On Behalf Of
> Gavin Li
> Sent: Wednesday, October 17, 2001 5:48 PM
> To: gcc@gcc.gnu.org
> Subject: I really need help!
> 
> 
> I am not sure if I should send this mail to here.
> 
> I use gcc (2.95.3) compile a file which include a
> function start(), 
> the C file is:
> /* Hardware boot loader */
> void start(void)
> {
> 	asm ("movl %esp, 0x5000");
> 	for (;;)
> 	{
>         	/* do whatever I want, such as call foo() */
> 		foo();
> 	}
> }
> foo()
> {
>    ...
> }
> 
> the command line used to compile :
> gcc -O3 -nostdlib -e start -o bootldr.out bootldr.c
> objdump -d bootldr.out > bootldr.asm
> 
> the ASM output is:
> 	push %ebp
> 	mov  %esp, %ebp
> 	mpv  %esp, 0x5000
> 	...
> 
> 
> My question is how can I get ride of the first two ASM
> instructions? I want the compiler to compile my
> inlined ASM instruction as the first instruction in
> the start() function, and the other function just as
> general output.
>  
> My reason that I want to get ride of those instruction
> si:
>    I provided -e start to tell compiler that program
> should start run from start(). There is no other
> function will call this start(), It is the first
> function which was run after power on. The first two
> ASM instructions are useless. Seriosly, they are
> harmful!!!
> Because when an embedded system power on, it runs from
> start(), the stack pointer is undefined at this time,
> it may points to some place where do NOT have memory
> at all! so the push instruction will generate
> exception! So, I need the compiler to generate start()
> which the first instruction is my inline assembler!
>     I checked the GCC online manual, but I can't find
> how to make gcc works as what I want.
>     Anyone who can tell me how to do that?
> 
> Thanks a lot,
> 
> Gavin
> 
> __________________________________________________
> Do You Yahoo!?
> Make a great connection at Yahoo! Personals.
> http://personals.yahoo.com

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

* Re: I really need help!
  2001-10-17 17:47 Gavin Li
@ 2001-10-17 18:15 ` Carlo Wood
  2001-10-22  6:46   ` Joern Rennecke
  2001-10-17 22:04 ` akbara
  1 sibling, 1 reply; 7+ messages in thread
From: Carlo Wood @ 2001-10-17 18:15 UTC (permalink / raw)
  To: Gavin Li; +Cc: gcc

Did you try -fomit-frame-pointer ?

On Wed, Oct 17, 2001 at 05:47:49PM -0700, Gavin Li wrote:
> I am not sure if I should send this mail to here.
> 
> I use gcc (2.95.3) compile a file which include a
> function start(), 
> the C file is:
> /* Hardware boot loader */
> void start(void)
> {
> 	asm ("movl %esp, 0x5000");
> 	for (;;)
> 	{
>         	/* do whatever I want, such as call foo() */
> 		foo();
> 	}
> }
> foo()
> {
>    ...
> }
> 
> the command line used to compile :
> gcc -O3 -nostdlib -e start -o bootldr.out bootldr.c
> objdump -d bootldr.out > bootldr.asm
> 
> the ASM output is:
> 	push %ebp
> 	mov  %esp, %ebp
> 	mpv  %esp, 0x5000
> 	...
> 
> 
> My question is how can I get ride of the first two ASM
> instructions? I want the compiler to compile my
> inlined ASM instruction as the first instruction in
> the start() function, and the other function just as
> general output.
>  
> My reason that I want to get ride of those instruction
> si:
>    I provided -e start to tell compiler that program
> should start run from start(). There is no other
> function will call this start(), It is the first
> function which was run after power on. The first two
> ASM instructions are useless. Seriosly, they are
> harmful!!!
> Because when an embedded system power on, it runs from
> start(), the stack pointer is undefined at this time,
> it may points to some place where do NOT have memory
> at all! so the push instruction will generate
> exception! So, I need the compiler to generate start()
> which the first instruction is my inline assembler!
>     I checked the GCC online manual, but I can't find
> how to make gcc works as what I want.
>     Anyone who can tell me how to do that?
> 
> Thanks a lot,
> 
> Gavin
> 
> __________________________________________________
> Do You Yahoo!?
> Make a great connection at Yahoo! Personals.
> http://personals.yahoo.com

-- 
Carlo Wood <carlo@alinoe.com>

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

* I really need help!
@ 2001-10-17 17:47 Gavin Li
  2001-10-17 18:15 ` Carlo Wood
  2001-10-17 22:04 ` akbara
  0 siblings, 2 replies; 7+ messages in thread
From: Gavin Li @ 2001-10-17 17:47 UTC (permalink / raw)
  To: gcc

I am not sure if I should send this mail to here.

I use gcc (2.95.3) compile a file which include a
function start(), 
the C file is:
/* Hardware boot loader */
void start(void)
{
	asm ("movl %esp, 0x5000");
	for (;;)
	{
        	/* do whatever I want, such as call foo() */
		foo();
	}
}
foo()
{
   ...
}

the command line used to compile :
gcc -O3 -nostdlib -e start -o bootldr.out bootldr.c
objdump -d bootldr.out > bootldr.asm

the ASM output is:
	push %ebp
	mov  %esp, %ebp
	mpv  %esp, 0x5000
	...


My question is how can I get ride of the first two ASM
instructions? I want the compiler to compile my
inlined ASM instruction as the first instruction in
the start() function, and the other function just as
general output.
 
My reason that I want to get ride of those instruction
si:
   I provided -e start to tell compiler that program
should start run from start(). There is no other
function will call this start(), It is the first
function which was run after power on. The first two
ASM instructions are useless. Seriosly, they are
harmful!!!
Because when an embedded system power on, it runs from
start(), the stack pointer is undefined at this time,
it may points to some place where do NOT have memory
at all! so the push instruction will generate
exception! So, I need the compiler to generate start()
which the first instruction is my inline assembler!
    I checked the GCC online manual, but I can't find
how to make gcc works as what I want.
    Anyone who can tell me how to do that?

Thanks a lot,

Gavin

__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com

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

end of thread, other threads:[~2001-10-22  6:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-17 19:37 I really need help! mike stump
2001-10-18  9:26 ` Davide Libenzi
2001-10-22  6:46 ` Joern Rennecke
  -- strict thread matches above, loose matches on Subject: below --
2001-10-17 17:47 Gavin Li
2001-10-17 18:15 ` Carlo Wood
2001-10-22  6:46   ` Joern Rennecke
2001-10-17 22:04 ` akbara

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).