public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* gas preprocessor
@ 2002-01-13  8:53 Crni Gorac
  2002-01-15  7:06 ` Nick Clifton
  0 siblings, 1 reply; 4+ messages in thread
From: Crni Gorac @ 2002-01-13  8:53 UTC (permalink / raw)
  To: binutils

Is preprocessing support in gas working? Am trying to
utilize it with gas 2.11.90.0.8 in order to create
alias names for functions arguments instead of use
[ebp+8] etc. (am using Intel syntax). What I'm
actually looking for is gas equivalent of EQU
directive commonly found in other (well, at least
IA-32) assemblers. I know that I could accomplish same
using gcc preprocessor but I don't like this solution
(when debugging code using gdb I have to struggle
again with [ebp+8] and alike).

Thanks.


__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/

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

* Re: gas preprocessor
  2002-01-13  8:53 gas preprocessor Crni Gorac
@ 2002-01-15  7:06 ` Nick Clifton
  2002-01-15 11:11   ` Crni Gorac
  0 siblings, 1 reply; 4+ messages in thread
From: Nick Clifton @ 2002-01-15  7:06 UTC (permalink / raw)
  To: Crni Gorac; +Cc: binutils

Hi Crni,

> Is preprocessing support in gas working? Am trying to utilize it
> with gas 2.11.90.0.8 in order to create alias names for functions
> arguments instead of use [ebp+8] etc. (am using Intel syntax). What
> I'm actually looking for is gas equivalent of EQU directive commonly
> found in other (well, at least IA-32) assemblers. I know that I
> could accomplish same using gcc preprocessor but I don't like this
> solution (when debugging code using gdb I have to struggle again
> with [ebp+8] and alike). 

I believe that the short answer to your question is "no".

You can use the .set directive to set up assemble time aliases for
expressions, so you could do:

        .set foo, [ebp+8]

This will not generate a debugging entry however, so you will not be
able to see 'foo' in your GDB sessions.

You might be able to use the register aliasing ability of gcc to solve
your problem however.  For example a declaration like this:

  register int ebp_reg asm ("ebp");

would create a variable called 'ebp_reg' which was mapped onto the ebp
register and which could be viewed inside gdb.

Cheers
        Nick

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

* Re: gas preprocessor
  2002-01-15  7:06 ` Nick Clifton
@ 2002-01-15 11:11   ` Crni Gorac
  2002-01-16  3:37     ` Nick Clifton
  0 siblings, 1 reply; 4+ messages in thread
From: Crni Gorac @ 2002-01-15 11:11 UTC (permalink / raw)
  To: binutils; +Cc: Nick Clifton

Hi Nik, thank you for your reply.

I tried what you suggested but seems like it doesn't
work. Here is small assembly program:

.intel_syntax noprefix
	
.text
.global  _start

_start:
	call answer
	mov	ebx, eax
	
	mov	eax, 1
	int	0x80

answer:
.set result, [ebp-4]
        enter   4, 0

	mov	result, dword ptr 42
	mov	eax, result
        leave
        ret

I'm using following commands to compile it:
as -o foo.o foo.s
ld -o foo foo.o

However, linker reports errors:
foo.o: In function `answer':
foo.o(.text+0x14): undefined reference to `ebp'
foo.o(.text+0x1d): undefined reference to `ebp'

Thanks.

--- Nick Clifton <nickc@cambridge.redhat.com> wrote:
> Hi Crni,
> 
> > Is preprocessing support in gas working? Am trying
> to utilize it
> > with gas 2.11.90.0.8 in order to create alias
> names for functions
> > arguments instead of use [ebp+8] etc. (am using
> Intel syntax). What
> > I'm actually looking for is gas equivalent of EQU
> directive commonly
> > found in other (well, at least IA-32) assemblers.
> I know that I
> > could accomplish same using gcc preprocessor but I
> don't like this
> > solution (when debugging code using gdb I have to
> struggle again
> > with [ebp+8] and alike). 
> 
> I believe that the short answer to your question is
> "no".
> 
> You can use the .set directive to set up assemble
> time aliases for
> expressions, so you could do:
> 
>         .set foo, [ebp+8]
> 
> This will not generate a debugging entry however, so
> you will not be
> able to see 'foo' in your GDB sessions.
> 
> You might be able to use the register aliasing
> ability of gcc to solve
> your problem however.  For example a declaration
> like this:
> 
>   register int ebp_reg asm ("ebp");
> 
> would create a variable called 'ebp_reg' which was
> mapped onto the ebp
> register and which could be viewed inside gdb.
> 
> Cheers
>         Nick
> 


__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/

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

* Re: gas preprocessor
  2002-01-15 11:11   ` Crni Gorac
@ 2002-01-16  3:37     ` Nick Clifton
  0 siblings, 0 replies; 4+ messages in thread
From: Nick Clifton @ 2002-01-16  3:37 UTC (permalink / raw)
  To: Crni Gorac; +Cc: binutils

Hi Crni,

> I tried what you suggested but seems like it doesn't
> work. Here is small assembly program:
> 
> .set result, [ebp-4]
> 	mov	result, dword ptr 42
> 	mov	eax, result

> However, linker reports errors:
> foo.o: In function `answer':
> foo.o(.text+0x14): undefined reference to `ebp'
> foo.o(.text+0x1d): undefined reference to `ebp'

*sigh* Yes, it seems that the assembler does not recheck the
expression in an evaluated .set symbol to see if it is a register
name, so it creates a reference to a symbol called 'ebp'.  I thinkt
you are going to have to use the C preprocessor instead.  Sorry.

Cheers
        Nick

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

end of thread, other threads:[~2002-01-16 10:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-13  8:53 gas preprocessor Crni Gorac
2002-01-15  7:06 ` Nick Clifton
2002-01-15 11:11   ` Crni Gorac
2002-01-16  3:37     ` Nick Clifton

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