MC9S08 - Assembly or C - Complete novice

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MC9S08 - Assembly or C - Complete novice

3,537 Views
jart
Contributor II

Hi. I’m planning on learning to use the S08 microcontroller. I have no experience of assembly or C. So what would you recommend for learning about embedded C and the S08? I would appreciate any links or advice.

 

 

 

 

 

Added part number to subject.



Message Edited by NLFSJ on 2007-06-16 07:44 PM
Labels (1)
0 Kudos
6 Replies

730 Views
tonyp
Senior Contributor II
OK, you said you wanted to learn how to use the S08.  This is a different task from learning how to program (irrespective of language).

So, start with the S08 Reference Manual (HCS08RMV1.PDF or something like this.)

If you manage to go through the whole book, you will have no choice but to encounter all the available instructions and their addressing modes.

Can you program using some third language (other than C or assembly?)  If so, you already know programming, and you just need to learn a new language.  Ah, but you just did by reading the S08 Reference manual.  So, you're already closer to assembly than C.

But if you meant you do not know how to program in any language, this is a whole different game.  Start with some good beginner books on programming and a very basic language (like BASIC) to get a good grasp of the various primary programming concepts.

So, what will it be then in the end, assembly or C?  Everything else being equal (e.g., competence level),

Best reasons to use assembly:

* Absolute control of all aspects of your coding (think of it as the WYSIWYG of programming).
* Much faster overall performance of your code (i.e., more job done for the same unit of time).
* Much shorter code (i.e., smaller device and cost for the same job).

Best reasons to use C:

* Be liked by other C programmers.
* Understand and/or use their code snippets posted in their messages.


Sorry if I appear a little biased :smileyhappy:


Message Edited by tonyp on 2007-06-20 12:26 PM
0 Kudos

730 Views
peg
Senior Contributor IV


tonyp wrote:


Best reasons to use assembly:

* Absolute control of all aspects of your coding (think of it as the WYSIWYG of programming).
* Much faster overall performance of your code (i.e., more job done for the same unit of time).
* Much shorter code (i.e., smaller device and cost for the same job).

Best reasons to use C:

* Be liked by other C programmers.
* Understand and/or use their code snippets posted in their messages.


Sorry if I appear a little biased :smileyhappy:


Oh, I love this, can I quote you on this? I think I am going to frame it and hang it on the wall. (Timber frame, no an HTML one):smileyhappy:
 
P.S. For those that may have missed the point, you will notice there is no technical reason offerred to use C.

 
0 Kudos

730 Views
Lundin
Senior Contributor IV
I would like to add a few:

Best reasons to use assembly:

* Non-portable, meaning you as a programmer will be invaluable to your boss and hard to replace.
* You support Freescale by making it nearly impossible to replace the MCU.
* Makes sure there is plenty of work for you if your boss still decides to port the code to another MCU.
* No need to read or follow annoying standards.
* You won't be tempted to waste money on the source code for that IP-stack or that CANopen port, since you will have to write them yourself.


:smileyhappy:
0 Kudos

730 Views
tonyp
Senior Contributor II


Lundin wrote:
I would like to add a few:

Best reasons to use assembly:

* Non-portable, meaning you as a programmer will be invaluable to your boss and hard to replace.
* You support Freescale by making it nearly impossible to replace the MCU.
* Makes sure there is plenty of work for you if your boss still decides to port the code to another MCU.
* No need to read or follow annoying standards.
* You won't be tempted to waste money on the source code for that IP-stack or that CANopen port, since you will have to write them yourself.


:smileyhappy:

You seem to try to list the "worst" reasons to use assembly, not the best.  Still,...

Your first point, job security, is indeed a "good reason" for the programmer, "not so good reason" for the employer.  But, on the other hand, doesn't using C that everyone is supposed to know make one very volatile (replaceable)?  So, you can add this one to the worst reasons to use C.

A boss that decides to use another MCU without technical merit (which if there was, means a bad choice was made in the original design) can only have cost in mind.  And that could have been avoided if the application was in assembly language in the first place (read again best reasons to use assembly)!

Your last two points contradict each other.  If you don't need to read standards how are you going to write that IP stack?   In general, the more low-level one has to get, the more technical one becomes, which I don't consider a bad thing.  So, this argument is moot.  (Unless by "standards" you meant the C language itself, in which case I wholeheartedly agree; it IS an annoying standard.)

Portable?  Why?  You can port from any S08 to any other S08 with minimal effort.  And there are so many of them to choose from.  If, however, you belong in that category where every application is written for a different MCU family, then C is certainly good for you.  I tend to stick to a few MCUs, usually related because it's not just the cost of porting to consider (which isn't zero with C either), but also the cost of tools (different programmers, emulators, software, etc.) and the cost of learning diffrerent (sometimes widely different) architectures (even when programming in C).

Anyway, assembly-or-C is an never-ending "war".  I don't think it can be settled here and now.  Everyone should use what they feel comfortable with.
0 Kudos

730 Views
freegeek
Contributor III
0 Kudos

730 Views
joerg
Contributor II
Hi jart
As a assembler freak i would have to say ASSEMBLER, but since i have seen, that a lot of users don't even know the assembly language, i have begun writing my programs in C (Including my simple OS, EBS08). First i was  afraid  to get large programs, but i must say the CWs C compiler is very efficient!!!

So my advise: is do it in C!

Why not have a look at EBS08C for getting an idea, you may also look at the ASM version to compare C and ASM.

Saluti Joerg


0 Kudos