flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > WHAT IZ MACRO PLIZ |
Author |
|
revolution 07 Dec 2013, 05:51
Moved to 'Macroinstructions'
|
|||
07 Dec 2013, 05:51 |
|
system error 20 Dec 2013, 09:58
In a way, a macro can be likened to a script. It works on the source rather than on the programming 'problem'. Just like a perl or css to an html document. That's just one way to put it. a Debug is a non-symbolic kind of assembler/disassembler. "db,dw" are all macros defined by symbolic macro assemblers like FASM,MASM,NASM.
|
|||
20 Dec 2013, 09:58 |
|
DOS386 20 Dec 2013, 16:36
bit_banger wrote: Looking for a little assistance here, I've been using Debug in XP Windows for my programming,... er, what is a "MACRO" 1. AFAIK no version of DOS- or DOS-like- DEBUG supports macro's. 2. MACRO is a preprocessing feature of advanced assemblers (FASM, NASM, ...) 3. RTFM: http://flatassembler.net/docs.php?article=manual#2.3.3 |
|||
20 Dec 2013, 16:36 |
|
m3ntal 23 Dec 2013, 12:17
In essence, a macro is a sequence of code that is replaced before (and while) instructions are converted. It is like Search>Replace with parameters. For example, this movx macro can accept 2 m,m operands:
Code: macro movx a, b { if a eqtype [0] & \ ; if both a+b are [memory] operands b eqtype [0] push b ; use push+pop pop a else ; standard mov mov a, b end if } Code: movx [x], [y] ; push+pop movx eax, 1 ; mov A common obstacle for beginners is mixing if/else with equates and not understanding that they are processed on separate levels. Example: Problem: if+equ always executes: Code: b equ -1 ; create equate a=1 if a=0 ; preprocessor skips this initially b equ 7 ; < always processed end if Code: b=-1 ; create numeric constant a=1 if a=0 b=7 ; < not processed end if |
|||
23 Dec 2013, 12:17 |
|
sid123 13 Jan 2014, 13:35
Just wanted to ask a little question here,
Do macros affect binary size, does using macros mean that the size of the binary will be larger when I use macros or would it be smaller? Or no change? |
|||
13 Jan 2014, 13:35 |
|
m3ntal 13 Jan 2014, 19:49
Depends on the size of the macros, how much data+code they produce and how you use them. An incorrect use of macros can produce tons of unnecessary code (example: DexOS). If you think that a macro is "something like a function" (wrong) and you're writing routines as macros - when they should be one call to a proc/function - you'll end up with TONS of additional code. But proper use of macros by experienced programmers will make no difference in the binary size.
Macros are not for beginners. Make sure you know ASM well before learning how to use and/or write macros. |
|||
13 Jan 2014, 19:49 |
|
CampTheBoss 17 Feb 2015, 19:19
Quote: Macros are not for beginners. Make sure you know ASM well before learning how to use and/or write macros. I have used FASM for quite a while, but only just started win32 programming (done it for 6 months) after a good 2 years of DOS. About 2 weeks ago, i started using macros and they are easy. So what is hard about them? |
|||
17 Feb 2015, 19:19 |
|
revolution 18 Feb 2015, 02:17
Macros are only as difficult as you wish to make them. They can be for beginners and experts. I see no reason to scare people away from such things. We learn best by trying.
|
|||
18 Feb 2015, 02:17 |
|
baldr 20 Feb 2015, 19:46
I second it. Macros can be blessing or curse, whatever you prefer.
|
|||
20 Feb 2015, 19:46 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.