News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

A quick one!

Started by LordAdef, April 22, 2018, 02:23:36 PM

Previous topic - Next topic

habran

Hi LordAdef :biggrin:

look at this code, I'll not comment it ;)

   299:     .if (SDWORD PTR eax > 1)
00007ff7d29e1803 83 F8 01                         cmp eax, 0x1 
00007ff7d29e1806 7E 05                            jle 0x7ff7d29e180d 
   300:       mov ecx, 1
00007ff7d29e1808 B9 01 00 00 00                   mov ecx, 0x1 
   301:     .endif
   302:     .if ( eax > 1)
00007ff7d29e180d 83 F8 01                         cmp eax, 0x1 
00007ff7d29e1810 76 05                            jbe 0x7ff7d29e1817 
   303:       mov ecx, 2
Cod-Father

LordAdef

Hi Habran, thanks!

I just want to say I do know the difference btw the two!

Call me a geometric freak, but all I wanted was a short for sdword as with dd, for the simple fact I want my struct definitions to be all aligned... and I like to use sdword in the declaration, so things get clear when coding.


foo struct

a    dd   ?
b    dd   ?
c    sdword ?  <== this vertical unalignment drives me crazy, believe it or not
d   dd   ?
foo ends

I got away with this:

foo struct

a    dd   ?
b    dd   ?
c    sdw ?  <== looks better and I still know c is sdword
d   dd   ?
foo ends

felipe

Quote from: LordAdef on April 23, 2018, 03:31:48 AM
I want my struct definitions to be all aligned...

You can check the align directive.  :t

8)

LordAdef

Quote from: felipe on April 23, 2018, 03:44:01 AM
Quote from: LordAdef on April 23, 2018, 03:31:48 AM
I want my struct definitions to be all aligned...

You can check the align directive.  :t

8)

I meant "visual" alignment Felipe

... as in one interrogation mark below the other ......

felipe

 :greenclp: Gotcha!

Seriously, i think aligning text format when coding should only be considered from left to right, otherwise you will be more concerned with appearance of text, rather than meaning of code  :idea:.

:lol: Sorry.

LordAdef

Quote from: felipe on April 23, 2018, 03:59:09 AM
:greenclp: Gotcha!

Seriously, i think aligning text format when coding should only be considered from left to right, otherwise you will be more concerned with appearance of text, rather than meaning of code  :idea:.

:lol: Sorry.

I agree with you! But in fact this is something personal. Unorganized things prevent me from thinking.
In fact, code formatting is very important. And I give you and example:

I recently changed the way I was tabbing my code. I noticed Marinus has a larger tab space between the mnemonics and the rest. It is so much easier for me to read Marinus's style of formatting that I adopted his way, and I'm feeling my code is a lot clearer.

russellgreen

Quote from: felipe on April 23, 2018, 03:59:09 AM
...otherwise you will be more concerned with appearance of text, rather than meaning of code...

But also a nicely formatted source code makes it easier to read, especially if posting for others to view.

btw re: formatting
"hard" tabs in others' source code drives me nuts!

I use QE as my editor, and when I view some other source code with multiple nested statements, the code can get so far to the right of the screen and.....   :dazzled:
I prefer QEs method of using 4  spaces substitute for tab, rather than the 'hard' tab.

just my two cents worth

LordAdef

Quote from: rsgrn on April 23, 2018, 04:16:57 AM
Quote from: felipe on April 23, 2018, 03:59:09 AM
...otherwise you will be more concerned with appearance of text, rather than meaning of code...

But also a nicely formatted source code makes it easier to read, especially if posting for others to view.

btw re: formatting
"hard" tabs in others' source code drives me nuts!

I use QE as my editor, and when I view some other source code with multiple nested statements, the code can get so far to the right of the screen and.....   :dazzled:

just my two cents worth

yet, something that makes life really hard is when one gives martian-crazy-long-unreadable names. Come on...

iSFD_D_GEThstgePTR_    dd  2300

invoke Ishd_USHD_ADBE_TTT, iSFD_D_GEThstgePTR_

jj2007

Quote from: RussG on April 23, 2018, 04:16:57 AMI prefer QEs method of using 4  spaces substitute for tab, rather than the 'hard' tab.

Hutch will certainly agree with you. I prefer tabs, because it happens often that I have to shift a bunch of lines to the right etc - but that is just another holy war ;-)

Related: Sometimes I see this sort of code formatting:

mov                              eax, ecx
sub                              eax, edx
mul                              ecx

It's driving me nuts, because it forces the eye to jump half a meter to the right to see the operand. IMHO an excellent method to introduce bugs :icon_mrgreen:

LordAdef

Quote from: jj2007 on April 23, 2018, 06:37:19 AM
Quote from: RussG on April 23, 2018, 04:16:57 AM
Related: Sometimes I see this sort of code formatting:

mov                              eax, ecx
sub                              eax, edx
mul                              ecx

It's driving me nuts, because it forces the eye to jump half a meter to the right to see the operand. IMHO an excellent method to introduce bugs :icon_mrgreen:

Oh, this one is awful too!

hutch--

I know that editor choice is like the choice of girlfriends but there are some fundamentals in code formatting that make the difference between readable code and code that is so obscure that you would not waste your time apart from disassembling it to gain some clarity. A lesson that all of the old fellas learnt long ago was to both format code so it could be read easily AND properly comment code so that you knew what it did a year or so later.

LordAdef

Quote from: hutch-- on April 23, 2018, 11:26:37 AM
I know that editor choice is like the choice of girlfriends but there are some fundamentals in code formatting that make the difference between readable code and code that is so obscure that you would not waste your time apart from disassembling it to gain some clarity. A lesson that all of the old fellas learnt long ago was to both format code so it could be read easily AND properly comment code so that you knew what it did a year or so later.


This is something I learned here! To be honest, I was saved many times by my sometimes over commented code. I over comment, and with time I clean what is really excessive. It's been working for me this way