Author Topic: Introduction + Silly Question :)  (Read 548 times)

coder

  • Member
  • **
  • Posts: 103
Re: Introduction + Silly Question :)
« Reply #15 on: July 27, 2017, 05:59:28 AM »
Actually INVOKE is not a macro in Masm, it has been a directive, for the last 25 years or so. Then Microsoft transferred all MASM developers to the C# department leaving there just an old guy to change the version number and rebuild from time to time (probably with the assistance from some people from this forum ).
When it was time to compile MASM for 64-bit they could not make INVOKE and the Comparition directives to work, so they left these behind saying rough and hard to use is indeed a feature - some people in this forum agree with that 100%.
You didn't just make that story up, did you?

I am not against high-level stuff. They have their own advantages especially in code readability. They fit very well in complex Win APIs environment. But some people just want to learn instructions without such API burden. I don't remember who, but someone told me that you should just throw away your AMD/Intel manuals once you're using MASM because it is highly likely that in a MASM source code, you could find only 20-30 percent 'instructions' while the rest are high-level statements, macros and directives. Look at this example:

Code: [Select]
.data
s1 db 'abcdefgh',0
s2 db 'abcd',0
.code
start:
.for (ebx = offset s1, edx = func(strlen,ebx) ¦ edx >= sizeof(s2) ¦ edx--)
    mov byte ptr [ebx+edx-1],0
.endfor
invoke printf,cstr(<"s1: %s",10,"s2: %s",10>),ebx,addr s2
output:
s1: abcdefgh
s2: abcd
...
mov ebx,offset s1
.for (edx = func(strlen,ebx) ¦ edx >= sizeof(s2) ¦ edx--)
output:
s1: abcd
s2: abcd

There's only one instruction in there, that is MOV instruction, out of the entire code. The rest are high-level stuff. This is not healthy for beginners wishing to learn X86 instruction sets (which is the heart of assembly programming anyway).

felipe

  • Member
  • ***
  • Posts: 282
  • I love assembly language programming.
Re: Introduction + Silly Question :)
« Reply #16 on: July 27, 2017, 08:09:40 AM »
invoke hides too many things crucial to understanding how instructions really work - the true fun of x86 assembly programming.
I understand this coder, but i really think that if were out there more O.Ses, probably it would be more fun to make programs than to understand just the basics of the architecture.  :greensml:

There are many bad guys in here, led by Hutch. You and I are the good guys  :dazzled:
:lol:
Felipe.

jj2007

  • Member
  • *****
  • Posts: 7554
  • Assembler is fun ;-)
    • MasmBasic
Re: Introduction + Silly Question :)
« Reply #17 on: July 27, 2017, 08:18:57 AM »
high-level stuff ... is not healthy for beginners wishing to learn X86 instruction sets (which is the heart of assembly programming anyway).

Code: [Select]
include \masm32\include\masm32rt.inc

.code
start:

  mov eax, 20
  lea ecx, [eax+4*eax]

  inkey str$(ecx), " is the result"
  exit

end start

Do you learn something when you see the two lines in the middle?
Will you learn something when you build and run this code?

Yes.

Will you learn better when somebody convinces you that you should not use this inkey and str$() high level stuff...?

Rob260z

  • Regular Member
  • *
  • Posts: 9
Re: Introduction + Silly Question :)
« Reply #18 on: July 27, 2017, 08:23:41 AM »
Cheers for the welcome folks :)

Sorry jj2007 , I shouldn't have taken offence , that was petty of me. It was 1am in the morning when I posted that. Busy trying to juggle my interest in Assembly ( wife would say obsession ) and my boring everyday work commitments :)

Coders example piece of code ! , ewwwwwww...yuck....lol. I must say it's this aspect of MASM that I initially wrestled with. But I realised that I don't have to use it , if I don't wish.

You are correct Coder , purist was the wrong terminology. It's the low level control that Assembly offers, that I really enjoy. It's about as close to having direct control of the CPU as I'm ever going to get.  But with that said , I'm also happy to use the WIN32 api. Why reinvent the wheel. It's all about compromise at the end of the day , the fine balance between it being fun or a grind.

Anyway, I should get back to double checking my RET's.........

Cheers,
Rob

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 4813
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Introduction + Silly Question :)
« Reply #19 on: July 28, 2017, 10:18:41 AM »
I have split this topic as I think Rob's original question has been answered and placed the following discussion in another thread so it is dealt with as discussion, not advice to the original poster.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin: