Message-ID: <3909F231.8A8E5625@mtu-net.ru> Date: Sat, 29 Apr 2000 00:18:57 +0400 From: "Alexei A. Frounze" X-Mailer: Mozilla 4.72 [en] (Win95; I) X-Accept-Language: en,ru MIME-Version: 1.0 To: Eli Zaretskii Cc: djgpp AT delorie DOT com Subject: Re: THE CONCLUSION References: <20000427104804 DOT 5E0F1785B5 AT mtu DOT ru> <39084DC4 DOT 4F8EFB AT mtu-net DOT ru> <200004272026 DOT QAA25553 AT indy DOT delorie DOT com> Content-Type: text/plain; charset=koi8-r Content-Transfer-Encoding: 7bit X-Recipient: eliz AT is DOT elta DOT co DOT il Reply-To: djgpp AT delorie DOT com Eli Zaretskii wrote: > > So, I strongly recommend to delete it from the site, since everyone who use it > > can have my problems with inline asm. > > Instead of removing inaccurate tutorials, we should correct them. > > So please submit changes for any piece of documentation that is > available from the DJGPP site that you think needs to be corrected. Okay here goes what I want to change and explain... ----------------8<--------------- Let's move on to the input field. Constraints are just instructions you give to the compiler to handle the variables they act upon. They are enclosed in double quotes. So what does the "g" mean? "g" lets the compiler decide where to load the value of i into, as long as the asm instructions accept it. In general, most of your input variables can be constrained as "g", letting the compiler decide how to load them (gcc might even optimize it!). Other commonly used constraints are "r" (load into any available register), "a" (ax/eax), "b" (bx/ebx), "c" (cx/ecx), "d" (dx/edx), "D" (di/edi), "S" (si/esi), etc. ----------------8<--------------- "g" must be explained as a constrain that may be used for anything from the following list: eax, ebx, ecx, edx or variable in memory Using "g" for constants and addresses ("g" (&some_variable)) is a bad idea (you may learn from my trobles again :), since there are some constraints avaiable exactly for those needs: i - immediate value, 0..0xffffffff n - immediate value known at compile time. I - immediate 0..31 J - immediate 0..63 K - immediate 255 L - immediate 65535 M - immediate 0..3 (shifts that can be done with lea) N - immediate 0..255 (one-byte immediate value) O - immediate 0..32 It's a good idea to explain the "m" constraint there as well: "m" stands for memory effective address, e.g. variable. IMHO adding the "cc" (stands for condition codes e.g. (E)FLAGS bits) to the clobbered registers list would be also very good. Btw, is it true that "g" may be used for the following registers only: eax, ebx, ecx, edx? Brennan Underwood's doc states exactly this list. Does that mean that esi and edi (parhaps plus ebp) registers can not be substituted by the compiler instead of "g"? bye. Alexei A. Frounze ----------------------------------------- Homepage: http://alexfru.chat.ru Mirror: http://members.xoom.com/alexfru