writing efficient code PIC microcontrollers

Status
Not open for further replies.

joeyd999

Joined Jun 6, 2011
5,237
Here we go again...... the monthly slanging match. Assy Vs C...
Max, I wasn't going even going to participate in this thread until I read this:

Assembly you need an IQ of 150+ to make an complex algorithm.

That's why they made C (to keep you from going insane)...
There are good reasons to use C.
There are good reasons to use .asm.

The OP asked about making the *most efficient* code, not the easiest. In this case, .asm wins hands down.

But, again, only children and stoopid heads use .asm.
 

takao21203

Joined Apr 28, 2012
3,702
The C compiler produces ASM all you need to do is to make it produce good ASM or even better ASM than by a human programmer.

ditch efficiency, fast chips are cheap these days, people spend 8 Euro on a fast food meal in the city, easily spend 50 Euro/day just for eating/commuting.

Where's the point cutting 5 cents?
 

Chalma

Joined May 19, 2013
54
I'm in the states, and to be honest electronics is very cutthroat (especially with mass production). If the company I work for can save 5 cents multiplied over 10k units just to keep competitive, we would consider it a viable option. Now as a hobbiest, I could care less over 5 cents. Things are so tight nowadays, especially when you can get cheap stuff from *insert you know what country* (yes I know the quality sucks but most companies can and WILL outsource)
 

takao21203

Joined Apr 28, 2012
3,702
Fine. From this point forward, I will do things your way.

One condition: I get to charge you a nickle for each PIC based product I ship. Hope you got deep pockets...
If you observe retail prices + compare them to distributor prices you see where most of the money goes- straight into the pockets of landlords.

If manufacturing something would cost 0.56 or 0.59 dollars does not make a difference. The discount retailers would sell it at 2 Euro the others between 4.98 and 14.98

Where you can cut prices these days is by the way of the business plan- do it the ALDI way: Dont invest in expensive shelves and decoration, just put pallets with boxes, let the customers pick up boxes so you dont have to dispose them off. Dont stockpile things that dont sell or dont sell much.

Or sell online.

If you buy retail you pay the landlord renting out the shop space + you pay the staff who wander around and dont really know all that much.

TESCO Ireland has changed already- first they introduced self service tills, then today I saw one of their supermarkets has removed all cashiers, only a booth left with a few staff.

You can observe good pricing because of that.

Optimizing a firmware is only relevant when you want to mass produce a few thousand at least + use blank dies. Before of that, labour costs and logistics will be the largest proportion of all costs.
 

takao21203

Joined Apr 28, 2012
3,702
The OP asked about making the *most efficient* code, not the easiest. In this case, .asm wins hands down.
That would depend on unspoked thus unstated assumptions about how "efficient" is defined.

joeyd: 15%? 20%? Moar?

And no fair comparing to a de-optiomizing compiler such as the free XC8.
When will people stop with that nonsense? The optimizing compiler wont neccessary improve anything, it depends what kind of source code you write.

It can also be quite bad for some complex firmwares, as it will render them non functional. This already happens if you turn on any optimization.

For a good source code, it will shove a few percents. you can factor out a lot and change the spelling, optimize for the MCU, so you dont use constructs that arent supported natively.

If you dont like the extra instructions inserted into for loops, factor them out?

I mean, you are probably a pro, but there are countless amateurs whining how bad and rubbishy the free compiler would be, and it is just not true.
 

joeyd999

Joined Jun 6, 2011
5,237
If you observe retail prices + compare them to distributor prices you see where most of the money goes- straight into the pockets of landlords.

If manufacturing something would cost 0.56 or 0.59 dollars does not make a difference. The discount retailers would sell it at 2 Euro the others between 4.98 and 14.98

Where you can cut prices these days is by the way of the business plan- do it the ALDI way: Dont invest in expensive shelves and decoration, just put pallets with boxes, let the customers pick up boxes so you dont have to dispose them off. Dont stockpile things that dont sell or dont sell much.

Or sell online.

If you buy retail you pay the landlord renting out the shop space + you pay the staff who wander around and dont really know all that much.

TESCO Ireland has changed already- first they introduced self service tills, then today I saw one of their supermarkets has removed all cashiers, only a booth left with a few staff.

You can observe good pricing because of that.

Optimizing a firmware is only relevant when you want to mass produce a few thousand at least + use blank dies. Before of that, labour costs and logistics will be the largest proportion of all costs.
You've got all the answers, takao. I suggest you risk your own cash and test out some of your ideas. Let me know how it works out for you.

You make the assumption that my coding in .asm puts me at a disadvantage (in what way, I cannot devine from your posts). To the contrary, my skill at achieving maximal performance from minimal hardware in the shortest amount of time is a decidedly competitive advantage. My products have 10x the functionality of my competitors at the same or a lesser price.

Keep in mind, I design, develop, and manufacture commodity products. You'd think that my customers wouldn't mind paying an extra nickle, but that math changes when there exists acceptable competing product that will save them that nickle.
 

Eric007

Joined Aug 5, 2011
1,158
And we missed you!

Actually, this thread made me think of you, as you can see from one of my above posts. No one has taken up the challenge.

Welcome back.
Yes Sir! you even linked to that thread...:D got to finish that some day... interresting one!
 

takao21203

Joined Apr 28, 2012
3,702
You've got all the answers, takao. I suggest you risk your own cash and test out some of your ideas. Let me know how it works out for you.

You make the assumption that my coding in .asm puts me at a disadvantage (in what way, I cannot devine from your posts). To the contrary, my skill at achieving maximal performance from minimal hardware in the shortest amount of time is a decidedly competitive advantage. My products have 10x the functionality of my competitors at the same or a lesser price.

Keep in mind, I design, develop, and manufacture commodity products. You'd think that my customers wouldn't mind paying an extra nickle, but that math changes when there exists acceptable competing product that will save them that nickle.
maybe, maybe. One for sure if you are a learned till clerk, you are obsolete since recently.
 
Status
Not open for further replies.
Top