Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #8433
| From | David Brown <david.brown@hesbynett.no> |
|---|---|
| Newsgroups | comp.lang.c, comp.sys.raspberry-pi, comp.programming |
| Subject | Re: Compile Assembly and C files together |
| Date | 2018-03-09 17:16 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <p7uc0j$du$1@dont-email.me> (permalink) |
| References | (11 earlier) <p7tiqm$hl5$2@dont-email.me> <87muzh4nhk.fsf@LkoBDZeT.terraraq.uk> <p7tk7d$r1p$1@dont-email.me> <p7u3qu$v3u$1@dont-email.me> <9EwoC.76436$CL3.51040@fx17.am4> |
Cross-posted to 3 groups.
On 09/03/18 15:13, bartc wrote: > On 09/03/2018 13:56, Tauno Voipio wrote: >> On 9.3.18 11:30, The Natural Philosopher wrote: > >>> Even so, the method still reveals WHICH registers >>> >>> But it is not a feature of the ARM per se, merely a convention. >>> >>> I assume gcc follows it, but there is no gurantee >> >> GCC follows the ARM EABI specification: >> >> - stack on 8 byte boundaries, >> - arguments in r0 - r3 >> - return value in r0 > > > Somewhat tidier than that for x64, which varies between Windows and > Linux. Or rather, varies between Windows and everything else. (There are other OS's out there.) > Windows has the simpler one, and passes the first four arguments > in rcx, rdx, r8 and r9. <https://en.wikipedia.org/wiki/X86_calling_conventions#x86-64_calling_conventions> I don't know quite why you think Windows has a simpler calling convention here - it uses fewer registers for parameter passing, but has this bizarre "shadow space" that the caller must allocate before calling functions. And MS, having failed to learn from its previous dog's breakfast on 32-bit Windows, has two different calling conventions. Still, it is simpler than the five different conventions on Win32. > > So not only are the registers not consecutive, but they couldn't even > come up with a consistent naming scheme for the registers. > Having the registers consecutive would not make much difference. It might be useful on some platforms when using variadic functions if the compiler could use a "push multiple registers" instruction. Consistent naming would be nice, I agree. > /And/ the stack has to be kept at 16-byte alignment, even though > individual parameters (the ones that have to go on the stack, and shadow > space for the first four), are all 8 bytes each. That is, it needs to be > 16-byte aligned just before you execute 'call'. There are good reasons for having a 16-byte stack alignment. The primary ones are to improve cache line alignment, and because some SIMD instructions require larger alignment. > > Keeping track of that is a nightmare, and a real problem when writing > extensive ASM code that has to make calls to conforming functions. > That's part of the fun of writing assembly code, isn't it? The other view is that it is a good reason for programming in C instead of assembly. > Further (I don't know if this applies to ARM; does it have a separate > set of floating point registers?), floating point params need to be > passed in a corresponding floating point register instead, XMM0 to XMM3 > (here, the names /are/ consistent, and they are consecutive!). For > variadic floating point arguments, they need to be passed in both. > > Phew! And that's the easier Win64 ABI. > > I guess simplicity of the call convention wasn't a priority. > Well no, of course it was not a priority. Why should it be? Virtually no one is interested in the calling conventions - just compiler writers, people writing OS context switch routines, and the few dozen people writing assembly routines instead of using higher level languages. Efficiency of generated code was far and away the priority when AMD made the System V AMD64 ABI used by everyone except Windows. $DEITY only knows what MS's priorities were when they scrambled it and made something pointlessly different and less efficient - the only think I can think of was to make implementation of "printf" a little easier for the MSVC compiler writers.
Back to comp.programming | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Compile Assembly and C files together "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2018-03-06 19:20 +0800
Re: Compile Assembly and C files together druck <news@druck.org.uk> - 2018-03-06 13:53 +0000
Re: Compile Assembly and C files together Rob Morley <nospam@ntlworld.com> - 2018-03-06 14:59 +0000
Re: Compile Assembly and C files together David Brown <david.brown@hesbynett.no> - 2018-03-06 16:35 +0100
Re: Compile Assembly and C files together "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2018-03-06 23:01 +0800
Re: Compile Assembly and C files together ray carter <ray@zianet.com> - 2018-03-06 15:44 +0000
Re: Compile Assembly and C files together "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2018-03-07 00:07 +0800
Re: Compile Assembly and C files together Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2018-03-07 22:39 +0200
Re: Compile Assembly and C files together "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2018-03-08 18:18 +0800
Re: Compile Assembly and C files together Martin Gregorie <martin@mydomain.invalid> - 2018-03-08 12:37 +0000
Re: Compile Assembly and C files together Martin Gregorie <martin@mydomain.invalid> - 2018-03-08 13:13 +0000
Re: Compile Assembly and C files together The Natural Philosopher <tnp@invalid.invalid> - 2018-03-08 13:34 +0000
Re: Compile Assembly and C files together Martin Gregorie <martin@mydomain.invalid> - 2018-03-08 15:27 +0000
Re: Compile Assembly and C files together mm0fmf <none@invalid.com> - 2018-03-08 17:33 +0000
Re: Compile Assembly and C files together The Natural Philosopher <tnp@invalid.invalid> - 2018-03-09 09:06 +0000
Re: Compile Assembly and C files together Richard Kettlewell <invalid@invalid.invalid> - 2018-03-09 09:17 +0000
Re: Compile Assembly and C files together The Natural Philosopher <tnp@invalid.invalid> - 2018-03-09 09:30 +0000
Re: Compile Assembly and C files together Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2018-03-09 15:56 +0200
Re: Compile Assembly and C files together bartc <bc@freeuk.com> - 2018-03-09 14:13 +0000
Re: Compile Assembly and C files together Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2018-03-09 11:14 -0500
Re: Compile Assembly and C files together The Natural Philosopher <tnp@invalid.invalid> - 2018-03-09 17:44 +0000
Re: Compile Assembly and C files together David Brown <david.brown@hesbynett.no> - 2018-03-09 17:16 +0100
Re: Compile Assembly and C files together Robert Wessel <robertwessel2@yahoo.com> - 2018-03-09 11:19 -0600
Re: Compile Assembly and C files together bartc <bc@freeuk.com> - 2018-03-09 18:11 +0000
Re: Compile Assembly and C files together Robert Wessel <robertwessel2@yahoo.com> - 2018-03-09 13:41 -0600
Re: Compile Assembly and C files together David Brown <david.brown@hesbynett.no> - 2018-03-09 19:20 +0100
Re: Compile Assembly and C files together Robert Wessel <robertwessel2@yahoo.com> - 2018-03-09 13:48 -0600
Re: Compile Assembly and C files together Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2018-03-09 13:16 -0500
Re: Compile Assembly and C files together scott@slp53.sl.home (Scott Lurndal) - 2018-03-09 18:29 +0000
Re: Compile Assembly and C files together Jack Fearnley <jack@alcor.concordia.ca> - 2018-03-09 19:07 +0000
Re: Compile Assembly and C files together scott@slp53.sl.home (Scott Lurndal) - 2018-03-09 19:13 +0000
Re: Compile Assembly and C files together Michael J. Mahon <mjmahon@aol.com> - 2018-03-10 13:16 -0600
Re: Compile Assembly and C files together Martin Gregorie <martin@mydomain.invalid> - 2018-03-11 19:39 +0000
Re: Compile Assembly and C files together Michael J. Mahon <mjmahon@aol.com> - 2018-03-12 01:16 -0500
Re: Compile Assembly and C files together David Taylor <david-taylor@blueyonder.co.uk.invalid> - 2018-03-12 06:39 +0000
Re: Compile Assembly and C files together Martin Gregorie <martin@mydomain.invalid> - 2018-03-12 20:49 +0000
Re: Compile Assembly and C files together scott@slp53.sl.home (Scott Lurndal) - 2018-03-12 16:11 +0000
Re: Compile Assembly and C files together Michael J. Mahon <mjmahon@aol.com> - 2018-03-12 14:58 -0500
Re: Compile Assembly and C files together scott@slp53.sl.home (Scott Lurndal) - 2018-03-12 20:38 +0000
Re: Compile Assembly and C files together scott@slp53.sl.home (Scott Lurndal) - 2018-03-12 16:06 +0000
Re: Compile Assembly and C files together Michael J. Mahon <mjmahon@aol.com> - 2018-03-12 14:58 -0500
Re: Compile Assembly and C files together Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2018-03-09 21:27 +0200
Re: Compile Assembly and C files together The Natural Philosopher <tnp@invalid.invalid> - 2018-03-09 17:40 +0000
Re: Compile Assembly and C files together Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2018-03-09 21:30 +0200
Re: Compile Assembly and C files together Richard Damon <Richard@Damon-Family.org> - 2018-03-09 13:16 -0500
Re: Compile Assembly and C files together Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2018-03-09 21:33 +0200
Re: Compile Assembly and C files together mm0fmf <none@invalid.com> - 2018-03-09 17:40 +0000
Re: Compile Assembly and C files together The Natural Philosopher <tnp@invalid.invalid> - 2018-03-09 17:47 +0000
Re: Compile Assembly and C files together mm0fmf <none@invalid.com> - 2018-03-09 18:05 +0000
Re: Compile Assembly and C files together The Natural Philosopher <tnp@invalid.invalid> - 2018-03-09 09:05 +0000
Re: Compile Assembly and C files together Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2018-03-09 16:01 +0200
Re: Compile Assembly and C files together Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2018-03-08 17:25 +0200
Re: Compile Assembly and C files together The Natural Philosopher <tnp@invalid.invalid> - 2018-03-07 07:36 +0000
csiph-web