News:

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

Main Menu

Re: Macro Definition & usage discussion + supplementary

Started by ognil, September 25, 2024, 01:13:56 PM

Previous topic - Next topic

ognil

For generic.asm I have the following small notes of his good explanations.
It is not explained in generic.asm what the following macros also do:

1. Invoke
2. ptr$(WndProc)
3. rv(LoadCursor,NULL,IDC_ARROW)
4. .if, .elseif, .endif
5. .if wParam == 1000
6. Why the second .asm file using macros is better than the first one not using macros?

The MACROS explanation needs to be changed to tell the truth.

MACROS is a deprecated method for expanding text during assembly in MASM32. Using them becomes difficult and wastes valuable time for the novice MASM64 programmer. He needs to learn in detail an obsolete high-level language (macros) and then learn MASM64.
MS MASM64 API  does not use macros and allows to programmer clean and convenient way to use COMMON blocks of code with capacity to use DIFFERENT parameters in each block starting with service word "proc" and ending with "endp".

Some forum members mistakenly put an equal sign between Newcomer and Newbie. They wasting Newbie's time with outdated Win32+Macros training without caring about Newbie's  present and future.

The third file is written in a language I do not understand and cannot comment on. Sorry! :nie:

Thank you Zedd151.
"Not keeping emotions under control is another type of mental distortion."

sinsi

ognil, I think you need to understand macros a bit better, they're not just "a deprecated method for expanding text during assembly".

There is no such thing as "MS MASM64 API" but there are two different things called "MS API" and "MASM64"

The whole point of MASM64 is to let people ignore the peculiarities of the Win64 ABI and just code.

Don't forget what the first "M" in "MASM" stands for  :biggrin:

NoCforMe

And realize that like one's choice of editor, the use of macros is what they call a religious issue, meaning that some folks have strong opinions one way or the other regarding them, and there are sometimes raging arguments over them. (I come down on the "few to no macros for me, thank you very much" side, while others, like JJ, use them frequently and make them an integral part of their code.)

Like they say, different strokes for different folks ...
Assembly language programming should be fun. That's why I do it.

ognil

Hi sinsi,

Quoteognil, I think you need to understand macros a bit better...

Interesting thought! I'm Newcomer but not a Newbie and prefer not to waste my time with some pseudo high level language that won't bring me anything in the future. I use this time to improve my C++.

Thanks for opening my eyes to what MS is, but you didn't say what you think the definition of a macro is and why it must be used in assembly programs.

I would appreciate your comment on my macro-free code here:

https://masm32.com/board/index.php?action=dlattach;attach=17529
and here:

https://masm32.com/board/index.php?action=dlattach;attach=17511

Thank you. :azn:
"Not keeping emotions under control is another type of mental distortion."

jj2007


sinsi

Quote from: ognil on September 26, 2024, 12:08:54 AMbut you didn't say what you think the definition of a macro is
That's for you to discover

Quote from: ognil on September 26, 2024, 12:08:54 AMand why it must be used in assembly programs
Where did I say that they must be used?

Quote from: ognil on September 26, 2024, 12:08:54 AMI would appreciate your comment on my macro-free code here
Macro-free? include  \masm32\include64\masm64rt.inc


NoCforMe

Quote from: ognil on September 26, 2024, 12:08:54 AM[I] prefer not to waste my time with some pseudo high level language that won't bring me anything in the future. I use this time to improve my C++

I'm in agreement here, surprisingly.
Seeing the way some people code with macros here and produce source that looks just like C, with indented if/else blocks and all, I wonder, why are they even bothering with assembly language? Why not just use C? For most purposes it's not going to be noticeably slower or anything ...
Assembly language programming should be fun. That's why I do it.

ognil

Thanks sinsi,

QuoteMacro-free? include  \masm32\include64\masm64rt.inc

Because it frames and keeps the stack aligned.
Otherwise, for each program I have to write something like:

extern __imp_MessageBoxA:qword
MessageBoxA equ <__imp_MessageBoxA>
.data
caption db "'Macbeth', specifically Act 5, Scene 5",0
text db 'Life is a tale told by an idiot, full of sound and fury, signifying nothing',0

.code
main proc frame
     push rbp
.pushreg  rbp
     sub  rsp, 010h
.allocstack 010h
     mov  rbp, rsp
.setframe rbp, 0
.endprolog
; modify the stack pointer outside of the prologue
     sub  rsp, 060h
;***********************
    xor   r9d, r9d
    lea   r8,  caption
    lea   rdx, text
    xor   rcx, rcx
    call  MessageBoxA
;***********************
add rsp, 060h
add rsp, 010h
pop rbp
ret
main endp
;***********************
end
:smiley:
"Not keeping emotions under control is another type of mental distortion."

sinsi

Quote from: ognil on September 26, 2024, 01:09:40 PMBecause it frames and keeps the stack aligned.
Yes by using prologue and epilogue macros.

As for your test program isn't that just an invoke-less copy of one of hutch's examples? Even the variable names are the same.

six_L

Hi, ognil
QuoteLife is a tale told by an idiot, full of sound and fury, signifying nothing.
Sounds fairly the philosophical words.
this showed you acknowledge it. you'r not a master of life, rather than a slave of life.
Chairman Mao said "
QuoteWherever there is oppression, there is counterattack.
"
"
QuoteFighting the sky, the earth, and people,that brings you to an endless enjoyment.
"
Say you, Say me, Say the codes together for ever.

ognil

Hi sinsi,

QuoteAs for your test program isn't that just an invoke-less copy of one of hutch's examples? Even the variable names are the same.

The example text is copy-paste-correct from "Examples" without the more important part:
WndProc                proc   
; Save 4 registers here or in global variables                     
                        mov    [rbp+16], rcx                      ; rbp+8=Return address
                        mov    [rbp+24], rdx                       
                        mov    [rbp+32], r8
                        mov    [rbp+40], r9
...
...
@Ret: 
                        lea    rsp,[rbp+8]                        ; rsp=Return address
                        lea    rax,DefWindowProc
; Restore 4 registers from here or from global variables                         
                        mov    r9, [rsp+32]
                        mov    r8, [rsp+24]
                        mov    rdx,[rsp+16]
                        mov    rcx,[rsp+8]
                        jmp    qword ptr [rax]
:smiley:
"Not keeping emotions under control is another type of mental distortion."

BugCatcher

Is call a macro or an assembler directive? Hmm.. I'm too sleepy to find out.

zedd151

#12
What sinsi said, below this post.  :toothy:

I'm using hutch's and vasily's macros, ognil Professor.

sinsi

Quote from: ognil on October 07, 2024, 05:46:58 AMGreat idea, but pls, stop using the macros in MASM64
Mate, you are using macros, hutch made invoke, prologue and epilogue macros, which rely on a shitload of other macros. If you are using masm64rt.inc then you are using macros :rolleyes:

ognil

Hi, sinsi

The creation of this site by Hutch as well as all programs and tools in it must agree the requirements and rules of  the owner - MS.
When the owner(MS) changes software requirements and rules are communicated to users.

In our case with a note in parentheses (32-bit MASM only).

It is not fair to use Hutch's authority and name now that he is no longer with us.
It can be seen that when he created the site with his tools and examples he followed all the rules and requirements of the MS.

The problem is that after him there is no one to update some of his tools (including macros) according to the changed MS rules, in other words to use rules, macros, directives, etc.
without the note (for 32-bit MASM only). :undecided:

Quote:by  zedd151:  quote from ognil


It is from MS not from ognil. :thumbsup:

"Not keeping emotions under control is another type of mental distortion."