flat assembler
Message board for the users of flat assembler.

Index > Main > org ($ and 0x00000FFF)

Author
Thread Post new topic Reply to topic
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji
Code:
.....
old = $
org ($ and 0x00000FFF) ;<--- does not compile, invalid expression Crying or Very sad

;org ($  + 0x00000FFF) ;<--- but this does compile !  Shocked 

;my_code

org old+($-$$)
.....
    

This does not compile, it's a pity, really! Crying or Very sad

_________________
I am not young enough to know everything (Oscar Wilde)- Image


Last edited by ouadji on 07 May 2011, 20:12; edited 1 time in total
Post 07 May 2011, 20:01
View user's profile Send private message Send e-mail Reply with quote
MHajduk



Joined: 30 Mar 2006
Posts: 6034
Location: Poland
MHajduk
ouadji wrote:
Code:
.....
old = $
org ($ and 0x00000FFF) ;<------ invalid expression Crying or Very sad 

;my_code

org old+($-$$)
.....
    

This does not compile, it's a pity, really! Crying or Very sad
Strange, because I have no problems with compilation of your code. Rolling Eyes
Post 07 May 2011, 20:04
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Maybe you are using a relocatable format or added fixups in a PE?
Post 07 May 2011, 20:45
View user's profile Send private message Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji
Code:

format MS COFF ;<========================

;with "MS COFF" does not compile
;without "MS COFF" does compile.

.....
old = $
org ($ and 0x00000FFF) ;<--- does not compile, invalid expression Crying or Very sad

;org ($  + 0x00000FFF) ;<--- but this does compile !  Shocked 

;my_code

org old+($-$$)
.....
    


But this does compile ... it's amazing !
Code:
format MS COFF
...
old = $
org ($ + 0x00000FFF) ; doesn't work with "and", but ok with "+"
...
org old+($-$$)
...
    

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 07 May 2011, 21:08
View user's profile Send private message Send e-mail Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
ouadji, adding a constant is supported because that is something that can be relocated, however, applying bit operation isn't as the loader/linker can only relocate by adding a new base, and not also remembering you wanted an AND operation to be performed over the "$" address.

Still, in your particular example if you specified a section with 4096 bytes alignment that would be something that could be relocated, but fasm can't realize this.
Post 07 May 2011, 21:49
View user's profile Send private message Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji
Quote:

adding a constant is supported ... however, applying bit operation ...
ok, understood, tks you Loco.
Quote:
Still, in your particular example if you specified a section with 4096 bytes alignment that would be something that could be relocated, but fasm can't realize this.

Indeed, it is!
Code:
format MS COFF

align 0x1000 ;<-----

;code

old = $
org ($ and 0x00000FFF) 

;code

org old+($-$$)

;code

    

(thank you all for your help)

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 07 May 2011, 22:07
View user's profile Send private message Send e-mail 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.