flat assembler
Message board for the users of flat assembler.

Index > Main > What's wrong with this code? FASM bug maybe?

Author
Thread Post new topic Reply to topic
alorent



Joined: 05 Dec 2005
Posts: 201
alorent
Hello,

I have create a small test to demostrate the error that I'm having.

This is the code:

Code:
format PE GUI 4.0
entry start

include 'win32a.inc'

; define our macro

macro MY_MACRO
{

    local   jmp_label

    jmp     jmp_label

    mov ebx, ebx

    jmp_label:

}

; code starts here

section '.text' code readable executable

  start:
        call    MyProc
        ret

; My test proc

proc MyProc

 push  eax

 jmp     .Exit

 mov ecx, ebx

 MY_MACRO

.Exit:

 pop eax
 ret

endp    


The above produces error "Error: undefined symbol MyProc.Exit". If I just comment the line "MY_MACRO" it works fine. Of course, this is quite a dummy macro and example to demostrate the error.

Is this a FASM bug? Because under MASM it works fine.

Thanks!
Post 02 Nov 2009, 12:44
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17269
Location: In your JS exploiting you and your system
revolution
The labels need to be local to the outer procedure. Use a dot before the macro local labels.
Code:
macro MY_MACRO {
    local .jmp_label
    jmp .jmp_label
    mov ebx, ebx
    .jmp_label:
}    
Post 02 Nov 2009, 12:47
View user's profile Send private message Visit poster's website Reply with quote
alorent



Joined: 05 Dec 2005
Posts: 201
alorent
Thanks a lot revolution!

I thought that the "local" inside the macro should do all that work.

Thanks!
Post 02 Nov 2009, 18:35
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17269
Location: In your JS exploiting you and your system
revolution
local in macros makes the label local to the macro only, that is, the label is internally make unique with a suffix. This is different from procedural localised labels (with a leading dot).
Post 03 Nov 2009, 01:05
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.