Skip to contentSkip to conversation

ASM formatting rules?

DISCUSSION Kumar Gala 7 participants 10 messages Mar 28, 2005 – Apr 5, 2005

lore
Share & tools
lore

Kumar Gala

author
#0 lore raw

Guys,

While this is not overly important to me, I was wondering if we had any rules related to formatting of assembly files. We seem to have code formatted with and without spaces in the args.

I'm assuming something like this (w/o spaces):

<TAB>insn<TAB>argD,arg1,arg2

is what we want? Just trying to get a rule documented going forward.

- kumar

#1 lore raw
Quoted 11 lines · Kumar Gala

Guys,

While this is not overly important to me, I was wondering if we had any rules related to formatting of assembly files. We seem to have code formatted with and without spaces in the args.

I'm assuming something like this (w/o spaces):

<TAB>insn<TAB>argD,arg1,arg2

is what we want? Just trying to get a rule documented going forward.

My preference is for spaces after each , just because it makes it visually clearer (and I don't always have instant mental insn->#args mental mapping :)).

Signature · 2 lines
Tom Rini
http://gate.crashing.org/~trini/
#2 lore raw
Quoted 1 line · Tom Rini

My preference is for spaces after each , just because it makes it

Me, too.

Thanks.

	-- Dan
#3 lore raw
In reply to Tom Rini
Quoted 9 lines · Tom Rini
Quoted 8 lines · Kumar Gala

Guys,

While this is not overly important to me, I was wondering if we had any rules related to formatting of assembly files. We seem to have code formatted with and without spaces in the args.

I'm assuming something like this (w/o spaces):

Quoted 7 lines
Quoted 3 lines

<TAB>insn<TAB>argD,arg1,arg2

is what we want? Just trying to get a rule documented going forward.

My preference is for spaces after each , just because it makes it visually clearer (and I don't always have instant mental insn->#args mental mapping :)).

As long as there is <TAG>insn<TAB>, I don't have strong feelings about the arg spacing. I feel that spaces between args really don't enhance readability (why I have none between args in head_44x.S) but I can live with them.

I think this is a good idea to get some consistency throughout ppc32 asm.

-Matt

#4 lore raw
In reply to Kumar Gala
Quoted 5 lines · Kumar Gala

I'm assuming something like this (w/o spaces):

<TAB>insn<TAB>argD,arg1,arg2

is what we want? Just trying to get a rule documented going forward.

Yep, that's the style we use.

Paul.

author
#5 lore raw

Great, if my counting is correct (which may not be, since I grow up in=20=

Florida)

2 - for no space (Paul, BenH)
2 - for spaces (Tom, Dan)
2 - dont cares (Kumar, Matt)

Well, does Paul have authoritative rule here as ppc maintainer? :)

- kumar

Quoted 7 lines · Paul Mackerras
Quoted 5 lines · Kumar Gala

I'm assuming something like this (w/o spaces):

<TAB>insn<TAB>argD,arg1,arg2

is what we want?=A0 Just trying to get a rule documented going =

forward.

Quoted 4 lines

Yep, that's the style we use.

Paul.

#6 lore raw
Quoted 8 lines · Kumar Gala

Great, if my counting is correct (which may not be, since I grow up in Florida)

2 - for no space (Paul, BenH)
2 - for spaces (Tom, Dan)
2 - dont cares (Kumar, Matt)

Well, does Paul have authoritative rule here as ppc maintainer? :)

I would take a similar attitude to Linus and say that if there is someone who has taken on the role of maintaining a file or subsystem, they get a fair bit of latitude in saying what the style should be there. So if Dan and Tom want to do "insn<TAB>op, op, op" in head_8xx.S, I'm not going to go in and remove all the excess spaces.

However, apart from that - i.e. for code that is used on all PPC platforms, or if people are asking what the style should be - then the style is no spaces between the operands.

Paul.

#7 lore raw
Quoted 3 lines · Paul Mackerras

However, apart from that - i.e. for code that is used on all PPC platforms, or if people are asking what the style should be - then the style is no spaces between the operands.

OK .... I'll try to change my old habits :-)

	-- Dan
#8 lore raw
In reply to Kumar Gala
Quoted 11 lines · Kumar Gala

Guys,

While this is not overly important to me, I was wondering if we had any rules related to formatting of assembly files. We seem to have code formatted with and without spaces in the args.

I'm assuming something like this (w/o spaces):

<TAB>insn<TAB>argD,arg1,arg2

is what we want? Just trying to get a rule documented going forward.

I used to have argD, arg1, arg2 but since everything else was "compact", I now tend to adapt to everything else ;)

Ben.

#9 lore raw
Quoted 7 lines · Benjamin Herrenschmidt
Quoted 6 lines · Kumar Gala

Guys,

While this is not overly important to me, I was wondering if we had any rules related to formatting of assembly files. We seem to have code formatted with and without spaces in the args.

Quoted 8 lines
Quoted 5 lines

I'm assuming something like this (w/o spaces):

<TAB>insn<TAB>argD,arg1,arg2

is what we want? Just trying to get a rule documented going forward.

I used to have argD, arg1, arg2 but since everything else was "compact", I now tend to adapt to everything else ;)

Assembly is not C! I don't like the space after the comma in assembly, but can adapt to (almost) any style.

For the record, the biggest file of PPC assembly I wrote (the real mode x86 emulator to initialize graphics board through BIOS emulation) is really atypical:

1) it has two tabs before the opcode, because it must accomodate really_long_labels and a single tab is not enough.

2) only a space between the opcode and the operands, but many registers have fixed uses and have mnemonic names through #defines. This helps a lot for readability and maintainability. See 4) for the reason.

3) no space after the comma between operands.

4) Sometimes several instructions separated by a semicolon in the same line, but only the first instruction may have a label. That's because at the time I wanted to see as much as possible on a small screen. But this does not mix well with putting tabs between instruction and operands, hence 2).

I don't think these rules ar generally applicable to assembly files, these were specific rules which matched my needs for this file (5000 lines).

Gabriel