Skip to contentSkip to conversation

Asm style

DISCUSSION Giacomo Catenazzi 2 participants 2 messages Nov 22, 2001 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 12 lines · Ben Collins

There's also:

	asm("\
	cmd	r,r\n\
lbl:	cmd	r,r\n\
	cmd	r,r\n" : spec : spec);

Or something similar (the trailing "\" added for continuation). Probably the easiest way to patch existing asm.

not ANSI C. The trailing \ is understood only in marco definitions (and outside strings)

giacomo

#2 lore raw
Quoted 9 lines · Giacomo Catenazzi
Quoted 8 lines · Ben Collins

There's also:

	asm("\
	cmd	r,r\n\
lbl:	cmd	r,r\n\
	cmd	r,r\n" : spec : spec);
Quoted 5 lines
Quoted 2 lines

Or something similar (the trailing "\" added for continuation). Probably the easiest way to patch existing asm.

not ANSI C. The trailing \ is understood only in marco definitions (and outside strings)

gcc begs to differ

/* z.c */
#include <stdio.h>

int main(void)

{
    printf("This is a string\n\
with continuation characters\n");
    return 0;
}
$ gcc -Wall -pedantic -ansi z.c -o z
[silence]

Remove the \ and you get

z.c:5: warning: string constant runs past end of line z.c: In function `main':
z.c:5: warning: ANSI C forbids newline in string constant

You are correct in thinking it is something to do with pre-processor - it deals with these continuation lines eg,

$ gcc -E -Wall -pedantic -ansi z.c

Gives
[snip stdio etc]
int main(void)

{
    printf("This is a string\nwith continuation characters\n");

    return 0;
}
Signature · 2 lines
Nick Craig-Wood
[email protected]