Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

need help on assembly and c++

Status
Not open for further replies.

ahmad

Member level 1
Joined
Jul 12, 2004
Messages
36
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,286
Location
malaysia
Activity points
354
hi,

I'm good in assembly but know very little in c++ programming.
Is any one there can help me by giving me some assembly langguage especially in Motorola and PIC 16fxx series and at the same time the assembly is also writen in c++. I think by this way, i can learn c++ faster.

thanks
 

for embedded programing usually c is used not c++. c++ is an object oriented version of c which is very popular for computer programming. for microcontroller platforms there is no need to use c++, although there are c++ compilers for microcontrollers, but if you want to learn c for programing microcontrollers, I suggest first learn ANSI C. when you became fluent in ANSI C, it is highly unlikely that you feel any need to learn c++ for microcontroller programming. if you search google there are virtually countless resources and tutorials for C.
good luck
 

Thanks bluechem for your advise.
 

Hi

Eventhough C++ is not used, C++ is a powerful language.
We cant find many of the C++ cross compilers.
If we get more C++ cross compilers we can use the power of C++ in Embedded.

Hope we get in near future.

REgards
Gopi
 

C++ was designed for very large distrubuted systems where namespaces and encapsulation are required, but to acheive this aim, it has turned out to be the biggest convoluted spaghetti mess of a programming language ever devised. Find a subtle bug in multiple inheritance? Which constructor depends on which destructor, F...ing nightmare! In fact, you will rarly find a program with multiple inheritance used because of it's complexity? Don't even mention Partial Template Specialization, (Which Microsoft Visual C++ can't handle, try compiling Loki, it falls over on the first pass?), it's like a leaky bucket, plug one hole to correct a shortcoming, create two more holes doing it, it took ten years to get ratified as a programming language. What other language has books published such as, 'Effective C++' by 'Scott Meyers' 50 bugs waiting to happen if you don't do it this way???? and the sequel, 'More Effective C++', 50 more bugs waiting for you if you don't dig this subtle thingy??? Do you know there is no compiler that fully supports the ratified version of C++? Why?
Long live Barny Soupspoon!

C is a simple, elegant, mature, very powerful language that is hard to beat. The whole of the Unix operating system was written in C. Microsoft recomends using C for device drivers because of the mess caused by C++ and the difficulty in debugging C++!
Whatever language you use, it ends up as assembler. One step beyond.
You can do anything in C that you can do in C++ with half the effort and twice the understanding. C can be structured and scoped.
Stick to C for embedded, it aint a distrubuted system, save a whole lot of headaches.
Use C++ for M$oft Windows stuff. Stuff that crashes and you don't know why, maybe the compiler got confused, was that runtime or compile time? Why is C++ never used (and discouraged from using) with critically safe software?
Use C for poetry. Stuff that works.
 

btbass said:
it has turned out to be the biggest convoluted spaghetti mess of a programming language ever devised... it's like a leaky bucket, plug one hole to correct a shortcoming, create two more holes doing it...You can do anything in C that you can do in C++ with half the effort and twice the understanding...Use C++ for M$oft Windows stuff. Stuff that crashes and you don't know why, maybe the compiler got confused, was that runtime or compile time?
LOL, you seem to have too much bad memories :D
 

You can do anything in C that you can do in C++ with half the effort and twice the understanding

I believe it's the other way around. Each languages have their own strengths and weaknesses. That's why there are many programming languages coexisting. However, I agree that C is more appropriate for embedded applications.
 

Microcontrollers generally would not have a good way to implement the memory management used in C++. Most have limited ROM and much more limited RAM.

Actually, most of the features from C++ that would be practical to implement on a microcontroller can be done with C. Structs, when combined with a pointer to a function, are pretty close to being objects.
 

Well, at least I have some agreement that C++ is an accident waiting to happen. One of the most rapidly advancing use of modern electronics is in the motor industry. The Motor Industry Software Reliability Association, (MISRA) has chosen C as the prefered programming language for embeded systems, for it's stability, maturaty and understanding. They have published a set of rules or guidlines for writing reliable software.
Most modern Lint packages support MISRA rules and static analysis of your programs will reveal a lot of things you didn't think of.

Now C++, write this:

class Empty{};

What have you got? You have just lost control of your program, the buggy compiler from those wonderful people at microsoft has thoughtfully supplied a copy construtor, an assignment operator, a destructor and a pair of address-of operators. If you don't declare any construtor, it will declare one for you. All these functions will be public.
you now have:

class Empty{
public:
Empty(); //default constructor
Empty(const Empty& rhs); //copy constructor
~Empty(); //destructor - is it virtual?

Empty&
operator=(const Empty& rhs) //assignment operator

Empty* operator&(); //address-of operators
const Empty* operator&() const;
};


Isn't this an ugly mess?
How can you fully understand your code when the compilers doing it's own thing behind your back?
 

A parting shot on memory management, we are told that in C++, the use of malloc and free should be avoided, instead, use the keywords 'new' and 'delete' for allocating dynamic memory.
Now, write a littlle program that declares a simple array with 'new', then destroy it with 'delete[]'.
Compile it and look at the assembler listing.
What have we got, 'new' is a wrapper that calls malloc, 'delete' is a wrapper that calls free?
So, whats new?
 

From the view of a assembly coder, the advance language is simply, so do not worry about it.as it come to the embedded system. c++ is not a poplar language, maybe it just provide a way to understand the system design with OO method. but c and assembly codig skill is most important. such as function array, macro and so on
 

:) Again, I totally agree that this is not the playing field for C++.

However, C++ doesn't belong to Microsoft.
Moreover, C++ is a multiparadigm programming language which includes more than just OO concept but also generic programming concept. OO allows better abstraction, more modularity and reusability which only benefit larger scale software development. Generic programming allows a clean implementation of data independent algorithms such as in STL.

Everything has its own use.
When people move from assembly to C, they sacrifice some control for ease of implementation of higher level language too.

It's just the matter of picking the right tool for the job.
 

I completely agree with me2please, c++ has nothing to do with microsoft or microsoft compiler. c++ uses the concept of encapsulation an inheritance to ease the use of c for large scale programming. if the compiler from microsoft is far from being perfect it is not a weak point for c++. but as me2please said it is the matter of picking the right tool, for embedded systems which usullay have less than 100K code, it is really unnecessary to use c++.
 

I know C++ has nothing to do with Microsoft, I personally use Borland Builder, but Visual C++ is usually used in commercial software.
Borland complies closer to the standard than Visual C++. But none of them fully support the ratified version.
Back to the original question ahmad asked, if you are good at assembler, you will have no trouble at all learning C and wonder how you ever got along without it. Good luck.
 

hi
i suggest to read a very useful book "embedded c" by Michael J. Pont.
it is so good to explain the c for embedded systems, and it has many examples,
i think it will be good for you.

you can look for the book in the books forume here
salam
eng_ahmed22
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top