Re: Formatting in assembly




James Daughtry wrote:
Okay, this is a combination of "What constitutes good formatting in
assembly?" and "Hey Betov, how does this strike you?". Here's some
RosAsm code formatted with Betov's suggestions. I'll eat my hat and say
that the flow is definitely easier to follow:

<snip?

The formatting works, but not quite as well. Ironically, this is
similar to my first attempts at writing assembly where I tried to
format the code like I would C. I rather like it, but I'm curious what
everyone else around here thinks about formatting assembly source code.
The sky is the limit, how do you feel assembly should be formatted for
readability? :-)

Hi James,

First of all, everyone will have a different opinion on this topic. No
2 coders will share the same 'style'. But anyway, here is the style
that I tend to use for my personal projects.

Single column, labels and assembler directives/options hard left.
Source intended 1 tab (1 tab = 2 or 4 spaces). For loops and other
conditional branches no addtional indentation (unlike your examples).
Comments align on column 32. Double line feed between procedures always
with header comment (procedure description including input/output).
Header comment has 2 leading comment characters (eg ;;) and aligned on
column 1.

Labels have each first letter of each word capitalised, and depending
on label name, words are joined or separated by underscore. eg.
SourceLabel2: or ThisIsAVeryLongLabel:

or:

use 32bit


;; Proc ExitToSystem:
;; This procedure exits the application returning control to the OS.
;; expects: al = exit code
;; output: void

ExitToSystem:
mov ah, 4ch
int 21h
ret


;; More code...

But if I'm working on someone else's code, then I use their coding
style...

--
Darran (aka Chewy509) brought to you by Google Groups!

.



Relevant Pages

  • Re: When to use Rosasm, when to use Masm?
    ... as desired;)...once the format can only possibly be ... > Rene can define it to be whatever Rene wants it to be (including, ... source file made a *big* difference in assembly performance. ... The assembler didn't compile the code to machine code, ...
    (alt.lang.asm)
  • Re: From the LuxAsm list.
    ... Lisa/816 did this, though it used a proprietary format ... MHz Apple II GS system by avoiding most of the symbol table ... In nearly every assembler I've used the symbol table lookup ... symbol table lookups, you remove a large percentage of the time ...
    (alt.lang.asm)
  • Re: C++ , and z/OS
    ... I have done that in the past in assembler. ... After having read the member names, ... It includes some z/OS specific functions like ...
    (bit.listserv.ibm-main)
  • Re: assembly without anything
    ... how the bios is written? ... interrupts, cause the interrupts are provided by itself... ... not to assembler. ... format that the environment needs. ...
    (alt.lang.asm)
  • Need help interfacing Gnu "as" to fpc (very specific)
    ... days I have been looking at AT&T syntax for the Gnu assembler ... The header is the problem ... buffer visible in fpc. ...
    (comp.lang.pascal.misc)