What micros do you actually hate to work with?

A0922A9DEBBAA3B5822389C2 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit

snipped-for-privacy@aol.com wrote:

Li-ion battery charger in C 858 bytes of machine object code on a 68S08.

of memory.

than people making it easier for a compiler to maintain information on RAM allocation and reuse. Everytime a compiler has started it has a fresh look at how the code should be implemented this time. C compilers use the full instruction set. C compilers enforce instruction set usage including manufactures suggested practices and work arounds for silicon restrictions

that are not possible to maintain in hand written assembler.

Skip in a PIC used by compilers to avoid memory management to jump over a single instruction. Requires exact knowledge of the current instructions ROM address. The following code fragment shows an example of this at location 0088. BTFSS PCL,0 skips the next instruction if the LSbit of the LSbyte of the program counter is set. Remember that the program counter is updated before the bit is sampled

0087 A01C TLRD 0,1C 0088 9002 BTFSS PCL,0 0089 AB1C TABLRD 1,1,1C 008A 5C0A MOVPF 1C,WREG

Same code sequence but the LSbit is a 0 this time

102C A01C TLRD 0,1C 102D 9802 BTFSC PCL,0 102E AB1C TABLRD 1,1,1C 102F 5C0A MOVPF 1C,WREG

some people use assembler there are many good reasons to use compiled code.

Each instruction of a processor is encoded in C, compiled and verified to generate one instruction. For example the following fragment from the Byte Craft Freescale RS08 compiler.

0165 BB 34 ADD $34 AC += page0; // ADD 0167 B9 34 ADC $34 AC = AC + CC.C + page0; // ADC 0169 B9 34 ADC $34 AC = AC + page0 + CC.C; 016B B0 34 SUB $34 AC = AC - page0; // SUB 016D B2 34 SBC $34 AC = AC - page0 - CC.C; // SBC 016F B1 34 CMP $34 (void) AC - page0; // CMP 0171 B8 34 EOR $34 AC ^= page0; // EOR 0173 BA 34 ORA $34 AC |= page0; // OR 0175 B4 34 AND $34 AC &= page0; // AND 0177 3B 34 00 DBNZ $34,$017A if (
Reply to
Walter Banks
Loading thread data ...

Hello Rickman,

Huh? Open up a cheap appliance. Any appliance. Or TV, or guitar tuner, or remote, or toy, or ... Chances are you'll see a phenolic board in there. Phenolic boards aren't conducive to SMT stuffing. It's done but through-hole is usually preferred.

I am in agreement with Roman here. There is a reason why TI decided to also offer most of their new MSP430F2xxx series in DIP and I am sure that the reason is no hobbyist usage.

Oh, and I might have one MSP430 app coming that would be produced on one or two layer phenolic, with a F2013 in DIP package ;-)

--
Regards, Joerg

http://www.analogconsultants.com
Reply to
Joerg

Hello Rick,

MSP430F2001 MSP430F2003 MSP430F2011 MSP430F2012 MSP430F2013

Just to name a few.

--
Regards, Joerg

http://www.analogconsultants.com
Reply to
Joerg

but isn't the IC package the most expensive part in those items? I opened up a computerized chess board and, as you predicted, a phenolic board was used, with a big 6502 chip and external memory! I guess those chips are 10 cents each vs the 50 cents for an integrated microcontroller, but who knows what goes on in those volumes

Reply to
steve

vice, that a want.

admit I use

Well maybe but 5-10 is certainly possible for small projects.

n=2E

Many small projects only use an algorithm once, although its true to say there is alot of "cut and paste" which increases code size but that can be avoided .

t sure I follow the question - because they choose to ?

Its because they know you cant do anything really useful with it, you end up buying the full product.

Exactly my point, you dont need C to get something done.

Hiatchi H8, Fujusu 16lx, Mtisubishi 16whatever. Plenty more I expect.

Yes ram is a problem as well can you imagine running C on a chip with

32 bytes of it.

Reply to
cbarn24050

Hello Steve,

Sure, plastic for the package is basically an oil based product and we all know where that price is heading. It still is a drop in the bucket, somewhere in the sub-cent range.

With volume products you turn every penny around and around. I have done a few of those designs and contrary to what most engineers think this can be fun.

While SMT can be and is used on phenolic this is different when you are dealing with a board that is supported by the usual 6-8 plastic ridges yet has to stomach all the flexing from users pounding on those rubber keys. Through-hole parts hold up much better under that type of stress while even the quite forgiving SO package might "lift a leg".

--
Regards, Joerg

http://www.analogconsultants.com
Reply to
Joerg

on battery charger =A0in C 858 bytes of machine object code on a 68S08.

Not really enough detail to make any valid comment.

han a K of memory.

ounting than people making it easier for a compiler to maintain information= on RAM allocation and reuse.

No doubt it makes management easier after all thats really its main function.

Everytime a compiler has started it has a fresh look at how the code should be implemented this time. C compilers use the full instruction set.

Some compilers do.

C compilers enforce instruction set usage including manufactures suggested practices and work arounds for silicon restrictions

Maybe yours does now.

ocessors that are not possible to maintain in hand written assembler.

sed by compilers to avoid memory management to jump over a single instructi= on.

lowing code fragment shows an example of this at location 0088. =A0BTFSS = =A0PCL,0 =A0skips the next instruction if the LSbit of the LSbyte of the pr= ogram counter is set. Remember that the program counter is updated before t= he bit is sampled

Its not clear what your saying here however i'll look into it and get back to you.

that some people use assembler there are =A0many good reasons to use compi= led code.

is encoded in C, compiled and verified to generate one instruction. For exa= mple the following fragment from the Byte Craft =A0Freescale RS08 compiler.

=A0 =A0// ADD

DC

=A0// SUB

BC

// CMP

=A0 =A0// EOR

=A0 =A0// OR

=A0 =A0// AND

NZ page0,rel

If I understand this correctly you appear to be saying that your compiler can compile variable++ into inc variable. Well terrific.

Reply to
cbarn24050

I've done plenty of under 1K projects in C. Most recently a power supply controller; 700 lines of C in 660 words on a PIC. This is a high-volume, cost-sensitive system. The idea that someone could replace 700 lines of C with 66 words of assembly language is just not realistic.

Are you perhaps thinking that there is a huge C runtime that uses up

500 words of code space before you ever write a line of code? Using Hi-Tech's compiler, the size of the executable with a main() containing only an infinite loop is 6 words on the 1K part in question.

So that you can evaluate the compiler on a small project before buying it for a big project.

--
John W. Temples, III
Reply to
John Temples

This is not consistent with my experience.

C compilers are a lot better at RAM re-use than hand coders. In many cases C may be the only way to squeeze and maintain code on a small part.

w..

Reply to
Walter Banks

Hello Dimiter,

Certainly when you have to do things like wide multiplying when there is no HW multiplier and there can only be 30-40 processor cycles alotted to that part of the code.

The reason can often be summed up in a single symbol: $

Then there are logistics reasons. It's tough to find 2nd sourcing for anything but the lower-tier 8051 types. This is also one reason why I do a lot of things analog with some logic chips sprinkled in.

--
Regards, Joerg

http://www.analogconsultants.com
Reply to
Joerg

Walter Banks wrote: > snipped-for-privacy@aol.com wrote: >

Impressive, and a very good idea for a test suite.

These are for 2 byte opcodes, can you post an example for one byte opcodes ? Do you have this full RS08 test file on your web anywhere ?

-jg

Reply to
Jim Granville

Hello Ulf,

Ok, I have only used '51 family device from Atmel, don't know if there are 16-bitters in store anywhere. But your word "generally" urges me to ask you how this multiplication by 0.457358479 (Horner + CSD optimized) would be done in C on a uC without HW multiplier in less than 30 CPU clocks:

mov.w R12,R13 rra.w R13 rra.w R13 add.w R12, R13 ; X1=X*2^-2+X rra.w R13 rra.w R13 add.w R12, R13 ; X2=X1*2^-2+X rra.w R13 rra.w R13 rra.w R13 rra.w R13 add.w R12, R13 ; X3=X2*2^-4+X rra.w R13 rra.w R13 add.w R12, R13 ; X4=X3*2^-2+X rra.w R13 rra.w R13 sub.w R12,R13 ; X5=X4*2^-2-X rra.w R13 rra.w R13 rra.w R13 add.w R12, R13 ; X6=X5*2^-3+X rra.w R13 ; Final output=X6*2^-1

On an 8-bitter this would take a few more cycles but probably not more than another 10.

--
Regards, Joerg

http://www.analogconsultants.com
Reply to
Joerg

We have literally hundreds of products, done in 'C', on sub 1.5K program space MCU's. I just recently did a pretty easy port from a Freescale HC05 core to a PIC16 core with just some minor tweaks in the low level stuff. Try saying it was pretty easy to go from HC05 assembly to PIC assembly and I'll laugh my butt off. At then end of the day it comes down to what you want/like to use. I have done more than my fair share of LARGE programs in assembly and I will take a good 'C' cross compiler any day.

Jim

Reply to
James Beck

BBFAD265797307DB3B203B81 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit

Jim Granville wrote:

Reply to
Walter Banks

You have clearly never used a compiler or you wouldn't make such insane claims. Just show us one example where a C compiler couldn't get within 10x of assembler. You can't, because even the worst compiler would beat that trivially.

Modern commercial compilers always beat the average assembler programmer and are typically within 25% of the absolute optimum. They apply optimizations that assembly programmers have never even heard of, and apply them consistently on large volumes of source code even when they constantly change.

Even at the early days of C the overhead was never large - C was specifically developed to map very easily onto the target architecture. It is precisely this high efficiency that made C popular (and it still is the only choice if you want fast code).

I have written lots of highly optimized code in both C and assembler. In all cases I could get within 10-20% of the speed or size of the assembler code. As Walter showed, you can translate a piece of assembler to C line-by-line and get virtually identical code on a good compiler. You can't argue with that!

I know several examples when people moved from assembler to C (or even C++) and got significant codesize and performance improvements. Or the case where programmers had written 100K lines of assembler which became obsolete when they upgraded to a better compiler...

Wilco

Reply to
Wilco Dijkstra

I don't believe that, show us an example.

Wrong.

The efficiency of C is closely related to the average size of functions and their complexity. Large, complex functions incur slightly more overhead than small and simple functions. In large projects the number of large and complex functions increases, while they are less frequent in small projects, so the efficiency of C actually *increases* on smaller projects.

Wilco

Reply to
Wilco Dijkstra
73g2000cwd.googlegroups.com...

mpiler or you wouldn't make

No you havent, all you have done is try to hand compile some C code, naturaly you not going to do much better than a compiler.

As Walter showed, you can translate a piece of

Yeh, he translated from assembler to C and back again, what does that prove.

Now that doesnt make any sence at all.

Reply to
cbarn24050

Is that a serious question? Your assembly code *literally* translates into the C code below:

unsigned short f(unsigned short x) { unsigned short y; y = x + (x >> 2); y = x + (y >> 2); y = x + (y >> 4); y = x + (y >> 2); y = x - (y >> 2); y = x + (y >> 3); return y >> 1; }

Any decent compiler will produce something similar to what you wrote. So I agree with Ulf, the C version is faster to write (not to forget understand, maintain etc) and is almost always fast enough.

Wilco

Reply to
Wilco Dijkstra
0cwe.googlegroups.com...

fy

believe that, show us an example.

Well thats not easy but I'll try. Some years ago I was making motor controlers, a required function was to produce an internal 8 bit number representing the true rms value of the motor current. Given the instantanous value is already stored in a byte and can be updated as often as you require, compile a C code fragment to perform that funtion. if I remember correctly it was around 60bytes on an ST9 but lets see how you get on.

nd

all

he

Reply to
cbarn24050

"Joerg" schreef in bericht news:ZDTWg.13298$ snipped-for-privacy@newssvr25.news.prodigy.net...

A very bad example. This has nothing to do with C or ASM, but shows an example where you need to solve a problem with minimal resources. In which case a clever approach is needed. In C, you would have to be equally clever, so it would look more or less the same. Something like this perhaps:

register int16 twelve; register int16 thirteen;

....

thirteen=twelve; twelve=>>2; thirteen+=twelve; // X1=X*2^-2+X twelve=>>2; thirteen+=twelve; // X2=X1*2^-2+X twelve=>>4; thirteen+=twelve; // X3=X2*2^-4+X

Etcetera.

Would compile to the same assembly code. The compiler will optimize the shift by a constant to a number of single shifts, no worries about that.

Generally speaking, asm is dead. Generally, using C will produce better code in less time. Generally, with less than tiny asm projects, a C version will give you a smaller footprint. Generally, using asm is a waste of time and energy and produces lower quality code.

Now that was a stupid example.

--
Thanks, Frank.
(remove 'q' and '.invalid' when replying by email)
Reply to
Frank Bemelman

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.