News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Strange behaviour of macros

Started by Yuri, September 18, 2010, 10:20:52 AM

Previous topic - Next topic

Yuri

Apparently this should be OK:

macro1(arg1, arg2) MACRO
    mov eax,arg1
    mov edx,arg2
ENDM


CODE SECTION

Start:
    macro1([eax+4], 0)
    ret


But it produces an error:
Quote
GoAsm.Exe Version 0.56.8 - Copyright Jeremy Gordon 2001/9 - JG@JGnet.co.uk

Error!
Line 10 of assembler source file (macro.asm):-
Use square brackets to address memory, ADDR or OFFSET to get address:-
mov edx,arg2

If I swap the arguments and write macro1(0, [eax+4]), it assembles OK.

However, if I add one more argument to the macro:

macro1(arg1, arg2, arg3) MACRO
    mov eax,arg1
    mov edx,arg2
    mov ecx,arg3
ENDM


CODE SECTION

Start:
    macro1(0, [eax+4], 0)
    ret


I get another error:
Quote
Error!
Line 11 of assembler source file (macro.asm):-
Unexpected material after end of square brackets:-
mov edx,([eax+4])

donkey

Hi Yuri,

This is definitely a bug, Jeremy will have to address it. For the time being push/pop should work.

Edgar
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Yuri


donkey

Hi Yuri,

Sorry, I was incorrect the bug extends to push/pop as well. However it only seems to be present when the first parameter is complex, ie [eax+4], for example using [eax] as the first parameter does not throw an error.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Yuri

Yes, you are right, I also noticed that. Unfortunately, I need to pass complex ones, members of a structure with the base address in a register.

Odd error. In fact, this must be plain substitution, just take what I wrote, omit leading/trailing spaces and paste what remains. Why does it matter — [eax] or [eax+4]?