delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/12/10/00:45:42

Date: Wed, 10 Dec 1997 07:39:09 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: djgpp AT delorie DOT com
cc: Ed Leiby <eiby AT frontiernet DOT net>, "Alan M. Doerhoefer" <aland AT seanet DOT com>
Subject: Re: Intermittent Run-Time of DJGPP App under Win95
Message-ID: <Pine.SUN.3.91.971210073552.9593A-100000@is>
MIME-Version: 1.0

On Nov 30, 1997 Ed Leiby wrote:

> I am now fairly sure that alignment has something to do with the
> slowdowns I have been seeing. I went into the above-mentioned
> correlation routine and got the "address" ( with & operator ) of some
> local variables and printed them out to screen ( after being cast to int
> ). Every time that the app was in slow mode, the local variables were
> not aligned on 4 byte boundaries. Everytime the app was moving fast,
> these local vars were aligned on 4 byte boundaries. When I went into the
> correlation routine and made the offending dynamic vars static, the app
> started running faster and with no intermittencies.

It turns out that the current DJGPP startup code doesn't ensure that
the stack is aligned on the 4-byte boundary.  Charles Sandmann
suggested to change the crt0 module; the patch is attached below.
(The line with the `+' at its left marging is the addition.)

You need to apply this patch, compile it with "gcc -c crt0.S" (note
the capital `S': it is significant), copy the resultant crt0.o to your
lib subdirectory, then relink the program that you used to test the
speed.  

Please tell here if after this change, the program runs at consistent
speed (hopefully, the fast one ;-).  If it does, this change will go
into the next DJGPP release.  (If the patch works, remember to compile
gcrt0.S as well, to prevent surprises when profiling the code.)

*** src/libc/crt0/crt0.S~0	Sun Oct  6 02:19:30 1996
--- src/libc/crt0/crt0.S	Tue Dec  9 09:10:10 1997
***************
*** 263,268 ****
--- 263,269 ----
  	je	no_memory
  	movl	%eax, ___djgpp_stack_limit	/* Bottom of stack */
  	addl	__stklen, %eax
+ 	andb	$0xfc, %al		/* make it 4-byte aligned */
  	movw	%ds, %dx		/* set stack */
  	movw	%dx, %ss
  	movl	%eax, %esp

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019