www.digitalmars.com         C & C++   DMDScript  

c++.dos.32-bits - DOSX Stack Alignment

reply "tjulian" <t t.com> writes:
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);
Dec 12 2001
next sibling parent reply Jan Knepper <jan smartsoft.cc> writes:
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);
Dec 12 2001
parent "tjulian" <t t.com> writes:
-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>
Dec 13 2001
prev sibling parent Heinz Saathoff <hsaat bre.ipnet.de> writes:
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
Dec 14 2001