News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Code Beautifier

Started by JohnnyReb, June 13, 2006, 02:12:51 AM

Previous topic - Next topic

JohnnyReb

I'm writing my first masm32 window program.  It is a multiple-choice program which tutors the capitals of states.  I started with one of the examples and modified from there.  I got it working, but my source desperately needs cleanup.  Is there a (hopefully) free code beautifier available for masm32 assembler source?
Thanks in advance,
JohnnyReb

stanhebben

How could a program ever do that for you?

Everyone's definition of 'beautiful' code is different...

hutch--

I agree with Stan here, far better to format your own code and ad some comments where you think you need them than to try and shove it through a text formatting program that can only blindly chomp away at the format of the text.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

JohnnyReb

Well, if not a code beautifier, is there style guidelines that would make assembler code more readable? 

In my IBM 370 assembler experience, col 1 for labels, col 9 for op codes, col 13 for operands, col 35 for comments.  And how should macros fit in.  Should indents be used and if so, where?

With more experience, I would develop my own style.  But I was hoping to jump-start that process.  I did find this link

http://webster.cs.ucr.edu/Articles/asmstyle.html#HEADING1-0

which was a little much, as I am already going thru the learning curve for the WIN API in addition to updating my very old z80 assembler skills.
Thanks again,
JohnnyReb

hutch--

John,

I have never claimed to be a reference for code formatting as it tends to be a matter of personal taste but it may be worth you having a look at the formatting style in the masm32 project as it is one approach to trying to write tidy readable code. I grew up in the old days of a label that fitted into the space of two tabs then the opcode, another tab for each operand and a couple of extras for any side comments but but over time I have adapted to a later style of coding that was influenced by writing years of Windows API code where the complexity knocked you over.

Label on seperate line, with nominally 2 spaces.
Normally an empty line before a label.
Each opcodes on a seperate line at 4 spaces indent.

Seperation of logical blocks of asm code. It tends to look like this.


; space here
  label:
    mov al, [esi]
    sub esi, 1
    jnz label


Some people like evenly spaced operands,


; space here
  label:
    mov     al,     [esi]
    sub     esi,    1
    jnz     label


It really is a matter of taste but there are a few guidelines around that you can either like or ignore depending on your own taste.  :bg

Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php