The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Ksbunker on May 30, 2008, 04:33:45 AM

Title: Macro error(s)
Post by: Ksbunker on May 30, 2008, 04:33:45 AM
Hey,

I'm trying to play around with the MACRO capabilities of MASM, but I seem to be having some issues with the following MACRO. It fails to assemble and errors on the actuall reference to the MACRO within .CODE section, i.e. the line "antitrace @Depart".

Any help would be most appreciated.

Cheers,
Ksbunker

antitraceCALL MACRO @Label

  call @F:
db 68h
  @@:
pop eax
push @Label
pop eax
mov ebx, eax
push ebx
ret
db 68h

   ENDM

.data

  pszText db "anything...", 0

.code

start:

  antitraceCALL @Depart

  db 4 dup(90h)

@Depart:
  Invoke MessageBox, 0, ADDR pszText, 0, 0
  Invoke ExitProcess, 0

end start
Title: Re: Macro error(s)
Post by: PBrennick on May 30, 2008, 05:38:26 AM
Yeah ...

I think trying to use a label in that manner is going to be problematic.

Paul
Title: Re: Macro error(s)
Post by: sinsi on May 30, 2008, 06:14:20 AM
  call @F:
  call @F

Title: Re: Macro error(s)
Post by: Ksbunker on May 30, 2008, 07:36:55 AM
DOH! Stupid error... Solved.
Title: Re: Macro error(s)
Post by: PBrennick on May 30, 2008, 02:12:37 PM
About the label 'thing', once in a while if things get too complex because of forward reference calculations mixed with macro expansion, you will get burned. The most frustrating thing about it is that when it happens, the error messages will NEVER make sense.

The following, in my opinion, 'may' be better. But, it is just another fun way of playing with this thing you are doing and may even give you some more clever insights...

Take a boo at this and tell me what you think


    .386
    .model  flat, stdcall
    option  casemap:none

    include \GeneSys\include\windows.inc
    include \GeneSys\include\kernel32.inc
    include \GeneSys\include\user32.inc

includelib  \GeneSys\lib\kernel32.lib
includelib  \GeneSys\lib\user32.lib

; Macros
antitraceCALL MACRO @Label

    call  @F
    db    68h
@@:
    pop   eax
    push  @Label
    pop   eax
    mov   ebx, eax
    push  ebx
    ret
    db    68h
ENDM

.data
pszText db "anything...", 0

.code

start:
    antitraceCALL Message
    invoke  ExitProcess, 0

Message proc
;---------------------------------------
.data
    db      4 dup(90h)
.code
    Invoke  MessageBox, 0, ADDR pszText, 0, 0
    ret
;---------------------------------------
Message endp

    end     start



Paul


[attachment deleted by admin]