Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #127472
| From | David Brown <david.brown@hesbynett.no> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Compile Assembly and C files together |
| Date | 2018-03-08 15:14 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <p7rgfr$tea$1@dont-email.me> (permalink) |
| References | (7 earlier) <NxRnC.20237$5c2.13407@fx09.am4> <p7ou2q$lt7$1@dont-email.me> <QpYnC.154946$J36.16870@fx10.am4> <p7r729$seu$1@dont-email.me> <9yaoC.224890$5c2.55848@fx09.am4> |
On 08/03/18 14:05, bartc wrote: > On 08/03/2018 11:33, David Brown wrote: >> On 07/03/18 22:00, bartc wrote: > >> If you want to use assembly along with gcc, you need to learn how to do >> it. > > This is the problem; I can't be arsed learning something so arcane, and > IMO so badly designed. (I anyway would hardly ever use it.) If you want to use it at all, learn it. If you don't want to use it, don't learn it. "Hardly ever use it" is your worst possible option. How do you manage to classify it as "arcane" and "badly designed" when you have not learned it, not used it, and clearly have not made the slightest attempt to understand it or the reasoning behind it? Don't you understand how stupid this makes you look? You have such a strong case of "not invented here" syndrome that you can't see past your own navel. I really don't care if you don't like gcc, or any other compiler that you didn't write yourself. But it bugs me that you publicly criticise tools that you know /nothing/ about, it bugs me that you try to scare people away from using good tools just because they flummox /you/. It bugs me that you give such astoundingly poor and ignorant advice to other people who come looking for /real/ help and /real/ answers. The OP came here looking for some advice. This is arguably not the ideal place for such system-specific information, but we could do a lot better if the folks that actually understand C, and can use toolchains, were able to help rather than trying to battle the ludicrous misunderstandings and prejudices that you spread. > > If specifying the interface is such a big deal, then do it with solid > looking commands rather than what looks like a random bunch of > punctuation. Or do some people take delight is mastering something that > has deliberately been made difficult and so demonstrating their > superiority? RTFM. > >> The idea is to describe to the compiler how your >> assembly interacts with the rest of the code. It works well - it has >> been around for many years, and has been copied by most of the high >> quality compilers. > > Copied out of admiration, or because they had to in order to be able to > able to compile the same code as gcc compiles? Go and ask Intel, Apple, Freescale, and other compiler writers. I would expect they followed it for both reasons. It is the second most powerful inline assembly system I know of (Diab Data compilers had a couple of other features). When you want to have a good inline assembly syntax for your compiler, why not copy such a well-known, widely used, and proven solution? > >> If /you/ think gcc has "chaotic" code generation, > > It's chaotic because the correlation between its generated code, and the > original C, can be poor when optimisation is used. I recommend you re-take your a beginners' class on C. You clearly don't know how it works. You might also want to look up the word "chaotic" in a dictionary before using it again. > >> make Usenet posts that are not just advertising your own failings. > > In my postings I highlight examples of design failings, not mine. You merely highlight your failure to understand, failure to read, failure to listen, failure to think, and - most of all - failure to appreciate that there is a world beyond you and your own needs, preferences and experiences. > >>> Some things really need to be made simpler rather than just writing >>> fatter manuals and devising extra training courses. >> >> No, there is no need to make inline assembly simpler. Doing so would >> reduce its usefulness. > > Really? I've used inline assembly for decades. My own idea of what I > consider it should be. Other people use decent compilers, partly so that they don't need to use assembly. (And when they want fast code, they /learn/ how to use their compilers.) > > If I to use gcc's version of it, with asm encoded as string constants > and all the other mumbo-jumbo, I would never have bothered. (I would > either have found a different occupation, or the nearest 6' length of > rope.) You could always have tried the same method other people use - if they need to use inline assembly with gcc, they read about it, learn about it, practice it, ask questions about it. It might take you a few hours effort, but it is hardly something to force a change in career. > >> Inline assembly is an advanced topic > > It shouldn't be, not more so than non-inline assembly. > Non-inline assembly is an advanced topic in programming too. >>> It certainly can be for interpreters. But for the other sorts of >>> projects I currently work on, inline assembly doesn't have a worthwhile >>> benefit, not for the extra trouble. >> >> That is usually the case. Assembly is for specialist needs only (or for >> fun, or education - know some assembly can make you a better C >> programmer). > > >>> But, why should there be such a difference? >>> >> >> They do different things, for different purposes. And they interact >> with other code in different ways. > > You miss my point. They are both specifying instructions for the same > processor. But they way they written is different. Yes. So what? They have different details, different additional features, different emphasis, different uses - why shouldn't there be differences in how they are usually written? > > For a start, in inline, they are within a string constant, and the > examples I've seen use concatenated strings, with each ending with > "\n\t". What a crass way of writing assembly code! > It doesn't matter to the compiler or the assembler - it just makes the listing files neater. > I can see why you need to keep examples short! As writing anything > longer would be trying. > Anything longer is rarely unnecessary. There are some situations where people use longer sections of inline assembly, such as for SIMD code taking advantage of the "weird" instructions. But that doesn't help in illustrating how the code can be written - a single instruction is far more typical. > I can't see why syntax can't written properly within a C source file > without having to pretend the whole sequence is a function call. "I can't see" - does your failure to understand automatically mean that it is gobbledegook, chaos, badly designed, overly-complex? Or does it perhaps just mean that /you/ don't understand how it works? > >> External assembly files are usually >> used for long sections of assembly > ... >> Why would I want to put that >> sort of thing in an external assembly file? Or include pointless >> prologue/epilogue code? > > Here's an example of recent inline assembly: > > threadedproc ka_return = > assem > mov word [Dsptr+ktag],0 > mov Dprog,[Dsptr+kretaddr] > mov Aframe,[Dsptr+kframeptr_low] > mov [frameptr],Dframe > > movzx A0,byte [Dsptr+kstackadj] > add Dsptr,D0 > popvar > jumpnext > end > end Since I am not familiar with any of the identifiers here, I have no idea what this is supposed to do. But I would be surprised if you can make a series of "mov" assembly statements that is more efficient that the compiler will generate. > > There are situations where you want to write more extensive asm > sequences, which are not necessarily mixed with HLL code in the function > body, but you want all the comforts of the HLL outside of the function. > > ['threadproc' means a void function with no entry/exit code; you jump to > it then jump out of it. 'dprog', 'dsptr' are macro aliases for certain > registers. popvar/jumpnext are macros. Register names A0 etc are > non-standard.] > >> If that were in a separate assembly file, using fixed registers >> according to the ABI, it would be far slower and lead to lots of >> movement of registers back and forth. With this inline assembly, the >> compiler picks the registers that are most suited. And it knows when >> registers can be re-used, when inline assembly code can be hoisted >> around loops, duplicated or eliminated, etc. > > I'm saying you can write inline assembly in a much saner form. > >> It was not a real-world tested example. > > And you've read the manual. I've read the manual for gcc inline assembly - not for the x86. I don't program significantly for x86, and I certainly don't do inline assembly for it. My ARM, PPC, AVR, msp430 inline assembly all works. > The point also stands that error messages > are not related to the source code in the .c file, but to line numbers > in the generated .s file (which on Windows is in a temporary file hidden > deep within the file system), which also turn out to be generated lines > that are hard to match up with what's in the .c file. > I have also read the manual and know how to handle that. But there is no point in telling you - you would just complain about how difficult it all is.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Compile Assembly and C files together Ilias Abrams <iliasabrams@gmail.com> - 2018-03-05 08:23 -0800
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 supercat@casperkitty.com - 2018-03-06 07:57 -0800
Re: Compile Assembly and C files together bartc <bc@freeuk.com> - 2018-03-06 16:35 +0000
Re: Compile Assembly and C files together Jorgen Grahn <grahn+nntp@snipabacken.se> - 2018-03-06 18:15 +0000
Re: Compile Assembly and C files together bartc <bc@freeuk.com> - 2018-03-06 18:51 +0000
Re: Compile Assembly and C files together Jorgen Grahn <grahn+nntp@snipabacken.se> - 2018-03-06 19:22 +0000
Re: Compile Assembly and C files together bartc <bc@freeuk.com> - 2018-03-06 19:30 +0000
Re: Compile Assembly and C files together supercat@casperkitty.com - 2018-03-06 12:31 -0800
Re: Compile Assembly and C files together scott@slp53.sl.home (Scott Lurndal) - 2018-03-06 23:05 +0000
Re: Compile Assembly and C files together David Brown <david.brown@hesbynett.no> - 2018-03-07 12:17 +0100
Re: Compile Assembly and C files together Jorgen Grahn <grahn+nntp@snipabacken.se> - 2018-03-07 16:05 +0000
Re: Compile Assembly and C files together bartc <bc@freeuk.com> - 2018-03-07 16:45 +0000
Re: Compile Assembly and C files together David Brown <david.brown@hesbynett.no> - 2018-03-07 17:54 +0100
Re: Compile Assembly and C files together Jorgen Grahn <grahn+nntp@snipabacken.se> - 2018-03-07 16:59 +0000
Re: Compile Assembly and C files together bartc <bc@freeuk.com> - 2018-03-07 17:13 +0000
Re: Compile Assembly and C files together David Brown <david.brown@hesbynett.no> - 2018-03-07 12:26 +0100
Re: Compile Assembly and C files together bartc <bc@freeuk.com> - 2018-03-07 14:25 +0000
Re: Compile Assembly and C files together David Brown <david.brown@hesbynett.no> - 2018-03-07 15:57 +0100
Re: Compile Assembly and C files together scott@slp53.sl.home (Scott Lurndal) - 2018-03-07 15:24 +0000
Re: Compile Assembly and C files together David Brown <david.brown@hesbynett.no> - 2018-03-07 17:56 +0100
Re: Compile Assembly and C files together David Brown <david.brown@hesbynett.no> - 2018-03-07 11:37 +0100
Re: Compile Assembly and C files together bartc <bc@freeuk.com> - 2018-03-07 13:11 +0000
Re: Compile Assembly and C files together David Brown <david.brown@hesbynett.no> - 2018-03-07 15:47 +0100
Re: Compile Assembly and C files together Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2018-03-07 07:31 -0800
Re: Compile Assembly and C files together bartc <bc@freeuk.com> - 2018-03-07 21:00 +0000
Re: Compile Assembly and C files together David Brown <david.brown@hesbynett.no> - 2018-03-08 12:33 +0100
Re: Compile Assembly and C files together bartc <bc@freeuk.com> - 2018-03-08 13:05 +0000
Re: Compile Assembly and C files together David Brown <david.brown@hesbynett.no> - 2018-03-08 15:14 +0100
Re: Compile Assembly and C files together bartc <bc@freeuk.com> - 2018-03-08 15:23 +0000
Re: Compile Assembly and C files together David Brown <david.brown@hesbynett.no> - 2018-03-08 23:22 +0100
Re: Compile Assembly and C files together supercat@casperkitty.com - 2018-03-08 14:40 -0800
Re: Compile Assembly and C files together Ben Bacarisse <ben.usenet@bsb.me.uk> - 2018-03-08 23:59 +0000
Re: Compile Assembly and C files together supercat@casperkitty.com - 2018-03-08 16:54 -0800
Re: Compile Assembly and C files together David Brown <david.brown@hesbynett.no> - 2018-03-09 10:37 +0100
Re: Compile Assembly and C files together Ben Bacarisse <ben.usenet@bsb.me.uk> - 2018-03-09 10:47 +0000
Re: Compile Assembly and C files together supercat@casperkitty.com - 2018-03-09 09:19 -0800
Re: Compile Assembly and C files together David Brown <david.brown@hesbynett.no> - 2018-03-09 10:23 +0100
Re: Compile Assembly and C files together bartc <bc@freeuk.com> - 2018-03-09 12:28 +0000
Re: Compile Assembly and C files together David Brown <david.brown@hesbynett.no> - 2018-03-09 16:43 +0100
Re: Compile Assembly and C files together bartc <bc@freeuk.com> - 2018-03-09 17:14 +0000
Re: Compile Assembly and C files together supercat@casperkitty.com - 2018-03-09 09:32 -0800
Re: Compile Assembly and C files together scott@slp53.sl.home (Scott Lurndal) - 2018-03-08 15:26 +0000
Re: Compile Assembly and C files together Jorgen Grahn <grahn+nntp@snipabacken.se> - 2018-03-08 19:23 +0000
Re: Compile Assembly and C files together David Brown <david.brown@hesbynett.no> - 2018-03-08 23:27 +0100
Re: Compile Assembly and C files together bartc <bc@freeuk.com> - 2018-03-08 16:17 +0000
Re: Compile Assembly and C files together David Brown <david.brown@hesbynett.no> - 2018-03-08 23:47 +0100
Re: Compile Assembly and C files together bartc <bc@freeuk.com> - 2018-03-09 11:59 +0000
Re: Compile Assembly and C files together supercat@casperkitty.com - 2018-03-07 09:13 -0800
Re: Compile Assembly and C files together scott@slp53.sl.home (Scott Lurndal) - 2018-03-07 17:42 +0000
Re: Compile Assembly and C files together supercat@casperkitty.com - 2018-03-07 10:55 -0800
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 supercat@casperkitty.com - 2018-03-09 10:12 -0800
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 supercat@casperkitty.com - 2018-03-09 11:45 -0800
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 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
Re: Compile Assembly and C files together Richard Kettlewell <invalid@invalid.invalid> - 2018-03-06 15:29 +0000
Re: Compile Assembly and C files together David Brown <david.brown@hesbynett.no> - 2018-03-06 16:38 +0100
csiph-web