News:

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

Main Menu

General question

Started by lqxpl, December 11, 2018, 11:30:35 AM

Previous topic - Next topic

lqxpl

General question about the State-of-Assembly:
Years ago, learned assembly for some damnable motorola chip.  The class was a hoot, but the language itself was pretty cut-and-dry.
I'm really unaccustomed to using a lot of macros, but they feature pretty heavily on these boards and in the masm32 material.  Is this pretty common for assembly written outside the confines of a safe, sanitized classroom?
SIGSEGV

felipe

This is really a general question so i will give an subjective opinion: Some programmers use macros for some tasks, functions, etc when they code in assembly, mostly because they can, it's helpfull, etc. Others don't. And that's all folks... :biggrin:

hutch--

Its usually the case that a beginner has no chance when dumped with a bare assembler. With the addition of working libraries you have about the equivalent of the normal runtime library that high level languages have. When an assembler is also a macro assembler it can structure data prior to assembly in very convenient ways so you get much of the convenience of a higher level language but can target specialised areas with the full power of the assembler.

jj2007

Hutch and I do not always agree but here we do :biggrin:

The question is a can of worms, a complex and controversial issue. On one side you have the "purists" who want to touch the bare metal, on the other side the "macro fans" who don't want to see a thousand times the same bare metal if the job can be done with a print "hello world". What is better? Check the results: See what both sides produce in terms of usable applications 8)

hutch--

Here is a quick example for you, manually calling a simple API function and calling it with a macro. They produce identical code as per the disassembly below but the second is a lot easier to read and faster to code.

You need to look where an assembler has its advantages, it is not in calling an API function but in being able to code bare mnemonic code where performance matters. API and similar high level code is just junk that has to be done to get basic things done and this is where using a macro saves you time hacking through a mountain of junk to get a task done so you can then write mnemonic code for pure performance reasons.

I have seen over and over again that people who start the old way with a bare assembler never get off the ground as writing the barest runtime library is a task beyond most. Starting with a pre-written runtime library, include and library files you can get off the ground and write working software. Once you are up and running and familiar with the assembler you can start to write the serious stuff which is algorithms in bare mnemonics, anything from text and image manipulation, animation, big hit data crunching, in fact whatever you need as once you have the freedom of a running assembler that you are familiar with.

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    include \masm32\include64\masm64rt.inc

    .data
      text db "MessageBox Text",0
      titl db "Title",0

    .code

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

entry_point proc

  ; --------------
  ; coded manually
  ; --------------
    mov r9, MB_OK
    lea r8, titl
    lea rdx, text
    mov rcx, 0
    call MessageBox

  ; ------------------
  ; coded with a macro
  ; ------------------
    rcall MessageBox,0,"Quoted Text","Title",MB_OK

    .exit

entry_point endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    end

felipe

Quote from: jj2007 on December 11, 2018, 07:49:34 PM
What is better? Check the results: See what both sides produce in terms of usable applications 8)

I don't think this is faire, not all members here have the same time to code, nor the same knowledge of the windows api, etc. And as for me, i don't get paid for it...  :P

lqxpl

I appreciate all of the responses!   :greenclp:

By day, I write software in a pretty high-level language, when we need speed they might ask me to write a C DLL.  That is to say, I"m familiar with the struggle between clever-n-fast vs maintainable.  If that is largely the motivation behind macro-ing in assembly, I feel much more comfortable plugging on.  Thank you all.
SIGSEGV

LordAdef

Hi lqxpl,

My 2 cents here...
I have limit time to code and sometimes am forced to stay away for a while.

I could be coding in C... But, you know what... I fell in love for MASM.

It's hard, but it is actually simple (in a away) because you deal with straight issues. AND... I always forget the bloody ;;;;;;;;;;;;
Sometimes, the lack of some specific libraries and the hassle to find your way around is a bit of an arse, but that's life. AND.. We have these monsters here at the forum to deal with our stupid questions with a great deal of patience :greenclp: .

I couldn't be happier coding in masm, regardless of everything else.

aw27

Macros are sort of inline functions, so they contribute to speed sacrificing size.
For beginners, the use of 3rd party macros, no matter how useful they are, is a trade off between learning how to cook our own meals and purchase some fast food in the supermarket.