flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > Alignment with explicit address/label |
Author |
|
Tomasz Grysztar 07 Mar 2012, 11:28
Maybe like this?
Code: macro align value,addr=$ { local base,size base = addr-size size = ((base+value-1)/value*value-base) db size dup 90h } |
|||
07 Mar 2012, 11:28 |
|
LostCoder 07 Mar 2012, 11:38
Tomasz, YES! You make me happy! Thanks a lot!
|
|||
07 Mar 2012, 11:38 |
|
Tomasz Grysztar 07 Mar 2012, 11:44
It doesn't really work with $ value though, the complete macro should be:
Code: macro align value,addr=$ { local base,size if addr>$ base = addr-size size = ((base+value-1)/value*value-base) db size dup 90h else db ((addr+value-1)/value*value-addr) dup 90h end if } |
|||
07 Mar 2012, 11:44 |
|
16bitPM 03 Oct 2012, 16:42
I don't understand this. Why didn't the first code work? Afterall the manual has an example like this:
Code: macro align value { rb (value-1)-($+value-1) mod value } And why did the second and third work? They contain a circular reference (base is dependent on size and vice versa). And finally, why didn't you work with the mod operator? |
|||
03 Oct 2012, 16:42 |
|
Tomasz Grysztar 03 Oct 2012, 17:20
16bitPM wrote: I don't understand this. Why didn't the first code work? Code: db ((someloop+15)/16*16-someloop) dup (90h) somefunc: nop ; some instructions someloop: Code: somefunc = (someloop+15)/16*16-someloop someloop = somefunc + c 16bitPM wrote: And why did the second and third work? They contain a circular reference (base is dependent on size and vice versa). 16bitPM wrote: And finally, why didn't you work with the mod operator? |
|||
03 Oct 2012, 17:20 |
|
tripledot 19 Sep 2013, 14:05
Serious necrophilia here. Sorry. I've been away for a long time; work dragged me into C++ land
Anyway, I'm struggling to get this explicit-address-alignment to work with MS COFF format ("Invalid use of symbol"). Applying the rva operator willy-nilly doesn't seem to fix things. Any ideas? |
|||
19 Sep 2013, 14:05 |
|
l_inc 19 Sep 2013, 21:28
tripledot
Quote: Applying the rva operator willy-nilly doesn't seem to fix things. That's because rva seems to return a value unknown at compile time of the MS COFF and thus requiring a relocation: the value will be known after linking. In other words rva $ relativeto 0 is false. What you could do is to subtract $$ instead of applying the rva operator. And don't forget to set the section alignment at least as large as the largest alignment you apply. _________________ Faith is a superposition of knowledge and fallacy |
|||
19 Sep 2013, 21:28 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.