Mail Archives: djgpp/1997/12/10/00:45:42
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 -