Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

programming language?

Status
Not open for further replies.

jrz126

Active Member
Hey gang,
I'm finally taking a microcontrollers class for school. We're using the 16f877, but we are programming in C instead of assembly, (they just switched to C this semester).
Now Im planning on tinkering with the microcontroller in my spare time, and I was wondering if it would be worth it to learn the assembly language on my own. Also, what are the benefits of assembly?
 
As I said many times before, it is worth learning Assembly first, Assembly has following pros and cons:
+Speed
+Code size (if programed correctly)
+Understanding true HW of PIC (how it works)
-Ease of writting (too much typing)
-Ease of Debugging and later editing (code is long even for simple application)
-Code is not Cross-platformed
-Harder for beginners?

Without Assembly you can't program advanced Projects (you need special low-level routines).
 
thats really strange. they are teaching you guyz how to program a microcontroller in C. i thought that assembly was the de facto standard in universities. all the people that i know who are working with microcontrollers studied assembly in their courses. it isnt about which language is easier or which language has more power, in universities its just tradition.

the choice between assembly and C comes when you are learning yourself. at that time you can choose the language depending on your skills and time that you want to spend.

anyway i think its a good thing you are going to use C for PICs. but you should also have a good understanding of assembly. for that you can read Nigel's tutorials and if you have more time then you could also read some books

i hope that helps
 
It is like an ancient King granting a person two beautiful young ladies and ask him to pick.

Obviously a wise man would ask the King, "Can I have both?". Just ask Jay and he will tell you the reason why.

Now the problem. Which one first? You are the one to decide.

You'll be fine with one at a time. Having both simultaneously would put you in big trouble as your heart may not take it so easily.
 
eblc1388 said:
Now the problem. Which one first? You are the one to decide.

You'll be fine with one at a time. Having both simultaneously would put you in big trouble as your heart may not take it so easily.

My heart's young enough to handle both simultaneously, but that's just me...

:cool:

:lol:
 
It really sucks that we are learning C...I already know C quite well and I was relying on this class to teach me assembly...I'm not very good at learning it on my own.

I think part of the reason for the switch over is the prof fro the course is a chinese lady with a horrible accent and she doesnt really know what she is doing even though she's taught the course for 4 or 5 years now. that really bothers me when the prof. doesnt even know how to work the equipment.

maybe once I get a good handle on using the pic in C I'll be able to teach myself assembly.
 
jrz126 said:
It really sucks that we are learning C...I already know C quite well and I was relying on this class to teach me assembly...I'm not very good at learning it on my own.

I think part of the reason for the switch over is the prof fro the course is a chinese lady with a horrible accent and she doesnt really know what she is doing even though she's taught the course for 4 or 5 years now. that really bothers me when the prof. doesnt even know how to work the equipment.

maybe once I get a good handle on using the pic in C I'll be able to teach myself assembly.

Once you're familiar with C on the PIC, assembly will be a breeze... In fact, what I think I would do in your situation is, when I get home, try to apply part of what was thought in class using assembly. I think you'd learn assembly pretty easily that way.
 
I remember the micromouse conference in 2004 that two professors got in descussion about the teaching of ASM to students (both in Electronics and CS classes). Both said they *would* if they could, but time does dictate whats taught.

On the advanced side of things, one was a compiler specialist; so he had to teach ASM in classes which based around compilers and also on more advanced electroics courses.

Problem is in the real world a ASM programmer is fast, but a C Programmer who knows enough ASM to get by is faster.

Benifit of ASM? Debuging C Code! Some of you may know the BoostC Compiler (now with 32bit math!) was recently released, but when in the beta stages it was all about bug finding and it needed ASM knowolege. Every compiler can have small bugs which occur in optimisation or pre-processing or compiling. You can spend hours scratching your head with every ANSI C book in existance at your side to find a simple compiler bug making the wrong ASM is to blame
 
An embedded engineer must have both.

Now a days C is becomming popular in industry with very bit of assembly in startup routines & crtical paths.

the best advantage of C is easy maintainance and speed of development.



eblc1388 said:
It is like an ancient King granting a person two beautiful young ladies and ask him to pick.

Obviously a wise man would ask the King, "Can I have both?". Just ask Jay and he will tell you the reason why.

Now the problem. Which one first? You are the one to decide.

You'll be fine with one at a time. Having both simultaneously would put you in big trouble as your heart may not take it so easily.
 
Is it safe to assume that THEORETICALLY, if using assembler language, you could write a bug-less program in one draft?
 
If you are skilled enaugh then Yes (regardless of programming language), take this example:
Code:
GOTO $
I think it is Bug-less :lol:
 
Jay.slovak said:
I think it is Bug-less :lol:

Even an instruction as simple as that can have bug.

In the following two programs, they look the same. can you tell me why the first one works and the second don't?

Program 1:
Code:
GOTO $

Program 2:
Code:
G0T0 $

Don't know? :D Try copy & paste the above codes into an editor.
 
My guess is that this change has come about because many company's C compilers now produce far better optimized assembly than ever before. Due to popular demand, they are focusing more on this aspect of their compilers. As an example for those of you considering yourselves quite adept in writing assembly for the PIC microprocessor, download the Hi-Tech PICC compiler (considered by some to have one of the best optimized assemblers available) and look through the generated assembler listing for one of your programs. They have come a long long way to bridging the gap as have other companies.
 
As an example for those of you considering yourselves quite adept in writing assembly for the PIC microprocessor, download the Hi-Tech PICC compiler (considered by some to have one of the best optimized assemblers available)

Why don't you also told us it costs only $2400 for the PICC Enterprise Edition (includes PICC, PICC-18 & dsPICC)? I admire you who can shell out that much money to buy and use one at home.
 
eblc1388 said:
Why don't you also told us it costs only $2400 for the PICC Enterprise Edition (includes PICC, PICC-18 & dsPICC)? I admire you who can shell out that much money to buy and use one at home.

They have a free version which supports a more limited number of PIC microprocessors.

Also, you don't have to purchase the enterprise package which contains three different compilers (one for PIC 10/12/14/16/17 series, one for 18 series, and one for dsPIC). An acquaintance purchased the one supporting the 10/12/14/16/17 series for 950$. This is comparable in cost to some of the better professional compilers available for writing programs to run on personal computers.

In relation to the original question, schools don't typically train you to do your hobby at home, but rather teach in skills that you will be using in the workplace. Many workplaces are moving over to the simpler to maintain compilers using the C programming language. The fact that many of them are writing much more optimized assembly than ever before in the past makes this even more so a point for small or medium sized businesses. 950$ isn't that big of an expense, even for a small company, and someone who knows ANSI C would also be cheaper and easier to find than employing someone who specializes in assembly for a large number of microprocessors.

Edit: Grammar.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top