Prev: IDE
Next: New NBASM IDE
From: Harold Aptroot on 13 Mar 2010 06:55 "Seebs" <usenet-nospam(a)seebs.net> wrote in message news:slrnhpmr61.6ma.usenet-nospam(a)guild.seebs.net... > On 2010-03-13, Nathan <nathancbaker(a)gmail.com> wrote: >> So we know that "return N;" is guaranteed to set the contents of EAX. > > No, we don't. > > We know that it did in a particular function compiled with a particular > compiler with particular settings for a particular target. We don't > know that it would always do the same even for this function -- it might > compile differently if it were compiled along with particular other > functions, or with different compiler flags, or... > > In short, no, it is not "guaranteed". > IIRC it would violate the ABI (no matter whether it's on windoze or linux) if the return type is int and it didn't place the return value in eax. So I would say it's guaranteed if N is an int, at least.
From: Ike Naar on 13 Mar 2010 07:05 In article <20100313125137.7dcab90b(a)maxa>, Branimir Maksimovic <bmaxa(a)hotmail.com> wrote: >On Sat, 13 Mar 2010 11:43:34 +0000 (UTC) >ike(a)localhost.claranet.nl (Ike Naar) wrote: >> In article <hnfs0b$2a2$2(a)speranza.aioe.org>, >> jacob navia <jn(a)nospam.org> wrote: >> >I have never seen any compiler unde the Intel architecture that >> >doesn't place the return value (when there is one of course, and >> >when it fits 32 bits) in the EAX register. >> > >> >Can you name a compiler or a combination of compiler+flags >> >that would place the return value in another register? >> >> Here's an example of a 32 bit value that is not returned in EAX: >> >> return 42; >> } >> >> 00000004 <_main>: >> 4: 83 ec 0c sub $0xc,%esp >> 7: e8 f4 ff ff ff call 0 <___gnu_compiled_c> >> 8: DISP32 ___main >> c: d9 05 00 00 00 00 flds 0x0 >> e: 32 .text >> 12: 83 c4 0c add $0xc,%esp >> 15: c3 ret > >This is not linked I guess. Since it calls 0 and loads in fpu stack >from 0? Indeed, it is not linked (it was compiled with gcc -c).
From: Branimir Maksimovic on 13 Mar 2010 07:29 On Fri, 12 Mar 2010 20:05:38 -0800 (PST) Nathan <nathancbaker(a)gmail.com> wrote: > On Mar 12, 3:59Â pm, Branimir Maksimovic <bm...(a)hotmail.com> wrote: > > But c++ is most closest to C still, and there is no > > other language that can successfully replace assembler > > then C. > > Before we declare this "successfully replace" status, I think we > should put it to a test. I didn't meant to write assembler, rather C. That means if you want to switch CPU just recompile, not rewrite. What would be the point anyway? By "replacing assembler" I meant in resulting code would be lightweight as I would write it in assembler, and with compiler extensions I can even dig into CPu registers;) Of course for CPu specific things, you still need assembler ;) Greets! -- http://maxa.homedns.org/ Sometimes online sometimes not
From: jacob navia on 13 Mar 2010 07:49 Ike Naar a �crit : As I said in another message, floating point values are returned in st(0)
From: jacob navia on 13 Mar 2010 16:30
Ike Naar a �crit : > Here's an example of a 32 bit value that is not returned in EAX: > > return 42; > } > > 00000004 <_main>: > 4: 83 ec 0c sub $0xc,%esp > 7: e8 f4 ff ff ff call 0 <___gnu_compiled_c> > 8: DISP32 ___main > c: d9 05 00 00 00 00 flds 0x0 > e: 32 .text > 12: 83 c4 0c add $0xc,%esp > 15: c3 ret This code doesn't correspond to the original C source code. Please tell me what compiler you used and what code you compiled. Note that floating point values are returned in st(0) |