News:

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

Macro error(s)

Started by Ksbunker, May 30, 2008, 04:33:45 AM

Previous topic - Next topic

Ksbunker

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

PBrennick

Yeah ...

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

Paul
The GeneSys Project is available from:
The Repository or My crappy website

sinsi

Light travels faster than sound, that's why some people seem bright until you hear them.

Ksbunker

DOH! Stupid error... Solved.

PBrennick

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]
The GeneSys Project is available from:
The Repository or My crappy website