Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Is there any convention on what to capitalize in (x86) assembly?

For example, which one of these 'looks best'? (Or maybe none of them do?)

[BITS 32]
%define MACRO 1
MyLabel:
    MOV EAX, 2

versus

[bits 32]
%define macro 1
MY_LABEL:
    mov eax, 2

versus

[Bits 32]
%define MACRO 1
MyLabel:
    mov EAX, 1

versus all the other possibilities?

share|improve this question
    
Unless you specify a specific assembly language I doubt there will be any form of consensus to be found, and this question will be highly subjective. –  Steven Jeuris May 17 '12 at 0:40
    
@StevenJeuris: Oh, I was referring to x86 assembly... is that what you mean? –  Mehrdad May 17 '12 at 0:45
1  
Lower case is better: What's with all of the YELLING? :-) –  jpaugh May 17 '12 at 5:44
3  
@jpaugh - because assembly is old, and can't hear too good. –  detly May 17 '12 at 5:54
    
@jpaugh I don't think assemblers really care, but lowercase does seem to be the "standard". –  Hawken Jan 6 '13 at 2:42
add comment

closed as not constructive by Steven Jeuris, MainMa, Bernard, Caleb, Walter May 17 '12 at 20:19

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

Every coder has his/her own style, like a signature, or handwriting. I would say if you want your code to be comfortably readable by the largest audience, use the "default" styles that you generally find as the output from a disassembler, or assembly listing from a compiler. In this way copying any disassembly into your program requires no reformatting and any coder worth their coding skills will be familiar with that format, logically speaking that is.

Macros aren't generally listed in disassembly so you are on your own on that, I will say it helps to have a common symbol like @, %, or + in every macro name to allow for quick recognition of macro identifiers. Most C familiar programmers like to capitalize macro names but it isn't necessary if you affix a common symbol to your macro identifiers because assembler syntax barely resembles spoken language.

If you want to see some "established" coding style (and learn a some tricks) in X86 ASM coding, be sure to read Randal Hyde's "The Art of Assembly Programming"

I would like to give you some advice if I may be so bold. It can get pretty rough maintaining a large assembly program, try to keep things small and modular, try to write C compatible libraries so you can take full advantage of your time invested on machines where that code will execute.

People argue that assembler is not portable, well if you write the same API in C as well as assembler, you will have the option of installing the optimized version of your library on machines that can run your X86 code, and you will still have the advantage of compiling for multiple architectures.

Be forewarned this is my personal opinion based on personal experience and does not intentionally conform to any written guideline. However I am more than sure that with proper discipline, research and development you will find my method to be most rewarding.

share|improve this answer
    
Even still, I am not sure this is a valid answer I haven't coded ASM in a few months now and I am sure I have forgotten many things that could be helpful to you, but I could not type all of that into a comment, so it is what it is. –  user54262 May 17 '12 at 7:09
    
I also wanted to mention that you can cheat and beat highly optimized c code by using register based procedure calls in the private procedures of your library versus stack based. Memory I/O is very expensive, register I/O is every bit as quick as "lightning". –  user54262 May 17 '12 at 7:21
    
Randal's HLA as established assembly style? AFAIK, his book will teach you a very idiosyncratic version of assembly. –  AProgrammer May 17 '12 at 7:56
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.