flat assembler
Message board for the users of flat assembler.

Index > Windows > 64BIT invoke? problem

Author
Thread Post new topic Reply to topic
@L.chemist



Joined: 08 Oct 2004
Posts: 14
Location: Russia, Vladimir, Suzdal
@L.chemist 22 May 2007, 09:10
As i understand
Code:
        invoke  Sleep, [P]
    

should be equivalent to
Code:
        sub     rsp, 0x10
        mov     rcx, [P]
        call    [Sleep]
        add     rsp, 0x10
    

But "invoke" works if "P" is local variable only.
Otherwise we get error: invalid use of symbol.
What's wrong?
Post 22 May 2007, 09:10
View user's profile Send private message Visit poster's website Reply with quote
Chewy509



Joined: 19 Jun 2003
Posts: 297
Location: Bris-vegas, Australia
Chewy509 22 May 2007, 23:08
Code:
mov     rcx, [P]    


will work fine as long as P is within +-2GB of the function. (Displacements are still limited to 32bit even in Long Mode).

However FASM doesn't know where 'P' will end up if 'P' is a global variable, it needs to use a 64bit space so that the address of 'P' can be inserted by your image loader. But since displacements are limited to 32bits, FASM will generate an error. (Can't load a 64bit value into a 32bit space).

The only way to to load a register with the location of 'P' and pass the register to the function.

eg
Code:
mov rax, P
invoke Sleep, rax    
Post 22 May 2007, 23:08
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.