flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
madmatt 16 Feb 2016, 14:50
I've converted an old opengl program to work with the new glut32 library called 'freeglut' which has a 64bit version of glut. At first, I thought my code was the problem, but discovered that it was a stack alignment problem in the 64bit proc macro.
Here is the problem area, full code can be downloaded below: Code: proc gldisplay ;local jitter:QWORD, transx:DWORD, transy:DWORD, ftemp:DWORD, viewport[4]:DWORD <- doesn't work right local jitter:QWORD, viewport[4]:DWORD, transx:DWORD, transy:DWORD, ftemp:DWORD ;<- does work right invoke glGetIntegerv, GL_VIEWPORT, addr viewport invoke glClear, GL_ACCUM_BUFFER_BIT Full code:
_________________ Gimme a sledge hammer! I'LL FIX IT! |
|||||||||||
![]() |
|
l_inc 16 Feb 2016, 15:02
madmatt
The problem is that local variable definition macros do not provide any guarantees for the alignment. In your case they don't even have to do that. But a possibility for explicit alignment specification is desirable. Here's a bit of a discussion on that. _________________ Faith is a superposition of knowledge and fallacy |
|||
![]() |
|
madmatt 16 Feb 2016, 15:23
l_inc wrote: madmatt Strange! But I didn't add or remove anything, just re-arranged. Why would one variation be aligned, and another not? _________________ Gimme a sledge hammer! I'LL FIX IT! |
|||
![]() |
|
l_inc 16 Feb 2016, 15:35
madmatt
Because the local variables are put onto the stack in the order you enumerate them. The stack at the beginning of the procedure is aligned to at least 16 bytes (because the calling convention demands that). So if you put one qword in front of viewport, than it will be aligned to 8 bytes only. And if you put 3 more dwords in front of it, than it will be aligned to 4 bytes only. _________________ Faith is a superposition of knowledge and fallacy |
|||
![]() |
|
madmatt 16 Feb 2016, 16:05
l_inc wrote: madmatt Hmmm, all right, I guess I have to keep an eye on that from now on. _________________ Gimme a sledge hammer! I'LL FIX IT! |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.