flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
revolution
Nameless wrote: it starts the next declared data from the next address of memory thats divisible by 4 |
|||
![]() |
|
Nameless
thanks
![]() my learning is being accelerated, as i go further things gets kinda easier ![]() |
|||
![]() |
|
Tomasz Grysztar
One detail: after "g" there should be a "0", because you have byte of such value defined at the end of your string. So it really should be "0" and two "x" instead of three "x".
|
|||
![]() |
|
edfed
align fills the empty bytes with NOP (90h), not X, but really nops.
because align can be used inside code to align huge instructions, it can speed up the code to do so, because nops are frequentlly ignored in recent X86. a formula for align can be that: Code: Align: ;input: ;eax = boundary parameter = 2^N ;es:edi = current offset before align ;return: ;eax = count of bytes 'NOPed' ;es:edi = current offset after align push ecx edx edi ;save trashed registers xor ecx,ecx ;ecx=0 mov cx,es ;ecx=es shl ecx,4 ;ecx*16 add edi,ecx ;edi = linear adress xchg eax,edi ;eax=linear adress, edi=bound param xor edx,edx ;expand eax to unsigned qword for div div edi ;offset/bound param mov ecx,edx ;ecx=modulus = count of bytes to nop mov al,90h ;al=opcode for nop pop edi ;restore offset rep stosb ;nop bytes mov eax,edx ;eax=count of bytes noped pop edx ecx ;restore trashed registers ret ;quit |
|||
![]() |
|
bitRAKE
We also see variations of ALIGN. Sometimes it is desired to have other data fill the gap. Data might compress better, or be more secure after encryption, etc...
Code: db $ and 1 dup 0 ; same as align 2 Code: dw (512-$+$$)/2 dup $AA55 ; pattern fill Code: times (4-$) and 3 db $FF There is much to be said about run-time alignment, but I'll leave that for another post... ![]() |
|||
![]() |
|
revolution
bitRAKE wrote: FASM's default behavior is to put NOPs in the code sections, and ? (0) in the data sections. |
|||
![]() |
|
mindcooler
90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 ...
|
|||
![]() |
|
bitRAKE
revolution wrote:
![]() (Maybe, there was a discussion regarding this?) Code: macro ALIGN0 n { ; assuming (n) is a power of two rb (n-$) and (n-1) } |
|||
![]() |
|
mindcooler
All I ever saw was 90 90 90 90 everywhere.
But I do not use sections. |
|||
![]() |
|
revolution
bitRAKE wrote: Did that change, ... The alignment code does not know what section attributes the align is assembled within. Besides, not all file formats have separate data and code sections. Not all file formats have sections. Anyhow, it is easy to test what really happens. |
|||
![]() |
|
bitRAKE
I just did,
Code: rb 3 align 16 rb 123 align 16 rb 256 |
|||
![]() |
|
Tomasz Grysztar
fasm's ALIGN generates bytes that have value 90h and are marked as uninitialized at the same time.
Thus if they occur in the data that is not included in the output file (like large uninitialized block at the end of PE section, or any uninitialized data at the end of binary format file) they are not included in output either; however when they happen to be in the output, they always have value 90h each. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.