mixing C and assembly

aller code than assembler.

And you will not. I have been trying to get some reasonably sized code example to be put for comparison to something similar that I have written using my VPA for years, all I have been given has been general babble.

Walter certainly knows what he is doing and what he claims is that you can write anything in C (if I got it right), I doubt he would claim one can write better code in C than in assembly. What he says (again, if I got that right) there is no code you can write in assembly which you could not reproduce exactly in C using his compiler (meaning getting the same object code). Makes sense, certainly you can extend any language to say anything you can say in any other language. Whether going through all the C hoops to achieve that is worth it is a completely different matter.

That can be true in some cases. Which assembler? x86? Of course. PIC or some similar mess? Sure. Any assembler? Well, if the purpose is to output "hello world" then it is again a "yes". But try to beat my time on a larger project which I will do using VPA and my libraries - no C coder I have encountered has a vague chance. And it is not because I am so much better, it is because of the tools I have (created).

They could, if the assembler programmer writes poor code. Apart from the cases where they recognize some widely popular pieces of code and insert a well written piece of assembly code, they have no chance against a good programmer, of course. But OTOH how many good programmers are walking around nowadays for whom this is valid...?

High level languages are good if one needs to use a system for a short while. If one will spend his working time within a system, though, they are only in the way of the user. In other words, you can learn a few phrases in a foreign language and be fine with them as a tourist in the respective country over the weekend or so, but if you intend to live in that country and work there as a journalist you better learn the language...

Dimiter

------------------------------------------------------ Dimiter Popoff Transgalactic Instruments

formatting link

------------------------------------------------------

formatting link

Original message:

formatting link

Reply to
Didi
Loading thread data ...

... snip ...

Most people simply admit that inability to read something largely inhibits the ability to criticize it. :-)

--
 [mail]: Chuck F (cbfalconer at maineline dot net) 
 [page]: 
            Try the download section.

** Posted from http://www.teranews.com **
Reply to
CBFalconer

... snip ...

(above diddled to reduce vertical space, shouldn't affect meaning) (If it does that is a serious effect)

OK. But you should be aware that opening the receiver to accept html mail allows all sorts of evil monsters to sneak in on many systems. Text is safe.

Now this shows the fall-thru. Yet, as far as I can see, the C source has no way to control it. A foo call here exercises foobar, and a bar call is independant. I am not doubting that you can do it - I just don't see how you can control it. Are you making some sort of extra requirement for prototypes? Are you doing some sort of possible path analysis? What if we put foo, bar, and foobar in one c file, and main in another? For example:

void bar(void) {NOP();) void foo(void) {NOP();} void foobar(void) {NOP(); bar();}

maybe with some extrn definitions. No prototypes needed for the file, only for linkage. The generated code can be:

void foobar (void) {

0100 9D NOP NOP(); bar(); } void bar (void) { 0101 9D NOP NOP(); 0102 81 RTS } void foo (void) { 0103 9D NOP NOP(); 0104 81 RTS }

and the loader can drop the code for foo, because it is never called. However there are differences in source order for C compatibility and for _easy_ fall-thru detection. Note that source and object are in different order.

--
 [mail]: Chuck F (cbfalconer at maineline dot net) 
 [page]: 
            Try the download section.


** Posted from http://www.teranews.com **
Reply to
CBFalconer

I would guess that path analysis is possible---unless you have functions called with function pointers. My recollection of

8051 C compilers from the 90's is that they did a lot of analyis to allow variable overlays. Call path analysis seems of comparable complexity.

A decade or so back, I used the Keil 8051 C compiler on a project for one of the smaller variants. I had done earlier projects with assembler, but I wanted to take advantage of the compiler overlay capability to maximize variable space and to take advantage of some of the math library routines. IIRC, the CPU had only 2K flash (89C2051).

At that time, IIRC, it was pretty much a "burn and learn" process as I didn't have a JTAG debugger comparable to the systems I use (and enjoy) for the MSP430 today.

Mark Borgerson

Reply to
Mark Borgerson

Now I do worry... "burn and .Learn"? The Keil system has one of the best simulators for 8051 there is.

For the 8051 family there are only a couple of oddballs with the Jtag debugger on them. Professionals would use an Emulator. They were not expensive and gave full vision and control of the MCU.

--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills  Staffs  England     /\/\/\/\/
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
Reply to
Chris H

[...]

But surely the C compiler has the freedom to emit the same code as the assembly programmer did? I don't know if any compiler would do it, but if this was a frequent enough case to optimize, it does not seem too hard to do.

--
Pertti
Reply to
Pertti Kellomäki

There is no need to control it. C is a way to describe the problem and compiler is responsible for code generation.

As a program evolves the compiler/linker on each build have an opportunity to start over and create new code based on the requirements embodied in the source.

w..

Reply to
Walter Banks

Apparently you don't know the first thing about compiler optimisation. This trick is called tail optimisation and is a standard technique, with all respect to Walter Banks, who implemented this technique neatly. See also

formatting link

I'm a good assembler programmer myself, and I don't find Banks claim extravagant, though a little provocative.

Groetjes Albert

--

--
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- like all pyramid schemes -- ultimately falters.
albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst
Reply to
Albert van der Horst

Going from the first to the second is a standard optimisation technique called strength reduction (with regard to an address calculation).

A good compiler knows that those are equivalent and do the picking for you.

That is a good advice. You can learn something. However ... Did you look at some Itanium code or SEAforth code lately? Did you learn something or did you awake with a headache?

Groetjes Albert

--

--
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- like all pyramid schemes -- ultimately falters.
albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst
Reply to
Albert van der Horst

True. One doesn't always have the pleasure of using a good compiler. :)

Can't say that I have.

What I'm usually looking at are pretty standard CISC micros like the H8 or MSP430, or vanilla RISC CPUs like the ARM or NIOS2.

Never had a chance to embed an Itanium in anything.

--
Grant Edwards                   grante             Yow! Here I am in the
                                  at               POSTERIOR OLFACTORY LOBULE
                               visi.com            but I don't see CARL SAGAN
                                                   anywhere!!
Reply to
Grant Edwards

I was once involved in a prototype for a very large power supply. Because of its odd design, it had a high minimum output current, so in idle we had to burn off about 800W. We used a panel oven, but an embedded Itanium would have given a more compact solution.

Reply to
David Brown

The worlds first power supply that runs protien folding simulations while idle...

--
Grant Edwards                   grante             Yow! Now, let's SEND OUT
                                  at               for QUICHE!!
                               visi.com
Reply to
Grant Edwards

"Protein folding" - that's like cooking a steak on top of the box?

Reply to
David Brown

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.