Comments: Authenticated sender is From: rbachtel AT ghg DOT net (Rodney L. Bachtel) To: djgpp AT delorie DOT com Date: Sat, 14 Dec 1996 20:40:06 +0000 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: Re: New to DJGPP c++compiler Message-ID: <19961215025015.AAB15442@max5-41.ghg.net> Is The Great Reverend Bas out there? Hello Brennan? ;) Anyway, to answer your questions: > bastards wrote: > > > > Hi, I'm now trying the DJGPP compiler and would like to know how to inclue > > inline assembly in my programs.. Like in other C Compiler: > > > > ASM{ > > mov ax,013 > > } > > > > /*This test do nothing*/ > > > > But I think it's not the same kind of ASM in DJGPP so, anybody could tell > > me how do pass some ASM? > > > > THanks > > -- > > [bastards AT ntic DOT qc DOT ca] > if I have read the info correctly from > http://www.rt66.com/~brennan/djgpp/index.html under "Brennan's Guide to > Inline Assembly with Djgpp2" that command should look as follows - > > asm("movw $013,%eax"); Well, actually, thats pretty darn close and _will_ compile perfectly, in fact it will run perfectly. But if you have a large program it will probably crash your code. The reason? DJGPP occasionally uses the registers (eax,ebc,ecx,edx, ad nauseum) to store global data or temporary results, or anything it feels like. Therefore when you write $13 to eax, (you would use $0x13 for hex 13, btw) you need to either a) save the registers you're going to clobber before you clobber them, and restore them afterwards, or b) use extended asm syntax. The method preferred nearl 2:1 is choice b. So, to our illustration: asm("movw $013,%%eax" : : : "%eax"); Would probably serve you better in the long run. (I'm not trying to be picky, but for most things basic asm is almost useless, and if you learn it, extended asm isn't all that difficult) If you really want to use asm statements in your code, a _MUST HAVE_ is Brennan's tutorial at: http://www.rt66.com/~brennan/djgpp/index.html It teaches you most of what you need to know (the rest you can email him about privately ;) Cheers, Jeff rbachtel AT ghgcorp DOT com > > I think this is right I am stilll trying to do the same thing myself > but if this isn't right I sure would likesomeone to tell me. You also > may want to download that file and read it! > > alaric AT novia DOT net > >