flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
revolution 05 Sep 2008, 15:04
There are three main Windows allocation functions:
HeapAlloc LocalAlloc (same as GlobalAlloc) VirtualAlloc The first two have no guaranteed alignment so for your case just allocate an extra 15 bytes and zero the last four bits of the return pointer after adding 15. VirtualAlloc is always aligned to a page boundary. |
|||
![]() |
|
t@2 05 Sep 2008, 15:19
many thanks
![]() any mention of alignment...may have missed it - will give this a blast. |
|||
![]() |
|
revolution 05 Sep 2008, 15:24
Alignment is simple to implement:
Code: ... ;eax has a memory pointer add eax,15 and eax,not 15 ;now aligned to 16 ... |
|||
![]() |
|
t@2 05 Sep 2008, 18:10
yeh thanks man - been a long time since i really worked at this level..
seems its going to take some time to readjust mentally - seeing your reply makes me feel a little dumb :/ - still i guess its always best to ask..the last time i really coded at this level was on my amiga.. while im here - is there a way to force stack alignment in a similar way? - so pushed params are aligned on 16byte boundries? - heh, no doubt this is just as simple... feel free to shoot me ![]() thanks again.. matt/t@2 |
|||
![]() |
|
LocoDelAssembly 05 Sep 2008, 18:51
Code: and esp, -16 I don't your particular context but in an EBP-based frame you could do this: Code: some_proc: push ebp mov ebp, esp and esp, -16 ; Now you have ESP aligned to a 16-byte boundary leave ret [edit]Removed unneded and memory waster "sub esp, 15"[/edit] Last edited by LocoDelAssembly on 05 Sep 2008, 19:09; edited 1 time in total |
|||
![]() |
|
edfed 05 Sep 2008, 18:54
maybe
Code: add esp,15 and esp,not 15 edit: ![]() |
|||
![]() |
|
LocoDelAssembly 05 Sep 2008, 19:08
You know, actually it should be "and esp, -16" alone, better I edit my post.
|
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.