Thread overview
DOSX Stack Alignment
Dec 12, 2001
tjulian
Dec 12, 2001
Jan Knepper
Dec 13, 2001
tjulian
Dec 14, 2001
Heinz Saathoff
December 12, 2001
When I run the DOSX program below on a plain DOS system (no HIMEM, etc), I have found that the stack is not always aligned on a 32bit word boundary. This results in slow performance times. If any command-line parameter is entered when the program is executed, the stack is always aligned on a 32bit word boundary.

I contacted Mr. Huffman in August, and he confirmed the results.


/*
** Compile: sc -mx test.c x32.lib
**
** Run on clean DOS machine.
** Execute with no commandline params for wrong alignment.
**  example: test.exe
** Execute with commandline params for proper alignment.
**  example: test.exe abc
*/
#include <stdio.h>

int main(int argc, char *argv[])
{
    int i;
    printf("\n&i=%p",&i);
    printf("\n&argc=%p   -- ",&argc);
    i = (int)&argc;
    if (i & 0x3)
        printf("Not Aligned on 32bit word\n");
    else
        printf("Aligned on 32bit word\n");
    return(0);



December 12, 2001
Could you try to compile with:
sc -mx -a4 test.c x32.lib

Jan



tjulian wrote:

> When I run the DOSX program below on a plain DOS system (no HIMEM, etc), I have found that the stack is not always aligned on a 32bit word boundary. This results in slow performance times. If any command-line parameter is entered when the program is executed, the stack is always aligned on a 32bit word boundary.
>
> I contacted Mr. Huffman in August, and he confirmed the results.
>
> /*
> ** Compile: sc -mx test.c x32.lib
> **
> ** Run on clean DOS machine.
> ** Execute with no commandline params for wrong alignment.
> **  example: test.exe
> ** Execute with commandline params for proper alignment.
> **  example: test.exe abc
> */
> #include <stdio.h>
>
> int main(int argc, char *argv[])
> {
>     int i;
>     printf("\n&i=%p",&i);
>     printf("\n&argc=%p   -- ",&argc);
>     i = (int)&argc;
>     if (i & 0x3)
>         printf("Not Aligned on 32bit word\n");
>     else
>         printf("Aligned on 32bit word\n");
>     return(0);

December 13, 2001
-a4 is the default alignment for 32bit compilations. I added -a4 anyway and the alignment problem remained. The problem is not with my program's alignment, the problem is with the stack alignment when main() is called from the x32 start up code.

Mr. Huffman has sent to me a patch of the x32 libraries, which seems to have fixed the problem.

Jan Knepper wrote in message <3C177768.41E51A5F@smartsoft.cc>...
>Could you try to compile with:
>sc -mx -a4 test.c x32.lib
>
>Jan
>
>
>
>tjulian wrote:
>
>> When I run the DOSX program below on a plain DOS system (no HIMEM, etc),
I
>> have found that the stack is not always aligned on a 32bit word boundary. This results in slow performance times. If any command-line parameter is entered when the program is executed, the stack is always aligned on a
32bit
>> word boundary.
>>
>> I contacted Mr. Huffman in August, and he confirmed the results.
>>
>> <listing snipped>
>


December 14, 2001
tjulian schrieb...
> When I run the DOSX program below on a plain DOS system (no HIMEM, etc), I have found that the stack is not always aligned on a 32bit word boundary. This results in slow performance times. If any command-line parameter is entered when the program is executed, the stack is always aligned on a 32bit word boundary.

Tested it and had the same behaviour when running with QEMM as memory manager. Thank's for this hint.

Regards,
	Heinz