flat assembler
Message board for the users of flat assembler.
![]() Goto page 1, 2 Next |
Author |
|
vid
hi, can't find good old align macro.
i just need to formula to calculate, how many bytes to fill to align something to some given value ![]() |
|||
![]() |
|
LocoDelAssembly
bytesToFill = $ mod alignValue ?
|
|||
![]() |
|
vid
no, byt maybe alignval - ($ mod alignval) seems a little better, except case when $ mod alignval is 0. I want that elegant form from old align macro
![]() |
|||
![]() |
|
Quantum
(($ + alignval - 1) and -alignval) - $
BTW, what happened to good old align directive? |
|||
![]() |
|
vid
it's not for FASM coding. i just needed algorithm.
good not-that-old align directive is still working |
|||
![]() |
|
vid
it's not for FASM coding. i just needed algorithm.
good not-that-old align directive is still working thanks |
|||
![]() |
|
Quantum
And not-that-good (unless I'm the only one missing howto insert a custom byte value instead of the predefined 90h). Nops look kind of weird inside a data block.
|
|||
![]() |
|
Tomasz Grysztar
Section 2.2.5 contains of fasm's manual an example how you can customize the alignment in any way you want. It's quite easy to make into macro.
And the so-called "good old align macro" you can find as one of the first examples in the 2.3.3 section. I know, nobody reads it, but it still contains a few useful things, you know. ![]() |
|||
![]() |
|
Quantum
2 locodelassembly and Tomasz Grysztar:
I already knew that, but thanks anyway. The point is I never asked for a macro solution. align is a directive, not a macro. I don't like macros at all. But that's only my very humble personal opinion. 2 locodelassembly: Quote:
People usually store uninitialized data in a block storage space section (BSS) or any other virtually extended (bss-like) place of another section (data/text). So, I'm not sure I understand your tip. |
|||
![]() |
|
vid
Quote: I know, nobody reads it, but it still contains a few useful things, you know. because we don't know what remained and what has changed. i don't want to read entire 200kb pure text file to find 0.05% of new things... |
|||
![]() |
|
Tomasz Grysztar
Actually the "align" macro was there for all the time, even in the previous manual.
|
|||
![]() |
|
amcl
Quantum wrote:
Sorry my response is offtopic, useless and pedantic, but BSS stands for 'Block Started by Symbol'. http://en.wikipedia.org/wiki/.bss |
|||
![]() |
|
Quantum
2 amcl:
Quote:
That's what many people believe (including D. Ritchie). But I prefer the former definition (mentioned somewhere by M. Pietrek). Oh, and never trust a wiki ![]() |
|||
![]() |
|
LocoDelAssembly
Quote:
That is because my english is terrible. I'd tried to say that never use my align macro on code sections because it will pad with zeroes which is a problem if those zeroes gets executed. And about the second macro (which has the same problem with code section unless you use a valid single byte opcode as customval or not pass a customval), the problem is if you have a source like this: Code: macro align alignval, customval { if customval eq align alignval else times (($ + alignval - 1) and -alignval) - $ db customval end if } db 1 align 16, 0 |
|||
![]() |
|
Quantum
2 locodelassembly:
Quote:
I see know. Well, a piece of padding code not intended to be executed should be filled with 0xCC bytes instead of 0x90's. At least MS VC guys think so. Quote:
That was clear from the beginning. Another little minus goes to macros ![]() Quote:
I whouldn't say that. Mine is worse. Mi español es un poco mejor. What really matters is that we finally understood each other. |
|||
![]() |
|
shism2
There was someone on this forum who made a macro which calculates the necessary alignment. I don't remember who and how to find it. But it was on here before.
|
|||
![]() |
|
LocoDelAssembly
Yep but the problem is that align is normally used to align loops where the preceding bytes will normally get executed.
Code: mov ecx, someValue align 16 .loop: dec .loop jnz .loop The bytes between "mov ecx, someVal" and .loop (if any) will be executed so apropiate opcodes are requiered here. Anyway good point about $CC, it could be used when you align PROCs. Si no has entendido dime y seguimos por PM en español así no te confundo más ![]() Regards |
|||
![]() |
|
shism2
ta hablodo a mi ?
|
|||
![]() |
|
Quantum
2 locodelassembly:
Quote:
In case of loops, nops ain't always the best solution. For example, instead of 2 consecutive nops it's more efficient to place a mov eax,eax. |
|||
![]() |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.