Author Topic: A quick one!  (Read 372 times)

habran

  • Member
  • *****
  • Posts: 1145
    • uasm
Re: A quick one!
« Reply #15 on: April 22, 2018, 11:15:09 PM »
Hi LordAdef :biggrin:

look at this code, I'll not comment it ;)
Code: [Select]
   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

  • Member
  • ****
  • Posts: 573
Re: A quick one!
« Reply #16 on: April 23, 2018, 03:31:48 AM »
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

  • Member
  • ****
  • Posts: 709
  • Asssssssembly language...said the snake.
Re: A quick one!
« Reply #17 on: April 23, 2018, 03:44:01 AM »
I want my struct definitions to be all aligned...

You can check the align directive.  :t

 8)
Felipe.

LordAdef

  • Member
  • ****
  • Posts: 573
Re: A quick one!
« Reply #18 on: April 23, 2018, 03:53:21 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

  • Member
  • ****
  • Posts: 709
  • Asssssssembly language...said the snake.
Re: A quick one!
« Reply #19 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.
Felipe.

LordAdef

  • Member
  • ****
  • Posts: 573
Re: A quick one!
« Reply #20 on: April 23, 2018, 04:12:49 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.

-infinity

  • Regular Member
  • *
  • Posts: 19
Re: A quick one!
« Reply #21 on: April 23, 2018, 04:16:57 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

  • Member
  • ****
  • Posts: 573
Re: A quick one!
« Reply #22 on: April 23, 2018, 04:22:31 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

  • Member
  • *****
  • Posts: 8352
  • Assembler is fun ;-)
    • MasmBasic
Re: A quick one!
« Reply #23 on: April 23, 2018, 06:37:19 AM »
I 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:
Code: [Select]
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

  • Member
  • ****
  • Posts: 573
Re: A quick one!
« Reply #24 on: April 23, 2018, 06:41:36 AM »
Related: Sometimes I see this sort of code formatting:
Code: [Select]
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--

  • Administrator
  • Member
  • ******
  • Posts: 5338
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: A quick one!
« Reply #25 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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

LordAdef

  • Member
  • ****
  • Posts: 573
Re: A quick one!
« Reply #26 on: April 23, 2018, 11:49:36 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