hi KetilO,

i was wondering if RadASM supports a 'code Re-formation' feature that VC has,
for example:

with no code formation:


.if eax>0
add eax,15h
sub ecx,edx
inc edx
.else
add edx,ecx
mov ecx,eax
inc eax
.endif


after code formation (select text and hit Alt-F8 in VisualC++)


.if eax>0
<tab here>add eax,15h
<tab here>sub ecx,edx
<tab here>inc edx
.else
<tab here>add edx,ecx
<tab here>mov ecx,eax
<tab here>inc eax
.endif


thanks :)
Posted on 2004-06-11 07:51:06 by wizzra
In C, Pascal and VB code styling(formatting) is common. But for ASM can not ever see. But good idea.

Try select lines and TAB ;)
Posted on 2004-06-11 12:12:25 by cakmak
it is IDE feature, has nothing to do with the langugage :)
yeah, i would like to see those in any win32 ide that is being dev atm by users from this forum.
it also must format complex strings to the correct code way.
how about this:

;assume '.' is a space


.........mov eax,12
........................inc edx
.if (eax>0)
.......................add eax,15h
.........sub ecx,edx
...inc edx
.else
add edx,ecx
...............mov ecx,eax
........inc eax
.endif


which sould be formated to:


mov eax,12
inc edx
.if (eax>0)
...add eax,15h
...sub ecx,edx
...inc edx
.else
...add edx,ecx
....mov ecx,eax
...inc eax
.endif
Posted on 2004-06-11 13:38:07 by wizzra
It should be easy enough to do as an addin. You have to just strip the leading spaces and tabs then indent or outdent on certain keywords. The rules are finite and simple to implement.
Posted on 2004-06-11 16:31:39 by donkey
yeah, it can be an addin, but its more likely to be a IDE built in feature :)

when removing space, the spaces must be removed from a relative cursor position
example



.........mov eax,12
........................inc edx
.if (eax>0)
.......................add eax,15h
.........sub ecx,edx
.........if (ecx==5)
.................mov edx,eax
..........................mov ecx,5
....mov eax,ecx
.........endif
...inc edx
.else
add edx,ecx
...............mov ecx,eax
........inc eax
.endif


and format with relative positions


mov eax,12
inc edx
.if (eax>0)
...add eax,15h
...sub ecx,edx
....if (ecx==5)
.......mov edx,eax
.......mov ecx,5
.......mov eax,ecx
....endif
....inc edx
.else
....add edx,ecx
....mov ecx,eax
....inc eax
.endif
Posted on 2004-06-12 04:45:30 by wizzra
I already programm / format like that with hard tabs ;)
So please take care that it will NOT break my own formating...
Posted on 2004-06-12 06:31:43 by BogdanOntanu
Bogdan,

what? add-in? I can't understand your post .
Posted on 2004-06-12 09:19:00 by wizzra
No he means your formatting style is already using by him. Copyright problem :))
Posted on 2004-06-12 13:03:46 by cakmak
Actually I assume he means that it must be optional because he has his own formatting style and does not want RadASM to try to change his blocking, I feel the same way, I format my code as I write it and follow certain guidelines that make it readable for me. If the feature is added it would have to be something you could turn off and would have to be configurable to each persons personal preferences.
Posted on 2004-06-12 13:19:33 by donkey
yeah,
i know what you mean by personal formating,
if so, as donkey said, personolized formating options should be added with option to shut it off.
Posted on 2004-06-12 13:37:20 by wizzra
Donkey was right about what i wanted to say ;)

cakmak: that was a funny post, after Microsoft patented coments with todo: list in source code i was wondering if my SolOS (beeing too much commented) is not breaking any patents :grin: ...damn humman race ...
Posted on 2004-06-12 23:38:21 by BogdanOntanu
Well, donkey won the prize :)

BogdanOntanu: Take care :) You dont have to admit your patent violations so clear.

Happy Coding
Posted on 2004-06-13 14:37:41 by cakmak
Along these lines of thought, i would *love* if there was some further formatting as follows:


mov eax, SomVariable ;My Reason

To:


...A...mov...B...eax, SomVariable...C...; My Reason


Where A, B, and C are specificed variables for column alignment. As well a forced single space only after commas and directly following a semi-colon.

This is my prefered way of reading ASM. However, the A variable could be set to vary depending on .if/.else/.while structures as this thread started out on. I realize you now have a problem. What if the comment starts with all the indenting, past the prescribed column start point. In this case it would not do anything, except not the longest string past the prescribed point. At the end of the pass over your source, it can update the variable with the newly learned MAX starting point of a comment. So the next time the user runs this 'add in' it will move all the coments in align according to the last known max line...


I dont know how to make add-ins, but if this feature were around I'd use it...
Regards,
:NaN:
Posted on 2004-06-13 20:14:46 by NaN
mmm, ;), I have in mind some from time a go... if I will write some assembler or some, I will not add help for comments or documentation and for formatting (in the normal way), because the formating is only needed for the programmer equal than the comments documentation.

The ones that will care about that things will be tools that are directly designed to suport the language, there are other things that I have in mind, but regarded to what you are talking only this.

With a "block language" will be 'easy' make the identations at runtime following some rules that can be changed, if you insert a comment, there are two options, that the source editor let you modify in the code, but in fact save it in other file, or put all the comments and documentationt at the end, with a respective mark of lines, also the editor in that moment can be converted in a documentation editor, that let you insert images, links, formulas, etc, also instead of put: todo, and you need search in the document TODO list, or warning, or not yet implemented, they can be easely get by the source editor and show you in a project the this things, apart of errors, name of funtions, relations, strutures, etc.



OK, for resume, I supose you get the idea, I discourage much insert comments, documentation, warnings, TODO and other things that are not code in the code, also formatting will have only a significate for the programmer (diferent from person to person, but some rules can be provided).

The formatting can be done (I think) at edit time by the source editor(more if is per bocks).

For the other things, because not are code, can be handled in diferent ways:

Insert the following at the end of the code (they can be distributed at the same time to other persons), or make a separate file with a diferent extension or some(they can be separated, and only provide one of them to other persons):

Let that the source editor move that things to the end and divide in sections, also have a reference per line where start the comment or documentation in the source. Also the assembler/compiler can do that.


This sound repetitive... ;), pheraps can be acepted comments (I discourage them in middle of the code), but one thing that I not accept is documentation in the middle of the code, then get them to the end, or other file.

Maybe you are thinking that I can hide things, maybe this is a large solution for a simple problem, that can be handled only letting the editor show hide things, and search for specific marks.


But I whant to encourage the diference between the implementation, things that the programmer mark about implementation (this are normally called comments)(TODO, warnings, problemHere, jokes of programmers ), and the documentation of the implementation.


Have a nice day or night.
Posted on 2004-06-14 10:19:26 by rea
Hi All,

I think code layout add-ins are a great idea. I was always taught that code should be well formatted and well commented. It does make the code easier to read, which is good when you are passing code on to others to read.

As mentioned here, many programmers have their own way of laying code out. The tricky bit could be definining this style for automatic formatting. As it would be very annoying if code were to format to the 'wrong' style (ie. not the way you like to lay it out.) Could a code formatter format to a set of rules defined by a user?
Posted on 2004-06-30 03:05:17 by kakashi
Here you are ;)
supports whatever I could currently remember
bugtests/stuff is welcome
Posted on 2004-06-30 06:27:33 by Ultrano
I realize that this is an old thread, but does "here you are" mean that there was a posted attachment i.e. a formatter for Radasm?  If so, where is the attachment??
Posted on 2005-06-03 14:51:36 by namuh1
I am not completely sure which addin it is refering to but it is probably available at Ketil's website, you will find addins on the projects page.
Posted on 2005-06-05 04:40:21 by donkey
Thank you.  I found it with no trouble.

Posted on 2005-06-07 09:39:40 by namuh1