On 24/03/07 20:42:02, Andrew Haley wrote: > > This is a problem. My task is to tranlate this inline asm written for MSC to > > gcc. It's from a big game (Call to Power II, CTP2). I've attached a file with > > the function that contains the code. But it won't compile withou a lot > > modifications outside the source tree. > > And you can't figure out how to provide the typedefs it needs... > > > At L131 my translation starts. It has the constrains I got it to compile with > > but segfaults then. I noticed that using any other var than tileData works > > with "m". Could it be a problem for gcc to use the double pointer here: > > Pixel16 **tileData ? > > > > The point is, if I just add -O2 to the g++ cammand, this error disappears > > without having changed anything in the code or the number of register the part > > uses. > > Sure, because gcc is optimizing, and thus it uses fewer registers. Is there then an option to gcc that lets gcc push all registers before asm so that I can use what I need without having to hope gcc lets me use all registers? > > Compiling all this with -fomit-frame-pointer: > > > > Can gcc not push all registers, and give me all seven without esp? > > > > I also tryed to use "R" instead of "m" for tileData. It compiled > > without errors even when I had specified -fPIC. > > Excellent. That one is solved, then. > > > -fPIC seems to use ebx so I pushed and poped that in my asm > > code. But when looking at the disassembly I had to see gcc used ebx > > for tileData and not ebp. > > OK. No, because it makes me a hard night to get ebx stay unclobbered and then it just uses it itself! Why can't it use ebp which I left empty for gcc because I can't directly assign it to a variable. > > > But if I specified "b" it complains about: error: PIC register > > %ebx clobbered in asm > > > > Is this a bug in gcc??? Is there a constraint just for ebp so I > > don't have to use "R" and hope it gets into ebp? > > Why do you care that it is in ebp? Why do you not allow gcc to choose > the register? You seem to want to use explicit registers in your asm, > but I can't see any reason why you want to do that. gcc usually works > better when you let gcc choose the registers. > I tried with just "r". But then gcc complains about not enough registers as it seems not wanting to use ebp and it still doesn't want to give up on ebx for PIC. Another reason is I don't know how to specify a register in the asm code that is still empty. Like in my problem I need at least one empty register apart the six preloaded ones. I use ebx there, so I can circumvent the PIC problem. Is there a way to specify an empty register without a direct name? And %dx I use because there is no way mentioned in the docs how to reduce the size when using eg %3. Lynx