Searching \ for '[PIC] Why bother with Assembly?' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'Why bother with Assembly?'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] Why bother with Assembly?'
2007\03\10@144307 by Don French

picon face
I see a lot of posts on this list that indicate that people are programming in Assembly.  So, I wonder why.  Except for really tight timing situations, why not use C, which is one heck of a lot easier to write, read, maintain, etc.?  And the optimizing compilers probably do at least as good a job of saving bytes as most people can do by writing in Assembly.  So, what is the point?

-- Don

2007\03\10@150124 by olin piclist

face picon face
Don French wrote:
> why not use C, which is one heck of a lot easier
> to write, read, maintain, etc.?

Because it's not in many cases on these tiny processors.

********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014.  Gold level PIC consultants since 2000.

2007\03\10@150810 by Jan Wagemakers

face picon face
Don French schreef:

> I see a lot of posts on this list that indicate that people are
> programming in Assembly. So, I wonder why.

Because programming in assembly is fun! :-)


--
Met vriendelijke groetjes         - Jan Wagemakers -

... movl $1, %eax  ;  movl $0, %ebx  ;  int $0x80

2007\03\10@153615 by Don French

picon face
Not what???

-- Don


 ----- Original Message -----
 From: Olin Lathrop
 To: Microcontroller discussion list - Public.
 Sent: Saturday, March 10, 2007 12:02 PM
 Subject: Re: [PIC] Why bother with Assembly?


 Don French wrote:
 > why not use C, which is one heck of a lot easier
 > to write, read, maintain, etc.?

 Because it's not in many cases on these tiny processors.

 ********************************************************************
 Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
 (978) 742-9014.  Gold level PIC consultants since 2000.
 --

2007\03\10@153807 by Don French
picon face
Yeah, right.  

-- Don


 ----- Original Message -----
 From: Jan Wagemakers
 To: spam_OUTpiclistTakeThisOuTspammit.edu
 Sent: Saturday, March 10, 2007 12:08 PM
 Subject: Re: [PIC] Why bother with Assembly?


 Don French schreef:

 > I see a lot of posts on this list that indicate that people are
 > programming in Assembly. So, I wonder why.

 Because programming in assembly is fun! :-)


 --
 Met vriendelijke groetjes         - Jan Wagemakers -

 ... movl $1, %eax  ;  movl $0, %ebx  ;  int $0x80
 --

2007\03\10@154706 by Thomas C. Sefranek

face picon face

-----Original Message-----
From: .....piclist-bouncesKILLspamspam@spam@mit.edu [piclist-bouncesspamKILLspammit.edu] On Behalf Of
Don French
Sent: Saturday, March 10, 2007 2:43 PM
To: pic list
Subject: [PIC] Why bother with Assembly?

Don!

This is clearly "stirring the pot!".
Read the archives about why, it has been discussed "ad nausium",
we don't need another round of arguments.

Tom

 *
 |  __O    Thomas C. Sefranek  .....WA1RHPKILLspamspam.....ARRL.NET
 |_-\<,_   Amateur Radio Operator: WA1RHP
 (*)/ (*)  Bicycle mobile on 145.41MHz PL74.4

ARRL Instructor, Technical Specialist, VE Contact.
hamradio.cmcorp.com/inventory/Inventory.html
http://www.harvardrepeater.org


2007\03\10@155735 by William Jacobs

flavicon
face
Don,
I know assembly, I don't know c.  I have a vast library of routines
already written in assembly.  Most of my programming is cut and paste.
bill


Don French wrote:

>I see a lot of posts on this list that indicate that people are programming in Assembly.  So, I wonder why.  Except for really tight timing situations, why not use C, which is one heck of a lot easier to write, read, maintain, etc.?  And the optimizing compilers probably do at least as good a job of saving bytes as most people can do by writing in Assembly.  So, what is the point?
>
>-- Don
>
>  
>

2007\03\10@164050 by Jan Wagemakers

face picon face

Don French schreef:

>>> I see a lot of posts on this list that indicate that people are
>>> programming in Assembly. So, I wonder why.
>>  Because programming in assembly is fun! :-)
> Yeah, right.  

I'm serious. After a hard day at work¹ I really enjoy drinking a nice
Belgian beer and playing around with PIC's and assembly. For me PIC's are
just an hobby, so having fun is what drives me.

On a PIC I have never tried other programming-languages, so I can't comment
on that ;-)


[¹] <www.janw.dommel.be/tmp/jan_at_work.jpg>
--
Met vriendelijke groetjes         - Jan Wagemakers -

- Debian GNU/Linux 4.0 - Up : 46 days

2007\03\10@165455 by Don French

picon face
Having a library is a good reason, but you can link assembly code with C if you want to.   And having libraries of Assembly code is great, and I would use those libraries to the fullest when there is no C library to do the same thing.  Copy and paste is the longest and most honored of programming traditions and I fully agree with it.   But not knowing C is valid only up to a point. After all, it is extremely easy to learn C, especially compared to learning Assembly.  I know that for fact as I have written tens of thousands of lines of code in both, just not for the PIC.  But the only time I chose Assembly over C is when there was a good reason.  For example, I wrote a chess engine in 80x86 because I needed to squeeze every cycle I could out of the processor, and I pulled every trick in the book and some that weren't in the book to get those cycles because speed was of the essence in that situation.  

But unless there is a specific requirement that demands Assembly, developing in Assembly is counter productive in my humble opinion.  I have the feeling that some people do it solely to feel superior to those who don't know Assembly.  I see that attitude enough among some of the Linux fanatics to find it extremely tiresome.  Whatever is most the efficient use of my time is what is best for me.  If you code for a hobby and find the business of playing with bits and registers and memory banks fun, then sure why not.  But if you do it for a living, why make life harder than it needs to be?   Well, that is my take on it anyway.  I don't want to try to change anyone's mind.

Someone else posted that this has been discussed to death already, but I am new to the list so I missed it.  I didn't want to stir anything up, I just thought that there must be some valid reasoning behind the choice of Assembly that I wasn't aware of.  So unless someone has a reason other than "it is more fun" or "the code that I need already exists in Assembly and not in C" which are fine reasons, let's drop it.  

-- Don


 {Original Message removed}

2007\03\10@165603 by Don French

picon face

I can understand that.

-- Don


 ----- Original Message -----
 From: Jan Wagemakers
 To: EraseMEpiclistspam_OUTspamTakeThisOuTmit.edu
 Sent: Saturday, March 10, 2007 1:40 PM
 Subject: Re: [PIC] Why bother with Assembly?


 Don French schreef:

 >>> I see a lot of posts on this list that indicate that people are
 >>> programming in Assembly. So, I wonder why.
 >>  Because programming in assembly is fun! :-)
 > Yeah, right.  

 I'm serious. After a hard day at work¹ I really enjoy drinking a nice
 Belgian beer and playing around with PIC's and assembly. For me PIC's are
 just an hobby, so having fun is what drives me.

 On a PIC I have never tried other programming-languages, so I can't comment
 on that ;-)


 [¹] <www.janw.dommel.be/tmp/jan_at_work.jpg>
 --
 Met vriendelijke groetjes         - Jan Wagemakers -

  - Debian GNU/Linux 4.0 - Up : 46 days
 -

2007\03\10@170257 by Herbert Graf

flavicon
face
On Sat, 2007-03-10 at 11:43 -0800, Don French wrote:
> I see a lot of posts on this list that indicate that people are programming in Assembly.  So, I wonder why.  Except for really tight timing situations, why not use C, which is one heck of a lot easier to write, read, maintain, etc.?  And the optimizing compilers probably do at least as good a job of saving bytes as most people can do by writing in Assembly.  So, what is the point?

Well, main reasons I can see are:

- person doesn't know C (there are alot out there that don't)
- C is portable, C for PICs isn't as portable. Alot of the code you
write for PICs in C is going to only work with your compiler. Change
compiler and you'll have to make changes. On top of that, there is alot
of "hardware" level stuff you have to do with PICs (i.e. setting up an
UART) that isn't portable, different compiler, different way of doing
things.
- established ASM codebase - alot of people have been using ASM for a
LONG time, and have a codebase that covers many things, why change to C
if you already have most of the code written in ASM?
- PIC projects are often small enough not to get many benefits from an
HLL - for example a recent project I did was a "flickering candle", it's
about 20 lines of ASM, hardly worth going to C
- compiler bugs - every compiler has bugs, and debugging compiler bugs
can get very frustrating.

With all that said, I use C almost exclusively now. I write my C in ways
that lets it be portable (i.e. have an UARTInit, UARTPut and UARTGet
routine that's always called the same way, simply rewrite those three
routines to support the new hardware and off you go. I've taken C code
written for a PC and used it on the PIC, taken C code written for the
PIC and used it on a Luminary MCU. If you are careful with how you write
your C you can remain VERY portable).

I still at least get an idea for how the ASM works for a given platform,
that way when you hit a compiler bug (and you will) you'll be prepared
to sift through the ASM listing to figure out what's going on.

Alot of people stick with ASM because it's what they've always done.
That's fine, but it sure does lock them into a small subset of what's
out there IMHO. While MCU C code is relatively portable across MCUs, ASM
is almost completely not portable the moment you leave a family (i.e.
some portability can be had going from 16F to say 18F or 30F if you
write your ASM right, but switch from a PIC to an ARM and much of your
code has to be thrown away).

TTYL

2007\03\10@170422 by Herbert Graf

flavicon
face
On Sat, 2007-03-10 at 15:57 -0500, William Jacobs wrote:
> Don,
> I know assembly, I don't know c.  I have a vast library of routines
> already written in assembly.  Most of my programming is cut and paste.

All very good reasons, but what happens when you boss puts an Atmel MCU
on your desk and says "use this for this project"? I'm all for ASM, but
I found it locks you into a family too much, and I don't like that. Just
my opinion. TTYL

2007\03\10@171721 by Peter P.

picon face
Don French <dcfrench <at> gmail.com> writes:

> I see a lot of posts on this list that indicate that people are programming in
Assembly.  So, I wonder why.
> Except for really tight timing situations, why not use C, which is one heck of
a lot easier to write, read,
> maintain, etc.?  And the optimizing compilers probably do at least as good a
job of saving bytes as most
> people can do by writing in Assembly.  So, what is the point?

Anything small, requiring exact timing (as in, bit-banged peripheral drive with
fairly exact repetitive timing requirements), and not expected to migrate or
have a very long life should be done in assembly.

Most other things, likely not. Else, a last minute processor change (or even
architecture change) will become a nightmare. Most people use C which has the
advantage of being machine-close but abstract enough to allow testing modules on
workstations. Some others use macro systems, slef-made or not. Olin L. uses an
extensive macro and preprocessor system which he has develped and made available
freely.

The problem with C on micros is that it is not really C (maybe c). So one is not
really writing C, but more like using C conventions and C syntax and
reimplementing libc functions with restricted functionality as needed. C proper
has only 26 keywords and not even one IO function in the core language set, as
you know. It turns out that this is its strength.

Peter P.


2007\03\10@171900 by Scott Dattalo

face
flavicon
face
On Sat, 2007-03-10 at 13:55 -0800, Don French wrote:

> I can understand that.

What is 'that' which you understand so well?

Scott

PS. To all you assembly language lovers; this is my attempt to help you
out by diverting this thread from C-trolling to top-post-trolling.

2007\03\10@172055 by Jinx

face picon face
> what happens when you boss puts an Atmel MCU on your desk
> and says "use this for this project"? I'm all for ASM, but I found
> it locks you into a family too much, and I don't like that. Just my
> opinion. TTYL

That's true if you have a boss (that would do that, and I don't think
I'd take too kindly to it), but I'm sure many micro users aren't given
directions about which micro to use. Undoubtedly there are times
when the project is run by the engineering or accounting department.
Each to his own. I see no reason why you couldn't learn both ASM
(first) and HLL (second)

2007\03\10@172408 by Jan Wagemakers

face picon face
Don French schreef:

> But not knowing C is valid only up to a point. After all, it is extremely
> easy to learn C,

Maybe it is for you. That doesn't mean that everybody finds C an easy to
learn language.

> especially compared to learning Assembly. I know that for
> fact as I have written tens of thousands of lines of code in both, just
> not for the PIC.

Yeah, right. Dutch is an easier to learn language then English, I know that
for fact because I have done discussions in both languages ;-)


--
Met vriendelijke groetjes         - Jan Wagemakers -

... A: Because it messes up the order in which people normally read text.
   Q: Why is top-posting such a bad thing?

2007\03\10@173532 by Steve Smith

flavicon
face
When there is no budget for tools you use what's free I started with MPALC
and a text editor.....

Never bothered to change. Wrote one program on a C84 and ended up with one
empty word after optimising about 10 times to make it fit c would have
crashed and burned

Just my 2p

Seve

{Original Message removed}

2007\03\10@173759 by David VanHorn

picon face
On 3/10/07, Olin Lathrop <olin_piclistspamspam_OUTembedinc.com> wrote:
>
> Don French wrote:
> > why not use C, which is one heck of a lot easier
> > to write, read, maintain, etc.?
>
> Because it's not in many cases on these tiny processors.


At times, it's not even possible to use C on the smaller ones.
3 level hardware stack with C?  :)

Overlapping buffer spaces in a small processor?  Someone check me if I'm
wrong but I don't think C will let you do that, and if you did, I doubt you
could fit the code.

Other places, I've had to deal with over 300kInts/sec on an 8 MHz processor.

2007\03\10@173801 by Peter P.

picon face
Herbert Graf <mailinglist3 <at> farcite.net> writes:

> On Sat, 2007-03-10 at 11:43 -0800, Don French wrote:
> > I see a lot of posts on this list that indicate that people are programming
in Assembly.  So, I wonder why.
> Except for really tight timing situations, why not use C, which is one heck of
a lot easier to write, read,
> maintain, etc.?  And the optimizing compilers probably do at least as good a
job of saving bytes as most
> people can do by writing in Assembly.  So, what is the point?
>
> Well, main reasons I can see are:
>
> - person doesn't know C (there are alot out there that don't)

That is a reason I do not agree with. I don't think that one can even get hired
for an embedded job without knowing C. C is the common denominator of
programming, especially low level, and has been for 20 years. Not knowing C is
about the same as going out of fashion whenever an architecture is retired. That
happens every six months or so now.

> - established ASM codebase - alot of people have been using ASM for a
> LONG time, and have a codebase that covers many things, why change to C
> if you already have most of the code written in ASM?

Because most of the valid reasons to use the old codebase were a lot of time
spent on optimization and cleaning up things. Because C has a math package built
in (well almost, with -lm) most of the old codebase that was
calculations-related can be duplicated in 5 seconds, the time to compile an
expression. And peripherals have changed enough that old code for peripherals
makes little sense imho. I see it that way while cleaning things in my computer,
things which are 10+ years old. My code was valid then, and it worked well, but
today it's just two more lines of C buried in the rest of what I am doing, and
it's likely faster than the way I coded it then. Compilers are written by very
clever people.

> - PIC projects are often small enough not to get many benefits from an
> HLL - for example a recent project I did was a "flickering candle", it's
> about 20 lines of ASM, hardly worth going to C

What happens if you have to add a USB interface in 2 weeks ? Or port it to
something else ? C would have used about 5 lines of code for that. Would it 'not
have been worth it' ? Try to think how long it took you to make the program
work. How long would it have taken in C ?

Statistics say that American programmers produce about 50 lines of 'good' code
per day (including debug time). So your asm program should have taken almost
half a day, and the C program a tenth of a day. Afaik, the rule of thumb is to
use the highest level programming language available for the task.

> - compiler bugs - every compiler has bugs, and debugging compiler bugs
> can get very frustrating.

Yes, but so does everything else. Including one's own code. Assembly requires
5-10 times more source statements to achieve what C achieves. The programmer's
error rate is proportional to the number of lines of code he writes, not to the
language used.

> I still at least get an idea for how the ASM works for a given platform,
> that way when you hit a compiler bug (and you will) you'll be prepared
> to sift through the ASM listing to figure out what's going on.

Every man should know his compiler's output ;-)

Peter P.


2007\03\10@174813 by Byron A Jeff

face picon face
On Sat, Mar 10, 2007 at 11:43:03AM -0800, Don French wrote:

> I see a lot of posts on this list that indicate that people are programming
>in Assembly.  So, I wonder why.

Several reasons:

1) The first is simple "You love what you learn." Most folks wander into
PICs reading projects and tutorials on the Internet. Most are targeted for
16F84A parts written in assembly. Another perfect example is that many many
projects are still written is absolute assembler even though relocatable
code linked together with the linker is easier to manage.

2) C on microcontrollers is generally nonstandard. So you can't just use
a standard C, but one augmented with pragmas and other nonstandard fare.

3) Assembly is the PIC lingua franca. It's used to communicate ideas and
concepts. Most of the Tech notes and virtually all of the code in the
datasheets and the family language references are in assembly.


>  Except for really tight timing situations,
>why not use C, which is one heck of a lot easier to write, read, maintain,
>etc.?

Again debatable. Simple example: Write code that clears bit 6 of variable i.
Not so easy in standard C. Something like:

  i &= ~(1<<6);

Whereas PIC assembly has the more straightforward:

  bcf   i,6

This one point aggravated me enough that when I was working on my PIC high
level compiler I specifically added a bit select operator. In NPCI this would
be written:

  i:6 = 0;

Also C is great if you already know it. If not then you have a bit of a
learning curve to tackle.

>  And the optimizing compilers probably do at least as good a job of
>saving bytes as most people can do by writing in Assembly.  So, what is the
> point?  >

See above. It isn't cut and dried. The other issue is that each and every
high level language community is fragmented. Not everyone here knows Basic,
C, Python, Jal, and all the other languages that are around for the PIC.
Assembly is a common thread. Therefore it has value.

BAJ

2007\03\10@180210 by Peter P.

picon face
David VanHorn <dvanhorn <at> microbrix.com> writes:

> At times, it's not even possible to use C on the smaller ones.
> 3 level hardware stack with C?  :)

FYI there were versions of C that ran fine on 16F84 (f.ex. bknd C from Bengt
Knudsen Data - free version exists too). And this was in 1998 I think, and it's
still there. Yes, it was tiny C. But the ROM size was more of a limitation than
the shallow stack. There are ways to implement software stacks even where there
is no stack at all, if the code is chaperoned by a compiler or by a macro system
which always keeps track of things. Speaking of shallow stack, I think that it
is Olin L. who implemented such a software stack for his math subroutines, and
he did it in assembly.

> Overlapping buffer spaces in a small processor?  Someone check me if I'm
> wrong but I don't think C will let you do that, and if you did, I doubt you
> could fit the code.

I think that you are confusing C with Pascal ;-). C will let you do every
possible dumb thing with pointers and buffers as long as it likes your spelling
and you finish each statement with a semicolon. This is one of the reasons a lot
of people hate it at least in the beginning.

> Other places, I've had to deal with over 300kInts/sec on an 8 MHz processor.

C combines smoothly with inline assembly. That is not the problem. It is likely
that a CPU that is interrupted every 27 foreground cycles is slightly overloaded
and must be programmed using highly optimized hand-written code anyway. That
would be an assembly job.

At the same time, I used C code written in SDCC on MCS51, where the clock was
10MHz (1MIPS - 12 clock stepping old core !) and I had two concurrent timer
routines, both in C, one at 4kHz and one on external interrupt at 0.5-2kHz.
Variable. I never had a timing problem. I did worry about it and I put in some
flags to catch problems during debugging but there weren't any. C works great.
Interestingly, that program was first implemented on a PIC, in assembly, but as
I added features I switched to C. Then the C program was ported to the MCS51 in
less than 2 hours afair. I could port it back in half the time. That's the point.

Peter P.


2007\03\10@180235 by Jan Wagemakers

face picon face
Peter P. schreef:

>>> I see a lot of posts on this list that indicate that people are
>>> programming in Assembly. So, I wonder why.
[cut]
>> - person doesn't know C (there are alot out there that don't)
> That is a reason I do not agree with. I don't think that one can even get hired
> for an embedded job without knowing C.

The question was: "I see a lot of posts on this list that indicate that
people are programming in Assembly. So, I wonder why.". I don't see the word
"job" mentioned in that question. Not everybody on this list is programming
PIC's because it is his profession.


--
Met vriendelijke groetjes         - Jan Wagemakers -

- Debian GNU/Linux 4.0 - Up : 46 days

2007\03\10@180312 by Herbert Graf

flavicon
face
On Sun, 2007-03-11 at 11:20 +1300, Jinx wrote:
> > what happens when you boss puts an Atmel MCU on your desk
> > and says "use this for this project"? I'm all for ASM, but I found
> > it locks you into a family too much, and I don't like that. Just my
> > opinion. TTYL
>
> That's true if you have a boss

I've seen them, and it's not "bad" IMHO either. Anyways, it's NEVER good
IMHO to have (or be) an engineer who's only REALLY good at one thing.
You never know what the future will bring. I've been using PICs for a
long time, and are VERY comfortable with them, but I've started using
other families now, just to gain experience. There are ALOT of gotchas
out there, and it's good to be familiar with at least a few of them.

> (that would do that, and I don't think
> I'd take too kindly to it), but I'm sure many micro users aren't given
> directions about which micro to use. Undoubtedly there are times
> when the project is run by the engineering or accounting department.
> Each to his own. I see no reason why you couldn't learn both ASM
> (first) and HLL (second)

But we're not talking about LEARNING asm, we're talking about use. I
completely agree that it's a VERY good idea to learn asm for the MCU
platform you are using. You don't have to be an expert knowing every
little trick there is, but a good familiarity will come in VERY handy
when you hit your first compiler bug, or want to optimize a certain
routine.

That said, always using ASM will limit your skill set.

Consider this: you're working at a company and have ALWAYS used PICs.
For whatever reason you loose your job, don't you think it's ALOT more
useful to write on your resume:

extensive MCU experience in ASM and C, specializing in Microchip PICs

then the following:

extensive MCU experience in ASM, using Microchip PICs

Just my opinion. TTYL

2007\03\10@181434 by Peter P.

picon face
Byron A Jeff <byron <at> cc.gatech.edu> writes:

> 1) The first is simple "You love what you learn." Most folks wander into
> PICs reading projects and tutorials on the Internet. Most are targeted for
> 16F84A parts written in assembly. Another perfect example is that many many
> projects are still written is absolute assembler even though relocatable
> code linked together with the linker is easier to manage.

I agree, for hobby, ASM is the way to go, maybe followed by a free C compiler to
pick up the skills for later. I also started with ASM on PICs although I already
had almost a decade of C by then. I still like to use ASM on PICs (as opposed to
other micros where I don't). I only switched to C when projects became large and
hard to maintain, and when the idea of easy migration to other platforms
appeared. And I never looked back.

> 2) C on microcontrollers is generally nonstandard. So you can't just use
> a standard C, but one augmented with pragmas and other nonstandard fare.

Yes, but it's not so hard to work with them, or to switch imho.

> 3) Assembly is the PIC lingua franca. It's used to communicate ideas and
> concepts. Most of the Tech notes and virtually all of the code in the
> datasheets and the family language references are in assembly.

C is the lingua franca for all the remaining programming aspects on the planet,
for embedded. Almost, imho.

{Quote hidden}

On normal compilers variables of type bit (or bool) exist, and when variables
must be used in more than one way then they are declared as unions, and then you
can do something like:

    BSET(i,6,0); // BSET() will usually be a macro

or:

    i.b[6] = 0;

or:

    i.b.b6 = 0;

> Also C is great if you already know it. If not then you have a bit of a
> learning curve to tackle.

So is English ...

There is no doubt that ASM has a very high value. But many (most?) jobs are done
in higher level languages now, afaik.

Peter P.


2007\03\10@183011 by Don French

picon face
Anyone who is smart enough to program microcontrollers in Assembly is smart enough to learn C in a weekend or two as long as they avoid pointers.  Not that pointers are that hard but they do add a bit to the learning curve and are, for the most part, avoidable in microcontroller code.  Read up on if statements, for loops, while loops, the bit-wise operators, and the logical operators. Then read about creating and calling subroutines. By now you are practically an expert C programmer.  Get the free CC5X compiler and compile a C program in MPLAB that someone else wrote so you understand how to compile a working program.  Then start to modify it in small ways.  If you get compile errors that you don't understand or the program doesn't do what you expect, post it here explaining that you are trying to learn C and you will get all the help you need.  Soon you will never go back to Assembly except for very small tasks and those cases where some critical timing issue demands it or !
when you get nostalgic for the bad old days.  :-)

-- Don

=======================================
I hate bottom posting as much as you hate top posting.  Deal with it.  I do.


 {Original Message removed}

2007\03\10@183227 by stef mientki

flavicon
face

>
> At times, it's not even possible to use C on the smaller ones.
> 3 level hardware stack with C?  :)
>  
So use a decent compiler that has a software stack.

--
cheers,
Stef Mientki
http://pic.flappie.nl

2007\03\10@183614 by olin piclist

face picon face
Don French wrote:
>>> why not use C, which is one heck of a lot easier
>>> to write, read, maintain, etc.?
>>
>> Because it's not in many cases on these tiny processors.
>
> Not what???

Not easier to write, read, or maintain, obviously.

********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014.  Gold level PIC consultants since 2000.

2007\03\10@183832 by piclist2

flavicon
face
On Sat, 10 Mar 2007, David VanHorn wrote:

> At times, it's not even possible to use C on the smaller ones.

Which times are those?

> 3 level hardware stack with C?  :)

What does the hardware stack depth have to do with C?  C does not
mysteriously consume hardware stack levels.

> Overlapping buffer spaces in a small processor?  Someone check me if I'm
> wrong but I don't think C will let you do that, and if you did, I doubt you
> could fit the code.

What do you mean by "overlapping buffer spaces?"

--
John W. Temples, III

2007\03\10@183927 by stef mientki

flavicon
face

> I agree, for hobby, ASM is the way to go, maybe followed by a free C compiler to
> pick up the skills for later.
I've teached  children to program PICs.
That would never have succeeded using either C or ASM.

There's more available on this planet,
something like JAL for example,
or what about Python for PICs

--
cheers,
Stef Mientki
http://pic.flappie.nl

2007\03\10@184536 by olin piclist

face picon face
Don French wrote:
> I have the feeling that some people do it solely to feel superior to
> those who don't know Assembly.

This is clearly a pointelss religious war.  Can some admin perhaps step in
and KILL THREAD?

Yes, all assembly users are elitist snobs who want to make sure the world
knows they're superior, and all HLL programmers are lazy knuckle draggers
who can barely spell PWM and don't really want to learn anything.  There,
happy now?

Maybe that will elicit enough flames to get this thread killed, or will
someone have the good sense to do it before it gets that far?


********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014.  Gold level PIC consultants since 2000.

2007\03\10@185713 by Don French

picon face
Why do you say obviously?  I mentioned three things and you only gave one "not".

So you think that for some processors it is harder to write, read, *and* maintain C code than Assembly?   How can it be harder to do any of those things?  It seems impossible to me in all three cases, unless you just don't know C, but I am willing to listen to your reasoned explanation.  

-- Don


 {Original Message removed}

2007\03\10@190304 by Don French

picon face
Get up on the wrong side of the bed this morning, Olin?  

"some" != "all"

But they know who they are.

-- Don


 {Original Message removed}

2007\03\10@190538 by Jan Wagemakers

face picon face
Don French schreef:

>>> But not knowing C is valid only up to a point. After all, it is extremely
>>> easy to learn C,
>> Maybe it is for you. That doesn't mean that everybody finds C an easy to
>> learn language.
> Anyone who is smart enough to program microcontrollers in Assembly
> is smart enough to learn C in a weekend or two as long as they avoid
> pointers.

So, your question was "people are programming in Assembly. So, I wonder why"
and now your saying that we *must* learn C?

> Get the free CC5X compiler and compile a C program in MPLAB that someone
> else wrote so you understand how to compile a working program.

MPLAB doesn't work on the platform I use. Not that that is a problem,
because I know there exist a C-compiler for the platform I use. But let
everyone decide for himself what he is using.

You like C, good. I like assembly, also good. Some people like JAL, also
good. I don't see the problem?


--
Met vriendelijke groetjes         - Jan Wagemakers -

... To alcohol, the cause of,
   and solution to, all of life's problems.              --Homer Simpson

2007\03\10@190833 by Jan Wagemakers

face picon face
Olin Lathrop schreef:

> Yes, all assembly users are elitist snobs who want to make sure the world
> knows they're superior, and all HLL programmers are lazy knuckle draggers
> who can barely spell PWM and don't really want to learn anything.  There,
> happy now?

ROFL :-)


--
Met vriendelijke groetjes         - Jan Wagemakers -

... Fidonet : 2:292/100.19

2007\03\10@192157 by Mike Harrison

flavicon
face
On Sat, 10 Mar 2007 11:43:03 -0800, you wrote:

>I see a lot of posts on this list that indicate that people are programming in Assembly.  So, I wonder why.  Except for really tight timing situations, why not use C, which is one heck of a lot easier to write, read, maintain, etc.?  And the optimizing compilers probably do at least as good a job of saving bytes as most people can do by writing in Assembly.  So, what is the point?
>
>-- Don

No one tool fits all jobs.
There are things that are quicker and easier ( yes, easier)  to code in assembler, e.g. intensive
hardware bit-twiddling.
No compiler will ever be as code-space and/or speed efficient as a good assembler programmer - In
some cases, the lower efficiency can be due to fundamental limitations of the C language rather than
any particular compiler.
In some applications this can be very significant, although probably less so than it was a few years
ago due to lower cost of memory and higher clock speeds.

For applications at the lower end of complexity, once you have a clear idea of what you want to do
and how you plan to implement it, the difference in effort between coding it C vs. Assembler can be
surprisingly little.
 


2007\03\10@192158 by Jinx

face picon face
Don French wrote -

> I don't want to try to change anyone's mind

I see a lot of argument from the OP very much in favour of C and
pointing out why people should switch to it. If that isn't proselytic
flag-waving I don't know what is

I'm very happy with asm, being an evolutionist atheist, and loving
South Park. Good luck changing me

OL wrote -

> This is clearly a pointless religious war.  Can some admin perhaps
> step in and KILL THREAD ?

They can kill it if they want, for now Deleted Items needs feeding

Someone's tag line -

> =======================================
> I hate bottom posting as much as you hate top posting.  Deal
> with it.  I do.

I'm as comfortable with asm as you are with C, Jal, Python,
whatever. Deal with it. I do

'nuff said

2007\03\10@192632 by Don French

picon face
Who said that there was a problem?  Not me!  Who said that people must use C?  Not me!  I was replying to someone who said that some people found C hard to learn and I suggested a way to learn it.  I said before and I say again that I am not trying to change anyone's mind.  I was only asking for the rationales that people had for using Assembly over C and got some good replies as well as one that was completely inappropriate for the content of the discussion.   Man, it is weird how people want to put words in your mouth some times.  

-- Don


 {Original Message removed}

2007\03\10@194817 by David VanHorn

picon face
>
> > At times, it's not even possible to use C on the smaller ones.
>
> Which times are those?


See below



> > 3 level hardware stack with C?  :)
>
> What does the hardware stack depth have to do with C?  C does not
> mysteriously consume hardware stack levels.


Nothing "mysterious" about it, but C pushes a lot of things onto the stack
in function calls and ISRs.
In some of my ASM ISRs I don't push ANYTHING because it's not necessary.
When you only have a three word hardware stack, I don't even think it's
possible to use C, is it?



> > Overlapping buffer spaces in a small processor?  Someone check me if I'm
> > wrong but I don't think C will let you do that, and if you did, I doubt
> you
> > could fit the code.
>
> What do you mean by "overlapping buffer spaces?"


Specific case, I needed a rather large input buffer, output buffer, and
stack space.
The sum of the three was about 1.5x the memory in the device.
(of course some will say "use a bigger chip", to which my project manager
would reply " A million times a dime pays your salary for a year, write
better code!"

By overlapping, I mean that I put data into the input buffer at the
beginning of the process, and as I fill up the output buffer, I start using
space that was originally used as input buffer.   I also at some times
needed deep stack space, which overlapped either the in or out, I forget
which, but since I knew exactly what my stack usage was and WHEN, I could
manage that.

2007\03\10@194925 by Tony Antoniou

picon face
Steady on there dude. I've only just started working with PicBASIC as it's
easier for me to pick up than C. Up until now, however, I have been
programming in Assembly purely because I see it as seeing and having control
over exactly what the chip will do. Kind of like "be the PIC" in a
philosophical sense. Heh. I figure that by programming it in assembly, I
know exactly what it's going to do and why. It also makes debugging easier
for me too.

Now of course, you'd be inclined to ask why the shift to PicBASIC? Simply
because it was recommended to me by a colleague and chances are, it will
make certain tasks easier which would involve reading strings of ASCII
characters from a serial port, for example. That's something I'd probably be
inclined to conjure up in a higher level programming language as a module
and then do the rest in assembler still - just because I get to see exactly
what the PIC is doing and still find it quicker to debug in it.

It's all a matter of personal preference ... not ego.


Adios,
Tony

---------------  TAMA - The Strongest Name in Drums  ---------------
-----Original Message-----
From: @spam@piclist-bouncesKILLspamspammit.edu [KILLspampiclist-bouncesKILLspamspammit.edu] On Behalf Of
Don French
Sent: Sunday, 11 March 2007 8:55
To: Microcontroller discussion list - Public.
Subject: Re: [PIC] Why bother with Assembly?

But unless there is a specific requirement that demands Assembly, developing
in Assembly is counter productive in my humble opinion.  I have the feeling
that some people do it solely to feel superior to those who don't know
Assembly.

2007\03\10@194953 by David VanHorn

picon face
On 3/10/07, stef mientki <RemoveMEs.mientkiTakeThisOuTspammailbox.kun.nl> wrote:
>
>
> >
> > At times, it's not even possible to use C on the smaller ones.
> > 3 level hardware stack with C?  :)
> >
> So use a decent compiler that has a software stack.


That would be kinda hard in a chip with a hardware stack.

2007\03\10@195337 by Don French

picon face
Man! What is with you?

I never said that people should switch to C.  Please don't misquote me!  I could care less what others do.  I stated why I use C, and given those reasons, wondered if there were valid reasons others did not.  And I got some reasonable answers from reasonable people, for which I would like to offer thanks.

-- Don


 {Original Message removed}

2007\03\10@195423 by David VanHorn

picon face
On 3/10/07, Jinx <spamBeGonejoecolquittspamBeGonespamclear.net.nz> wrote:
>
> > what happens when you boss puts an Atmel MCU on your desk
> > and says "use this for this project"? I'm all for ASM, but I found
> > it locks you into a family too much, and I don't like that. Just my
> > opinion. TTYL
>
> That's true if you have a boss (that would do that, and I don't think
> I'd take too kindly to it), but I'm sure many micro users aren't given
> directions about which micro to use. Undoubtedly there are times
> when the project is run by the engineering or accounting department.
> Each to his own. I see no reason why you couldn't learn both ASM
> (first) and HLL (second)


That's amusing.. I have had projects where PICs were already designed in,
and then they came to me for software.  So I learned PICish. :)

2007\03\10@195521 by David VanHorn

picon face
Wow.. You spend a day putting up antennas, and look what happens!

:)

2007\03\10@203314 by Jinx

face picon face
> Man! What is with you?
>
> I never said that people should switch to C
> Please don't misquote me!
> I could care less what others do

Rubbish. The whole tone of your posts has been strongly in favour
of, and promoting, C and disparaging of asm and (some) asm users.
Deny that if you will but read them again. Look at the subject you
gave the thread for goodness sake, and the original post

"Except for really tight timing situations,
why not use C, which is one heck of a lot
easier to write, read, maintain, etc.?  And
the optimizing compilers probably do at least
as good a job of saving bytes as most people
can do by writing in Assembly.  So, what is
the point?"

And so it continues, post after post

This is a waste of my time. Any further posts from you and the
thread in general are straight in the bin unread

2007\03\10@211217 by John Temples

flavicon
face
On Sat, 10 Mar 2007, David VanHorn wrote:

>> What does the hardware stack depth have to do with C?  C does not
>> mysteriously consume hardware stack levels.
>
> Nothing "mysterious" about it, but C pushes a lot of things onto the stack
> in function calls and ISRs.

A C function call or ISR uses one level of the hardware stack, just
like assembly language.  I've never seen a PIC C compiler that used
the hardware stack for any additional storage purposes.

> In some of my ASM ISRs I don't push ANYTHING because it's not necessary.
> When you only have a three word hardware stack, I don't even think it's
> possible to use C, is it?

I've done a C application on the 10F200, which has a two-deep hardware
stack.  The application used zero of those stack levels, because my
code contained no function calls, and the 10F200 doesn't have
interrupts.

--
John W. Temples, III

2007\03\10@211426 by Tobias Gogolin

picon face
I haven't programed assembler in years and when I recently started a micro
controller project I 'obviously' chose C because of being an available
portable HLL pr the micro controller I am planning to use.
Actually this may be a good place to ask people to please help with the
code, I am progressing way to slow, cause I have too little spare time and
the hardware related details take a lot of time to research!
Its a open source solar tracker that the program is going to be for! I
recently posted the Boost C source code as far is it exists so far (in the
toward first hardware message) in our List at
http://groups.yahoo.com/group/GoBox

I am a bit afraid of the upcoming debugging cycle too!
Any help will be appreciated and serves the good cause to make renewable
energy an even more _open source_!

On 3/10/07, Don French <TakeThisOuTdcfrenchEraseMEspamspam_OUTgmail.com> wrote:
{Quote hidden}

>   {Original Message removed}

2007\03\10@212531 by Bob Axtell

face picon face
The primary reason that Assembly is so popular is that firmware can be
made smaller, the PIC executes algorithms faster, with the result that
more can be done in less space.
Another reason is that C requires overhead, and for some small PICs, the
overhead is simply unavailable.

Years ago I bought an expensive C compiler and offered that capability.
Whether it was Hitachi, Zilog or PIC, every time I had an algorithm
worked out my client said
"That's great, Bob. Now I also want it to do this and this and this."
Suddenly, the C code had to be rewritten into Assembler so that I could
add "this and this and this".
Finally, I simply stopped offering C anymore.

Having said that,  processors now have better capability and more RAM
than before, and  are oriented to C requirements. I like Pascal better
than C and have begun tinkering with Mikro
Pascal for PIC. Its fun.  But my primary work is Assembler.

--Bob



Don French wrote:
> Having a library is a good reason, but you can link assembly code with C if you want to.   And having libraries of Assembly code is great, and I would use those libraries to the fullest when there is no C library to do the same thing.  Copy and paste is the longest and most honored of programming traditions and I fully agree with it.   But not knowing C is valid only up to a point. After all, it is extremely easy to learn C, especially compared to learning Assembly.  I know that for fact as I have written tens of thousands of lines of code in both, just not for the PIC.  But the only time I chose Assembly over C is when there was a good reason.  For example, I wrote a chess engine in 80x86 because I needed to squeeze every cycle I could out of the processor, and I pulled every trick in the book and some that weren't in the book to get those cycles because speed was of the essence in that situation.  
>
> But unless there is a specific requirement that demands Assembly, developing in Assembly is counter productive in my humble opinion.  I have the feeling that some people do it solely to feel superior to those who don't know Assembly.  I see that attitude enough among some of the Linux fanatics to find it extremely tiresome.  Whatever is most the efficient use of my time is what is best for me.  If you code for a hobby and find the business of playing with bits and registers and memory banks fun, then sure why not.  But if you do it for a living, why make life harder than it needs to be?   Well, that is my take on it anyway.  I don't want to try to change anyone's mind.
>
> Someone else posted that this has been discussed to death already, but I am new to the list so I missed it.  I didn't want to stir anything up, I just thought that there must be some valid reasoning behind the choice of Assembly that I wasn't aware of.  So unless someone has a reason other than "it is more fun" or "the code that I need already exists in Assembly and not in C" which are fine reasons, let's drop it.  
>
> -- Don
>
>
>   {Original Message removed}

2007\03\10@213251 by Don French

picon face
There is nothing in my posts or my title that suggests or was meant to suggest that I want to change people's minds.  Why should I?  I have no interest in how others work or their programming language choices.  Again, why should I?  Why should anyone other than a programming manager perhaps?  Or someone with a compiler or assembler for sale, maybe.   I would never have guessed that anyone would even think that because the whole idea is absurd.   It just never occurred to me that anyone would take it that way.  If you read that into my posts, the only thing I can tell you is that you are wrong.  Yes, I stated my opinion that C is easier to write, read, and maintain, but I figured that everyone already knew that.  I thought that much was a given in this group and I have never met anyone in my long programming career who didn't think that, but today I did.  And it took me by surprise.  And what took me even more by surprise was that I was attacked and misquoted and misundersto!
od for asking the questions and stating the opinion that I did.  But I think I know why it happened. It was the opinion that I should have kept to myself, about some people's motivation.  I think that is really what set some people off and I should have known better.  I apologize to anyone who felt that was meant to apply to them.  

For the record, I write in both Assembly and C and always have. I just pick the one that seems to be the most appropriate at the moment. In fact, I was writing Assembly code before C was invented.  I even wrote an assembler and marketed it fairly successfully for a number of years.  (It ran on the unexpanded VIC-20 and holds the world's record as the smallest symbolic assembler ever written.)  So, I am certainly not prejudiced against Assembly language or the fine people who use it.  In fact I am one of them!    Sorry to have created such a stir!  I had no idea people were so touchy about this subject. Please, everyone just go back to what you were doing and try to enjoy the rest of the weekend. :-)

Peace!

-- Don


 {Original Message removed}

2007\03\10@213919 by Tony Antoniou

picon face
Question, while we're sort of on the topic ...

As I've stated before, I'm looking into PicBASIC and from what I've seen,
the only useful one seems to be the expensive Proton Plus compiler. Are
there any other recommendations on the BASIC platform (as well as C - I
might experiment with that one too)?


Adios,
Tony

---------------  TAMA - The Strongest Name in Drums  ---------------

2007\03\10@215523 by Victor Faria

picon face
www.sfcompiler.co.uk/swordfish/
http://www.mikroe.com/
http://www.melabs.com
victor
----- Original Message -----
From: "Tony Antoniou" <RemoveMEartstarspamTakeThisOuTiinet.net.au>
To: "'Microcontroller discussion list - Public.'" <piclistEraseMEspam.....mit.edu>
Sent: Saturday, March 10, 2007 9:39 PM
Subject: RE: [PIC] Why bother with Assembly?


{Quote hidden}

> --

2007\03\10@232452 by William Chops Westfield

face picon face

On Mar 10, 2007, at 2:04 PM, Herbert Graf wrote:

> but what happens when you boss puts an Atmel MCU on your desk
> and says "use this for this project"? I'm all for ASM, but I
> found it locks you into a family too much

Bah.  Once you've learned two or three assembly languages, it's
not difficult to pick up a new one pretty quickly.

A big reason for KNOWING assembly language is that most microcontroller
programming is going to require a relatively intimate understanding of
the underlying architecture of the chip, and most of the documentation
(such as it is) for the features of the chip is going to be described
in terms of the assembly language used by the processor.  (usually.
I was looking at the Luminary ARM chips, where peripheral documentation
consisted largely of a C library and documentation for THAT.  I found
it rather disorienting.)

Needing to KNOW the assembler doesn't mean you have to program in
assembler...

BillW

2007\03\11@035215 by John Chung

picon face


> Someone else posted that this has been discussed to
> death already, but I am new to the list so I missed
> it.  I didn't want to stir anything up, I just
> thought that there must be some valid reasoning
> behind the choice of Assembly that I wasn't aware
> of.  So unless someone has a reason other than "it
> is more fun" or "the code that I need already exists
> in Assembly and not in C" which are fine reasons,
> let's drop it.  
>
> -- Don
 
 Reasons why I choose assembly:

1) Depends on architecture. AVR with the bigger MCU
have an architecture tuned for high level language
like C. GCC support is VERY good for this MCU so I
choose C.
Microchip C compilers cost plenty and the compilers
aren't so great for PIC midrange due to it's limited
unsupportive arch. for HLL.

2) Assembly documentation is plenty for MCHIP. Plus
code samples in assembly. Here is basically the
support for the given language.

3) USE less memory. Regardless of the language for HLL
it use plenty of memory of the MCU. Assembly is
compact in size therefore and USE less memory and ADD
in more features.

4) Speed... Depends on the req. of the application.

5) Debugging. One ought to know the target's assembly
for debugging the problem which includes the compiler
output and tracing the problem using some sort of
debugger. You write in Pascal but use gdb to debug the
problem. You know how it feels....

6) Knowledge. I learn something new all the time.
Assembly is more expressive in it's language. Unlike
C++ and C I am able to do all the above and more due
to it's LAX rules.



John



____________________________________________________________________________________
TV dinner still cooling?
Check out "Tonight's Picks" on Yahoo! TV.
http://tv.yahoo.com/

2007\03\11@050115 by Vasile Surducan

face picon face
hi John,

On 3/10/07, John Chung <EraseMEkravnusspamyahoo.com> wrote:
{Quote hidden}

Exactly the same support is available in HLL

>
> 3) USE less memory. Regardless of the language for HLL
> it use plenty of memory of the MCU. Assembly is
> compact in size therefore and USE less memory and ADD
> in more features.

Debatable. An asm beginner may use more memory than an beginner using
a good compiler.

> 4) Speed... Depends on the req. of the application.

Very debatable. A HLL with all tricks already known will be faster than any asm

>
> 5) Debugging. One ought to know the target's assembly
> for debugging the problem which includes the compiler
> output and tracing the problem using some sort of
> debugger. You write in Pascal but use gdb to debug the
> problem. You know how it feels....

Here you have right if debugging is made using MPLAB. However there
are built in simulators and external devices for debugging as well.
Some of them like LED or serial console are well known.

>
> 6) Knowledge. I learn something new all the time.
> Assembly is more expressive in it's language. Unlike
> C++ and C I am able to do all the above and more due
> to it's LAX rules.

Depends of your age and if you're programming for living or just for
fun. I have doubts who is designing with PICs for living is so happy
with asm every day...
Just take a look to the old people reaction from this list.

2007\03\11@060011 by stef mientki

flavicon
face

>>>      
>> So use a decent compiler that has a software stack.
>>    
>
>
> That would be kinda hard in a chip with a hardware stack.
>  
not at all !!

--
cheers,
Stef Mientki
http://pic.flappie.nl

2007\03\11@094419 by John Chung

picon face
Hi Vasile,


--- Vasile Surducan <RemoveMEpiclist9EraseMEspamEraseMEgmail.com> wrote:

{Quote hidden}

 I was refering to Microchip site. Support for HLL
does exist at the product site and sometimes the
Microchip site. So you are right here.


{Quote hidden}

 I agree.


> > 4) Speed... Depends on the req. of the
> application.
>
> Very debatable. A HLL with all tricks already known
> will be faster than any asm
>

 I agree. I have seen some VERY good programmers that
can squeeze out every clock cycles. This unfortunately
requires knowledge more than just assembly therefore
it really depends on the programmer. C can squeeze
more performance but with assembly we can squeeze
more. It is more of diminishing returns. How much time
and effort do we take to get what we want.

{Quote hidden}

 I agree.

{Quote hidden}

 This is something personal so I rather not go there
:) Personally it depends on what I need to do. On PC I
try to use C if possible. Okay I do use C++ due to the
amount of libraries written..... I try to keep a
balance between all the languages. Assembly if useful
for hardware manipulation. The instruction OUT for x86
is not naturally supported in C so I use macro or
functions that use embedded assembly. Intel C compiler
tends to use ALL those funny assembly stuff
internally. So I learn from there to embed assembly
into my C programs from time to time... For PIC I use
assembly which is for the MID range only. Once again
this is choice.

John.



____________________________________________________________________________________
We won't tell. Get more on shows you hate to love
(and love to hate): Yahoo! TV's Guilty Pleasures list.
http://tv.yahoo.com/collections/265

2007\03\11@142153 by Peter P.

picon face
Don French <dcfrench <at> gmail.com> writes:

> Please, everyone just go back to
> what you were doing and try to enjoy the rest of the weekend.

No, no, please don't stop! We have not clarified what the best operating system
to run the assembler or compiler on is, and what text editor to use. You can't
really stop now.

;-)
Peter P.


2007\03\11@144736 by Peter P.

picon face
stef mientki <s.mientki <at> mailbox.kun.nl> writes:

> > I agree, for hobby, ASM is the way to go, maybe followed by a free C
compiler > > to
> > pick up the skills for later.
> I've teached  children to program PICs.
> That would never have succeeded using either C or ASM.
>
> There's more available on this planet,
> something like JAL for example,
> or what about Python for PICs

Yes, but did you try a visual programming environment ? And how small were the
kids ? I think that LOGO was tried with very small children. Also, there are RAD
programs for embedded boards now.

Peter P.




2007\03\11@152827 by stef mientki

flavicon
face
Peter P. wrote:
> stef mientki <s.mientki <at> mailbox.kun.nl> writes:
>
>  
>>> I agree, for hobby, ASM is the way to go, maybe followed by a free C
>>>      
> compiler > > to
>  
>>> pick up the skills for later.
>>>      
>> I've teached  children to program PICs.
>> That would never have succeeded using either C or ASM.
>>
>> There's more available on this planet,
>> something like JAL for example,
>> or what about Python for PICs
>>    
>
> Yes, but did you try a visual programming environment ?
Yes, MindStorms itself, within a week they weren't interested anymore.
Not sure why, too slow ?, bounced into limits ?
We stepped over to NQC (similar to JAL) and within an hour they could
run a program.
> And how small were the
> kids ?
about 11 years old
> I think that LOGO was tried with very small children.
Yes we also looked at that, but I couldn't see the elegance of it ;-)
>  Also, there are RAD
> programs for embedded boards now.
>  
Well I just made an evaluation between LabView, MatLab, Python
and about 10 other programs as a signal analysis tool,
meant for research done by medical students,
and although graphical design environments are my favorite,
the big looser is LabView (from which Robolab is derived).
the big winner is Python !!

--
cheers,
Stef Mientki
http://pic.flappie.nl

2007\03\11@191546 by Peter P.

picon face
stef mientki <s.mientki <at> mailbox.kun.nl> writes:

> Well I just made an evaluation between LabView, MatLab, Python
> and about 10 other programs as a signal analysis tool,
> meant for research done by medical students,
> and although graphical design environments are my favorite,
> the big looser is LabView (from which Robolab is derived).
> the big winner is Python !!

There is a visual rad tool for programming small PLCs that should work for
introducing to embedded (complete) programming. I.e. a self contained board with
screw terminals and a wall wart, and visual programming using some program under
Windows.

My highest respect for Python comes from using Blender.

Peter


2007\03\11@202642 by Chris McSweeny

picon face
Haven't read the whole of this thread (it was getting tedious), but thought
I'd just add my perspective. For my job I program on a PC in C++, and have
also written code in C for a Motorola uC. However for the small stuff I do
with PICs, not only is timing usually an issue (including with the projects
I do for work), but also most of the effort is in making the hardware work
properly, which isn't something that coding in C helps with at all.
Therefore I program in assembler on a PIC. Maybe it's just because I've also
been coding in assembler for 25 years (back to when I had a ZX81, and I hand
compiled and used a hex-editor to program!) so it's something I'm relatively
comfortable with.

I've even recently ported some assembler code from a PIC to an AVR, and am
now working in assembler on AVRs, which seems to be much more unusual as
most people seem to use C for those. However, since as mentioned above most
of the complex issues in my code are to do with hardware interaction, it
wouldn't have been any easier at all to port C code, as I'd still have had
to go into the datasheet and work out how all the different bits worked and
translate it all by hand.

2007\03\12@062924 by Alan B. Pearce

face picon face
>> - PIC projects are often small enough not to get many benefits from
>> an HLL - for example a recent project I did was a "flickering candle",
>> it's about 20 lines of ASM, hardly worth going to C

...

>Statistics say that American programmers produce about 50 lines of
>'good' code per day (including debug time). So your asm program
>should have taken almost half a day,

His flickering candle would probably take about that long I would guess.

>and the C program a tenth of a day.

For a program of that size, I would suggest that it would probably also take
around half a day ...

I do seriously wonder how well the metric scales down to very small
programs. I can see that the metric would work for large programs, but to my
mind, when you come to small programs there are other things that would tend
to overshadow the generality of the metric.

2007\03\12@063707 by Alan B. Pearce

face picon face
> > what happens when you boss puts an Atmel MCU on your desk
> > and says "use this for this project"? I'm all for ASM, but I found
> > it locks you into a family too much, and I don't like that. Just my
> > opinion. TTYL
>
> That's true if you have a boss (that would do that, and I don't think
> I'd take too kindly to it), but I'm sure many micro users aren't given
> directions about which micro to use. Undoubtedly there are times
> when the project is run by the engineering or accounting department.
> Each to his own. I see no reason why you couldn't learn both ASM
> (first) and HLL (second)

I could see this happening in a company that does a programming contract for
another company that wishes to use a micro they already use in their
products, rather than change to a different chip or family. It may well
result in using a less than optimum chip for the job (could be too big or
too small), but purchasing considerations make it a viable deal where
switching chips in a cost sensitive environment may well kill the project.

2007\03\12@064307 by Alan B. Pearce

face picon face
>Wow.. You spend a day putting up antennas, and look what happens!

Worse than that, you go home for the weekend and don't look at the emails
... ;))

2007\03\12@070516 by Alan B. Pearce

face picon face
At risk of continuing the thread ...

> > 3) USE less memory. Regardless of the language for HLL
> > it use plenty of memory of the MCU. Assembly is
> > compact in size therefore and USE less memory and ADD
> > in more features.
>
> Debatable. An asm beginner may use more memory than
> an beginner using
> a good compiler.

For a number of modern compilers I believe this is a red herring. It may
well have been true in the past, but as someone else has pointed out, there
are some very clever people making the compilers these days, and
contributors have commented here on how they have managed to get smaller
programs in C than they have in assembly, due to compiler optimizations.

The problem I have with going to an HLL is using it enough to keep in
practice with it. Using it for a one off project gets one familiar with some
features, and then the next time one comes to use it again, there is another
learning curve to get back the knowledge lost over time. I do feel that the
relearning curve is easier with ASM.

Maybe this will change with a couple of 18F projects I have in mind, where
having a no-cost compiler available makes one feel that there is nothing to
lose by attempting to do it in C, along with having some linkable libraries
available for I/O interfacing.

2007\03\12@074747 by wouter van ooijen

face picon face
> > 3) USE less memory. Regardless of the language for HLL
> > it use plenty of memory of the MCU. Assembly is
> > compact in size therefore and USE less memory and ADD
> > in more features.
>
> Debatable. An asm beginner may use more memory than
> an beginner using
> a good compiler.

> For a number of modern compilers I believe this is a red herring.

But even if it would be true - how important is using let's say 50% more
flash (which is I think a too high estimate). It matters only when your
chip is - using assembly - between 66 and 100% filled - and even then it
will in a lot of cases just mean switching to the next larger chip.
What's the price difference between let's take a 16F628A and a 16F648A?
And how does that difference compare to the increase of development time
(and bugs, etc) caused by using assembler?

Wouter van Ooijen

-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: http://www.voti.nl/hvu



2007\03\12@081603 by Tamas Rudnai

face picon face
I have to disagree with you here. The device I've made is existing on the
market already, but the firmware written in C. They had to use a 16Fxxx chip
and the product has less functionality as mine. I used 10F202 instead. That
saved me quite a few quid during the manufacturing and even do the job much
better (smaller and more functionality). And if you have a great collection
of macros the development time is not even much higher than using a C I
suppose.

I agree though that in a huge company where engineers leave the company and
new comes to take over projects it might be better choice to use a HLL as
more people knows C than Assembly - I mean as a high standard, so your
project won't be dead just because your engineer who had left your company
had much greater knowledge in Assembly than those you can replace with.

Tamas



On 3/12/07, wouter van ooijen <RemoveMEwouterTakeThisOuTspamspamvoti.nl> wrote:
{Quote hidden}

> -

2007\03\12@084041 by Peter P.

picon face
Mike Harrison <mike <at> whitewing.co.uk> writes:

> No compiler will ever be as code-space and/or speed efficient as a good
> assembler programmer - In
> some cases, the lower efficiency can be due to fundamental limitations of the
> language rather than
> any particular compiler.

I think that this is a myth. When one compares an assembly programmer with a C
compiler one most often compares an average assembly programmer with ten crack
assembler programmers who wrote the C compiler's code generator, which was then
validated by hundreds or thousands of users. Every time someone uses assembler
to do trivial tasks he reinvents the wheel, and since he might not be the best
assembly programmer in the world, he may also do things suboptimally or induce
bugs of his own.

I also like assembly very much but at the right time and place. I did Z80, 8085,
a little 80x86 (boot sectors etc), PIC and MCS51 and I know what I don't love
and why. One begins to write 'reasonably' good assembly after studying several
books about that particular processor's assembly. Until then, it's hacking at
best. For non-RISC architectures the learning process is in the tens of years.
Reinventing a (seemingly) clever 4-bit masking and adding operation (unbeknownst
to the happy coder, for the 768,519th time in the last 20 years) is very
satisfactory ego-wise but not very productive. And one can be sure that a good
compiler will 'know' that trick, and ditto a good assembly book, and worse, not
knowing this and boasting it in a resume or such may earn one bad marks. Some of
my biggest AHA (aka Evrika) moments in programming came while analyzing compiler
output listings.

I think that anybody repeating the myth about 'compilers outputting less
efficient code' without having read listings from a good compiler's output does
not do himself justice. After all, compiler output *IS* machine code written
using code generators made and optimized by expert assembly programmers. Of
course size matters but as others have pointed out, size is not everything.

Speaking of 20 years ago, I remember wrapping my mind around the tricks used by
the Sinclair Spectrum's ROM authors (see the book about this) and being awed by
the clever hardware (~12 ttl chips for TV output from a Z80 micro) of the ZX80
(not 81).

Peter P.


2007\03\12@084606 by wouter van ooijen

face picon face
> I have to disagree with you here. (snip)

We don't disagree: I was not arguing that C is *always* better than asm.


The correct question is "how to decide which language to use", and in a
commercial context there is ultimately only one answer: "which ever
costs less", although it might be not that easy to incorporate all
relevant costs. (This is not different from any other business
decsision.)

You example might show a case where asm is better than C.

Wouter van Ooijen

-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: http://www.voti.nl/hvu



2007\03\12@123646 by David VanHorn

picon face
On 3/12/07, Alan B. Pearce <EraseMEA.B.PearcespamspamspamBeGonerl.ac.uk> wrote:
>
> >Wow.. You spend a day putting up antennas, and look what happens!
>
> Worse than that, you go home for the weekend and don't look at the emails
> ... ;))


Work and home are separated by about 20 feet, and the antenna feedlines
start in the office, and go up the tower at home.

More... (looser matching)
- Last day of these posts
- In 2007 , 2008 only
- Today
- New search...