- mixing C and assembly
- Posted by Hans-Bernhard Bröker on April 27th, 2008
Chris H wrote:
Actually, no, that's not the point under discussion. The point is this,
and only this statement taken from your post of 2008-04-26, 07:36h+0100h:
I rejected exactly that statement, as written, and you think I
shouldn't. I haven't seen any argument to support that statement.
Instead you (and Walter) argue against things I didn't say.
Yes, compilers users produce good code faster than assembler users.
But that doesn't mean compilers produce faster code than assembler.
There is no code a compiler can "produce" that an assembler couldn't, so
it's impossible for them to have the rigid advantage claimed by the
quoted statement.
- Posted by Didi on April 27th, 2008
Hans-Bernhard Bröker wrote:
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
http://www.tgi-sci.com
------------------------------------------------------
http://www.flickr.com/photos/didi_tg...7600228621276/
Original message: http://groups.google.com/group/comp....6?dmode=source
- Posted by CBFalconer on April 28th, 2008
Chris H wrote:
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]: <http://cbfalconer.home.att.net>
Try the download section.
** Posted from http://www.teranews.com **
- Posted by CBFalconer on April 28th, 2008
Walter Banks wrote:
(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]: <http://cbfalconer.home.att.net>
Try the download section.
** Posted from http://www.teranews.com **
- Posted by Mark Borgerson on April 28th, 2008
In article <4815376D.EF541A20@yahoo.com>, cbfalconer@yahoo.com says...
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.
- Posted by Chris H on April 28th, 2008
In message <MPG.227ee89292430b1798983f@newsgroups.comcast.net >, Mark
Borgerson <mborgerson@comcast.net> writes
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 /\/\/\/\/
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
- Posted by Pertti Kellomäki on April 28th, 2008
CBFalconer wrote:
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
- Posted by Walter Banks on April 28th, 2008
CBFalconer wrote:
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..
- Posted by Neil Cherry on April 29th, 2008
On Fri, 25 Apr 2008 00:08:56 +0200, David Brown wrote:
I've written the startup code in C on the SDCC compiler and the small
C comiler. Basically the compiler did nothing and I had to do
everything. I basically wouldn't use this for professional work but
it was simple enough and I just managed everything.
--
Linux Home Automation Neil Cherry ncherry@linuxha.com
http://www.linuxha.com/ Main site
http://linuxha.blogspot.com/ My HA Blog
Author of: Linux Smart Homes For Dummies
- Posted by Albert van der Horst on May 8th, 2008
In article <4813D4E6.44B6D3BE@yahoo.com>,
CBFalconer <cbfalconer@maineline.net> wrote:
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 http://home.hccnet.nl/a.w.m.van.der....hlecture5.html
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
- Posted by Albert van der Horst on May 9th, 2008
In article <seCdnTwTA7tRdZLVnZ2dnUVZ_gmdnZ2d@visi>,
Grant Edwards <grante@visi.com> wrote:
<SNIP>
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
- Posted by Grant Edwards on May 9th, 2008
On 2008-05-09, Albert van der Horst <albert@spenarnc.xs4all.nl> wrote:
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!!
- Posted by David Brown on May 9th, 2008
Grant Edwards wrote:
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.
- Posted by Grant Edwards on May 9th, 2008
On 2008-05-09, David Brown <david@westcontrol.removethisbit.com> wrote:
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
- Posted by David Brown on May 9th, 2008
Grant Edwards wrote:
"Protein folding" - that's like cooking a steak on top of the box?