flat assembler
Message board for the users of flat assembler.

Index > Main > jmp trouble

Author
Thread Post new topic Reply to topic
Grenader



Joined: 11 Dec 2003
Posts: 3
Grenader
fasm dont compile code like this ("invalid use of symbol"):
Code:
jmp dword 0   ; or any other address
    

why?
Post 11 Dec 2003, 18:22
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3500
Location: Bulgaria
JohnFound
It works for me.
Maybe you should post bigger snippet from your code.

Regards.
Post 11 Dec 2003, 19:11
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Grenader



Joined: 11 Dec 2003
Posts: 3
Grenader
may be, you write
Code:
jmp dword [0]
    

i'm use fasmw 1.50, and "jmp dword 0" not work.
Post 11 Dec 2003, 19:33
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7724
Location: Kraków, Poland
Tomasz Grysztar
It works, but perhaps you are using PE output format, which is a relocatable format by default. In case of relocatable formats such instruction cannot be encoded correctly, so fasm generates an error. You may also find this thread helpful in that case, there is a solution for this problem based on assumption, that you won't include relocations in your PE file.

And if you are creating one of the object formats, like COFF or ELF, you cannot make such instructions at all, because those formats have to be relocatable in any case.


Last edited by Tomasz Grysztar on 11 Dec 2003, 19:41; edited 1 time in total
Post 11 Dec 2003, 19:41
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3500
Location: Bulgaria
JohnFound
Well, you can see the version, source and the result:


Description:
Filesize: 5.11 KB
Viewed: 9331 Time(s)

demo0.gif


Post 11 Dec 2003, 19:41
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Grenader



Joined: 11 Dec 2003
Posts: 3
Grenader
Thanks!
Post 11 Dec 2003, 20:09
View user's profile Send private message Reply with quote
AMD64



Joined: 19 Sep 2003
Posts: 8
AMD64
Wouldn't it be better to detect if you have defined a relocation section (in PE format), and if not, generate the code correctly?
Post 12 Dec 2003, 10:07
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7724
Location: Kraków, Poland
Tomasz Grysztar
The only solution would be to restart the assembly completely with new settings when the relocation section is detected (and then it still would fail, as it may happen that someone is putting fixups inside the conditional blocks and the conditions changes between those passes). Perhaps it's possible, but would need some huge changes in PE formatter - I'm not sure whether macro solution is not just a simpler one.

And, BTW, in general you shouldn't use such insctructions in PE format, and you should include relocations, even though non-relocatable PE programs used to work on most of the Win32 systems (AFAIK, except for the Win32s).
Post 12 Dec 2003, 11:03
View user's profile Send private message Visit poster's website Reply with quote
AMD64



Joined: 19 Sep 2003
Posts: 8
AMD64
Ok...
Then, how about adding a nonrelocatable flag that you can use with the format directive (at least for PE format)?

I'm not sure how much changes would it require, as I don't know the FAsm code that well... not too much I guess, just ignore the fixups when the flag is set.

Anyway it's not a very large issue, and you can use macros to get around it, so...
Post 13 Dec 2003, 09:08
View user's profile Send private message Reply with quote
Betov



Joined: 17 Jun 2003
Posts: 98
Betov
Hi Priv. Are you saying that, under Win32s, PE.exe(s) require Reloc?

If yes, where did you got the info from, and (... excuse me, but i don't know of it...) is there another name for "Win32s". What OS flavour is this?


Betov.
Post 13 Dec 2003, 09:23
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7724
Location: Kraków, Poland
Tomasz Grysztar
Betov: No, relocations are not required for PE executable, but if the system is not able to load program at its default address, it needs relocations to execute it, and such program just won't work if it doesn't include relocations. So it is much safer to generate PE with relocations, and earlier fasm version were even generating .reloc section automatically even if it hadn't been declared in source.
And Win32s is the overlay for Windows 3.11 that allowed to run Win32 programs (those were WinNT programs only those days) on that system. Perhaps it was also a base for later kernels of Win95/98/Me series, but since Win95 it was capable of loading every program at default base 400000h, while Win32s wasn't.

AMD64: Yes, that would be a solution, but since the same thing can be easily achieved with macros, I don't consider it really worth the effort. But if it happens to me that I can add such feature on the occasion of some other formatter changes, I'll do it.
Post 13 Dec 2003, 09:53
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. Also on YouTube, Twitter.

Website powered by rwasa.