X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f From: luisllo AT alumni DOT uv DOT es (Luis) Newsgroups: comp.os.msdos.djgpp Subject: Help with extended inline asm (or I'm stupid) Date: 28 Feb 2002 08:57:51 -0800 Organization: http://groups.google.com/ Lines: 41 Message-ID: <6124b64f.0202280857.5d8c4dda@posting.google.com> NNTP-Posting-Host: 80.25.146.7 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1014915471 11870 127.0.0.1 (28 Feb 2002 16:57:51 GMT) X-Complaints-To: groups-abuse AT google DOT com NNTP-Posting-Date: 28 Feb 2002 16:57:51 GMT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Hi all! I need to save the fpu state in order to be able to make a context switch, in a multi-thread package I'm writting. I know how to do it in assembler with a small function __obt_flags: movl 4(%esp),%eax #eax has the buffer address fsave (%eax) ret I think that works fine, but I'm trying to do it with extended inline asm, inside my c code while compiling with djgpp's gcc. So I wrote a c function like this int obt_flags (char* buffer) { asm ( "fsave %0\n\t" : // no outputs : "m" (buffer) : "memory" ); } void main(void) { char buffer[108]; obt_flags(buffer); printf("%s\n",buffer); } It compiles fine, but when executing it crashes with a sigsev FAULT, when executing the print instruction. Does anyone have any idea about where is the problem?, I guess it's something very stupid, but I don't know how to fix it. Thanks in advance!