News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Introduction + Silly Question :)

Started by Rob260z, July 26, 2017, 06:18:35 PM

Previous topic - Next topic

coder

Quote from: aw27 on July 27, 2017, 05:19:36 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:

.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

Quote from: coder on July 27, 2017, 05:16:24 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:

Quote from: coder on July 27, 2017, 05:16:24 AM
There are many bad guys in here, led by Hutch. You and I are the good guys  :dazzled:
:lol:

jj2007

Quote from: coder on July 27, 2017, 05:59:28 AMhigh-level stuff ... is not healthy for beginners wishing to learn X86 instruction sets (which is the heart of assembly programming anyway).

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

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--

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.