* "\n\t" in inline asm
@ 1998-12-10 3:41 Martynas Kunigelis
1998-12-10 3:54 ` Andreas Schwab
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Martynas Kunigelis @ 1998-12-10 3:41 UTC (permalink / raw)
To: egcs
Good day,
I use inline assembly quite often and I am a little disturbed by the
need to append "\n\t" to the end of every inline assembly line. This
makes the code much less readable, so I end up using a preprocessor hack
like this:
#define _ "\n\t"
asm (
"movl %0,%1" _
"decl %2" _
"int $0x80"
: /* this is just an example */
: "=r" (0) /* whatever */
);
#undef _
While experimenting I tried using commas at the end of each line, like
this:
asm (
"movl %0,%1",
"decl %2",
"int $0x80"
: /* this is just an example */
: "=r" (0) /* whatever */
);
It compiled w/o problems, but the resulting .s file had only the last
line from the inline asm statement, that is "int $0x80". It seems as if
it was evaluated as a regular C statement, like "a = 1, 2, 3, 4;" would
result in a == 4.
I would like to make a suggestion to add somewhat more special handling
of inline asm() statements, and make a comma appent the "cursed" "\n\t"
to each line. That wouldn't break any existing code and it would allow
one to "beautify" the inline assembly code a lot more.
-Martynas
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: "\n\t" in inline asm
1998-12-10 3:41 "\n\t" in inline asm Martynas Kunigelis
@ 1998-12-10 3:54 ` Andreas Schwab
1998-12-10 4:11 ` Philip Blundell
1998-12-10 10:35 ` Gilles-Claude Rajaobelina
2 siblings, 0 replies; 5+ messages in thread
From: Andreas Schwab @ 1998-12-10 3:54 UTC (permalink / raw)
To: Martynas Kunigelis; +Cc: egcs
Martynas Kunigelis <mkunigelis@alna.lt> writes:
|> I use inline assembly quite often and I am a little disturbed by the
|> need to append "\n\t" to the end of every inline assembly line.
You can use a semicolon instead. But this depends on the assembler, the
compiler does not interpret anything inside the string except % escapes.
--
Andreas Schwab "And now for something
schwab@issan.cs.uni-dortmund.de completely different"
schwab@gnu.org
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: "\n\t" in inline asm
1998-12-10 3:41 "\n\t" in inline asm Martynas Kunigelis
1998-12-10 3:54 ` Andreas Schwab
@ 1998-12-10 4:11 ` Philip Blundell
1998-12-11 3:15 ` Jamie Lokier
1998-12-10 10:35 ` Gilles-Claude Rajaobelina
2 siblings, 1 reply; 5+ messages in thread
From: Philip Blundell @ 1998-12-10 4:11 UTC (permalink / raw)
To: Martynas Kunigelis; +Cc: egcs
>I use inline assembly quite often and I am a little disturbed by the
>need to append "\n\t" to the end of every inline assembly line. This
You don't. You can write it like this:
asm (
"movl %0,%1
decl %2
int $0x80"
: /* this is just an example */
: "=r" (0) /* whatever */
);
p.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: "\n\t" in inline asm
1998-12-10 3:41 "\n\t" in inline asm Martynas Kunigelis
1998-12-10 3:54 ` Andreas Schwab
1998-12-10 4:11 ` Philip Blundell
@ 1998-12-10 10:35 ` Gilles-Claude Rajaobelina
2 siblings, 0 replies; 5+ messages in thread
From: Gilles-Claude Rajaobelina @ 1998-12-10 10:35 UTC (permalink / raw)
To: Martynas Kunigelis; +Cc: egcs
Martynas Kunigelis wrote:
> While experimenting I tried using commas at the end of each line, like
> this:
>
> asm (
> "movl %0,%1",
> "decl %2",
> "int $0x80"
> : /* this is just an example */
> : "=r" (0) /* whatever */
> );
>
>
This is how I would have written it:
asm ("
movl %0,%1;
decl %2;
int $0x80;"
: /* this is just an example */
: "=r" (0) /* whatever */
);
--
Gilles-Claude Rajaobelina \\\/// | mailto:Gilles.Rajaobelina@bull.net |
Groupe Bull (o o) | http://www.openmaster.com \\\/// |
rue Jean Jaures, BP68 oOO--(_)--OOo| Tel:(33)01.30.80.77.87 (o o) |
78340 Les Clayes sous Bois, FRANCE |Fax:(33)01.30.80.33.35 oOO--(_)--OOo|
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: "\n\t" in inline asm
1998-12-10 4:11 ` Philip Blundell
@ 1998-12-11 3:15 ` Jamie Lokier
0 siblings, 0 replies; 5+ messages in thread
From: Jamie Lokier @ 1998-12-11 3:15 UTC (permalink / raw)
To: Philip Blundell, Martynas Kunigelis; +Cc: egcs
On Thu, Dec 10, 1998 at 12:08:48PM +0100, Philip Blundell wrote:
> >I use inline assembly quite often and I am a little disturbed by the
> >need to append "\n\t" to the end of every inline assembly line. This
>
> You don't. You can write it like this:
>
> asm (
> "movl %0,%1
> decl %2
> int $0x80"
> : /* this is just an example */
> : "=r" (0) /* whatever */
> );
But then the assembly output is ugly. The point of using "\n\t" is that
it matches up with GCC's generated code in the output file.
I like the suggestion for parsing commas between strings as line
separators. Semicolons instead of commas might be easier (they work for
`for'), but they're a bit uglier IMO and easily confused with colons.
-- Jamie
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~1998-12-11 3:15 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-12-10 3:41 "\n\t" in inline asm Martynas Kunigelis
1998-12-10 3:54 ` Andreas Schwab
1998-12-10 4:11 ` Philip Blundell
1998-12-11 3:15 ` Jamie Lokier
1998-12-10 10:35 ` Gilles-Claude Rajaobelina
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).