Making Fatal Hidden Assumptions

I think that the thing about C that makes it "like (macro) assembler", for me, has nothing to do with the level of control or the low-level-ness of the feature set, although (a) that helps and (b) I think that it's been eroded a bit, over the years, so that conforming code will run on a wider variety of hardware.

The thing that's special about C (and perhaps Fortran and Forth) is that what happens is what the code says to happen, nothing more. There is very little "magic" about C. The language doesn't insert code for run-time array bounds checks (as in Pascal, Java, most others.) The language doesn't create invisible data structures to support it's object abstractions (VTables and RTT-info in C++). While you can run C code with a conservative garbage collector, like Bohem's, there isn't going to be a magic mechanism moving things around in memory behind your back. (Well, not unless you are using a particularly virulent interpretation of the standard, and something like safec that has decorated pointers of some sort.)

Even the loop constructs are basically just ways to put labels and branches into the code. They don't even constrain the form of the conditional expression, or the variant-update parts. Just labels and branches.

Yes, C does do a small amount of magic. It magically marshalls arguments onto a stack for subroutine calls, and may "promote" some along the way. Yes, it will do a block-copy for you if you do a structure assignment.

The relative lack of magic is the important factor, IMO.

(Pascal's magic level is pretty low, too, so I do agree that it's pretty close to C in this particular spectrum. Range checking is about the limit of magic, here.)

--
Andrew
Reply to
Andrew Reilly
Loading thread data ...

... snip ...

Even lower than you think, especially when the programmer has taken advantage of sub-ranges and typed everything as tightly as possible. In this case a good Pascal compiler can compute the possible range of expressions, and avoid most runtime checks. This has the minor disadvantage of not checking for hardware errors.

--
"If you want to post a followup via groups.google.com, don't use
 the broken "Reply" link at the bottom of the article.  Click on 
 "show options" at the top of the article, then click on the 
 "Reply" at the bottom of the article headers." - Keith Thompson
More details at: 
Also see
Reply to
CBFalconer

[snip]

Apparently I have failed utterly to make myself clear. I'll try one last time.

You claim that C is, in some sense, an assembly language (specifically, a "portable assembly language"). I'm assuming here that any "portable assembly language" is an "assembly language".

I claim that C is not an "assembly language", though it may bear some resemblance to one.

I am not offended by the claim, I simply disagree with it. My disagreement is based on my knowledge of the C programming language and my understanding of what is meant by the term "assembly language". (I haven't tried to provide a definition of the term myself; I might or might not make the attempt later.)

I used the word "us" simply because we are having this discussion in a public forum. Anything you post here will be read by multiple people, including me -- thus "us". Nothing more.

There should be some definition of the phrase "assembly language". If C is an assembly language, then C should meet the requirements of that definition. This line of reasoning seems obvious and unremarkable to me; do you disagree?

[...]

[...]

I agree. It does not follow from this, though, that the term "portable assembly language" is necessarily meaningful, or that it applies to C even if it is meaningful.

If someone cries "portable assembly", I can either figure out what they mean, or I can decide they're crying nonsense. I'm content to do either or both.

So, finally, what do you mean by "assembly language"?

--
Keith Thompson (The_Other_Keith) kst-u@mib.org  
San Diego Supercomputer Center               
We must do something.  This is something.  Therefore, we must do this.
Reply to
Keith Thompson

Here's what you wrote upthread:

] C was designed as a portable assembly language, the most successful so ] far, so if the term has any practical meaning, then C is that meaning. ] ] C was designed as a portable assembly language for the purpose of ] porting Unix (which then had some seven or ten installations, I ] forget, but one rumor has it there was only one, namely the PDP-7) ] more easily. That didn't fully remove the need for using actual ] assembly. But only some small parts still needed to be ] machine-specific assembly.

So you're using the term "portable assembly language" while insisting, in contradiction to ordinary English grammar, that a "portable assembly language" is not necessarily an "assembly language". ("Portable" is an adjective; "assembly language" is a noun phrase.) And yet you seem surprised that I'm having trouble figuring out what you're talking about.

I'm done here.

--
Keith Thompson (The_Other_Keith) kst-u@mib.org  
San Diego Supercomputer Center               
We must do something.  This is something.  Therefore, we must do this.
Reply to
Keith Thompson
  • Keith Thompson:

If it were as want it to be, then "portable assembly" would be a contradiction in terms... :-o

You cannot extract meaning or conclude from a self-contradiction.

By the rules of logic, that is.

Yes, you have managed to suprise me continuously. Nobody can be that stubborn, I think. And yet you come through; ignoring logic, ignoring examples, ignoring established usage, insisting that your own extremely little irrelevant subset of language rules is what "should" apply.

Well done, I might add. If not to say roasted.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Reply to
Alf P. Steinbach

Complete nonsense. Read what dmr himself writes about this: .

C was designed as a systems programming language for (then) a single, new OS, _not_ a portable assembler. In fact, that article explicitly states that a. one of the reasons that drove the evolution of C's ancestors, and later C itself, was _not_ to have to use assembler and b. portability was not yet a concern in the first days.

Ah, well, yes, if you get your information from Wikipedia, where any little fool with a complete misunderstanding of his subject can, and last time I looked at that page in fact _had_, turned an article into a mix of some seeds of fact, some serious misconceptions, and quite a bit of complete bollocks, then I'm afraid I cannot take your opinion on any subject seriously, certainly not on C.

Richard

Reply to
Richard Bos

This is a fallacy known as "Appeal to Ridicule". To quote one source:

This sort of "reasoning" is fallacious because mocking a claim does not show that it is false. This is especially clear in the following example: "1+1=2! That's the most ridiculous thing I have ever heard!"

Why should I read that yet again? Quote what you think is relevant.

All that is correct and irrelevant. Why do or did you think it should or would be relevant? Perhaps you're just objecting as best you can to terminology that seems frightening to you, and even appears new to you; perhaps can help?

The above is several fallacies lumped into one spaghetti fallacy. But the main top-level fallacy is known as "Poisoning the Well". Don't you think you should perhaps restrict your usage of fallacious reasoning?

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Reply to
Alf P. Steinbach

If you can't define what a term means, then it is meaningless and so it is pointless to use that term with reference to anything.

Well, you don't need to be told what you mean (I assume) so it is everyone else that needs to know in order to understand what you are trying to say.

No one has expressed any offence at the term that I've seen, they have just disagreed.

Suggesting that the people who disagree with you have an inferiority complex, on the other hand, is insulting.

All completely irrelevant to the discussion at hand.

I'll give some attributes that I consider essential to an assembler, and whether or not C has them:

- The ability to write Interrupt Service Routines - Not possible in C since there is no mechanism to specify that a routine is an ISR and some processors use different calling conventions for IRSs.

- The ability to access the status flags of the processor, including such flags as overflow flags - Not possible in C, if a calculation overflows you invoke undefined behaviour

- The ability to access IO ports on the processor - Not possible in C. You can access memory mapped devices, but not IO mapped devices.

I could go on.

Indeed, since C does not come close to any definition I would use. Also, what do you mean by "portable assembler".

BTW, I've done embedded programming, including writing interrupt service routines, accessing IO ports (as opposed to memory mapped devices), accessing memory mapped devices etc all in a few different extended versions of Pascal. So from my perspective Pascal is about as close to assembler as C is.

--
Flash Gordon, living in interesting times.
Web site - http://home.flash-gordon.me.uk/
comp.lang.c posting guidelines and intro:
http://clc-wiki.net/wiki/Intro_to_clc
Reply to
Flash Gordon

Every C compiler I've used for the last 2exp(N) years (apart from perhaps the ones for specific OSs like Windows, where I've simply not looked) has had this facility. It's not C- it's an extension, and it's very annoying that they are all different- but it's there.

Same as above.

Plus necessary constructs to direct unchanging objects to ROM, again all compilers different.

But you're right (whoever said it), it's nowt like an assembler. It's just a quick and dirty middle- level language, and to use it you really need to know the hardware yoiu're operating on in many cases.

It seems that the little embedded stuff is considered simply below the radar for the standards committees. Perhaps that's a good thing.

Paul Burke

Reply to
Paul Burke
  • Flash Gordon: > [snipped anonymous babble]

What is the question?

-- A: Because it messes up the order in which people normally read text. Q: Why is it such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet and in e-mail?

Reply to
Alf P. Steinbach

I don't think that's true, if only because you have to start with /some/ terms that don't have definitions.

Meaning is prior to definition.

Clarity and/in communication, that's the ticket.

--
Chris "sparqling" Dollin
"Who do you serve, and who do you trust?"
Reply to
Chris Dollin

You snipped the part where I pointed out that you can do all this in the various forms of extended Pascal I've used, so if you allow extensions Pascal is just as low a level language as C ;-)

Agreed. Despite my comment above, I would say that Pascal was a higher level language than C.

Well, those odd little corners in my experience are only a small fraction of the code, so I don't see it as a big issue.

--
Flash Gordon, living in interesting times.
Web site - http://home.flash-gordon.me.uk/
comp.lang.c posting guidelines and intro:
http://clc-wiki.net/wiki/Intro_to_clc
Reply to
Flash Gordon

I don't know why you call it anonymous, since I am not posting anonymously. Or if I am, it is about the worst attempt ever at being anonymous.

I wasn't asking a question, I was refuting points you raised and pointing out why C is not any form of assembler, including a portable assembler. It's not my fault if you don't understand a lot of the things I spent many years using assembler for, or the various things you cannot do in C that you can easily do in assembler.

--
Flash Gordon, living in interesting times.
Web site - http://home.flash-gordon.me.uk/
comp.lang.c posting guidelines and intro:
http://clc-wiki.net/wiki/Intro_to_clc
Reply to
Flash Gordon

Just about any language than isn't pure OO (I'm not 100% sure on that point, I just can't imaging pure Java in this role) can be extended to do this. DEC even sold an operating system written in BASIC.

So what is the point of this discussion? No language can replace assembler without extensions, any attempt to standardise a hardware layer would be doomed.

If C was intended as an assembler, the original PHP UNIX would have been pure C, which it wasn't.

--
Ian Collins.
Reply to
Ian Collins

...

i don't know what "portable assembly language" is (because for an assembly there is a cpu and "

Reply to
RSoIsCaIrLiIoA

Nonsense. C is not and cannot be an assembly language, portable or otherwise. Now *your* implementation of C might provide extensions, or you might create them yourself to access specific features of the target processor, but that is beside the point.

Standard C is not an assembly language, portable or otherwise. Anyone who thinks so has a dilute conception of assembly language.

< snipped wierd inline assembly code >
Reply to
santosh

but this seems to compile and to run here (Borland C compiler)

#include #include #include

int main(int argc, char** argv) { asm{push ebx;} /* printf("arg0=%s\n", argv[0]); */ _EBX=argv; if(!(_EBX==0)) goto c1; c0: {asm{pop ebx;} _EAX^=_EAX; return;} c1: _EBX = *(int*)_EBX; /* ebx= argv[0]*/ if(_EBX==0) goto c0; strstr((char*)_EBX, "prog.exe"); if(_EAX==0) goto c0; _EBX=_EAX; _EBX+=strlen("prog.exe"); _BL = *(char*)_EBX; if(!(_BL==0)) goto c2; {printf("i nomi sono uguali\n"); goto c3;} c2: {printf("il nome e' piu' lungo \n");} c3: goto c0; }

Reply to
RSoIsCaIrLiIoA

PLONK

--
"If you want to post a followup via groups.google.com, don't use
 the broken "Reply" link at the bottom of the article.  Click on 
 "show options" at the top of the article, then click on the 
 "Reply" at the bottom of the article headers." - Keith Thompson
More details at: 
Also see
Reply to
CBFalconer
[snip]

Please stop posting this non-portable non-standard crud in comp.lang.c.

--
Keith Thompson (The_Other_Keith) kst-u@mib.org  
San Diego Supercomputer Center               
We must do something.  This is something.  Therefore, we must do this.
Reply to
Keith Thompson

Pompous insults are Alf's usual recourse when he's confronted with someone willing to point out that his arguments are vacuous.

I haven't killfiled him because he occasionally has something worthwhile to say in technical discussions, but in an argument of this sort it's best just to ignore him. If past behavior is any indication, he'll just try to shout everyone else down until we all get tired of him and give up.

--
Michael Wojcik                  michael.wojcik@microfocus.com

The way things were, were the way things were, and they stayed that way
because they had always been that way.  -- Jon Osborne
Reply to
Michael Wojcik

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.