From: "Christopher Nelson" To: Subject: Re: Some nice questions!! (one of them is silly!) Date: Sun, 27 Jun 1999 14:46:00 -0600 Message-ID: <01bec0de$10cd1120$LocalHost@thendren> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 4.71.1712.3 X-MimeOLE: Produced By Microsoft MimeOLE V4.71.1712.3 Reply-To: djgpp AT delorie DOT com >Hi all, > how are u? hope u r all very fine! > > hmmm... just some small questions... > 1) if i declare 2 global arrays as follows... > char ar1[100]; > char ar2[20]; > will djgpp ALWAYS store ar2 exactly after ar1??? > i.e. will the expression ar2[-1] always return >ar1[99]?? you should never assume that two variables are in proximate memory locations. the compiler and link-editor are under no requirement to put them next to each other. this is what USUALLY happens, but it's not safe to assume that it will ALWAYS happen. > 2) what are registers that i can safely change in >my assembler function without having to push its >values? there are no "safe" registers to manipulate. the compiler uses all the registers available for it in an optimized register allocation algorithm. if you mess with the registers in an unexpected way, you should save them, then restore them. if you are using inline assembly, you can do this after the third ':' so that the compiler knows not to expect anything in the registers that you thrash. finally, if you write a function in assembly that's prototyped as returning an int or an unsigned int, you may usually do anything you want with EAX because the compiler will expect the return value to be passed in that register. of course, if your program doesn't use the return value you can't assume what the compiler will do with the register. (most often it will just mark it dirty and reload it with whatever value it needs for the next expression resolution.) > 3) in djgpp progs, does djgpp make the register es >equal to ds?? ALWAYS?? no. DJGPP usually ignores the segment registers. after the initial initialization code, it never addresses the segment registers again, unless you do it in assembler -- or use the "farptr" routines. -={C}=-