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.

Hard to help people

Status
Not open for further replies.
How do you translate from C to Assembler if you do not know C? :wideyed:

I know enough about C to at least read it and get the idea of what the program is doing. I used C in school where it was required, but no more than I had to do so. It is not hard to beat a high level language in both speed and size.

Ratch
 
Compiler can optimize for size well which probably doesn't make any sense any more, because there's always enough room for code. Although I can bet that you can get the code generated by the compiler and make it smaller.

Compilers are very bad when they optimize for speed because they have no idea how the code is going to be used, which parts need to be fast and which are not, what's important and what's not. Therefore, it's easy to beat the compiler manyfold if you want to speed something up. People use Assembler in such cases.

With the advent of C# and Java, you cannot really use Assembler any more. Therefore many modern software programs run very slow even on modern PCs, sometimes slower than their C counterparts could run on older computers. If I wanted something really fast, such as mining BitCoins (which I don't do), I would write most of the code in Assembler.

BTW: GNU C, in particular, is not very good at optimizing the code. Pascal compiler in Delphi produces better code than GNU C, but nobody uses it :confused:

Now, back to the topic. C++ is a misapproprated language. It doesn't add much to C for "low level" programming. And it falls behind Java in OOP.

I think the reason C++ is used so much is because it is perceived to be cool. You want to hire a programmer, you go to the hiring agent and ask how to do that. The hiring agnet says that all good programmers use C++, so you decide to print an ad requiring C++ experience, 3 years or better 5 years. Job seekers see these ads and start studying C++ to get the necessary experience. Consequently they teach C++ in college instead of C, which is perceived to be obsolete etc.
 
The only programming I prefer to do is PLR and PLC ladder logic on prebuilt systems. :p
 
NorthGuy,

"With the advent of C# and Java, you cannot really use Assembler any more."

Why is that?

Could you or anyone explain why C++ or any high level language is better than assembler. I know that assembler requires an intimate knowledge of the CPU architecture, is not portable, has a steep learning curve, and needs to be documented well. Other than that, could you explain in words, not code, why folks shy away from assembler as if it can't do everything that a high level language can do.

Ratch
 
NorthGuy,

"With the advent of C# and Java, you cannot really use Assembler any more."

Why is that?

Because you cannot attach Assembler pieces to these things as easy as you can do in C. If you write an app for Android, for example, you would need to write an entirely separate Assembler program and invoke it from Java objects. Because of this separate file, you also will have troubles installing this onto the phone. You will go through such thing only if it's really no other way. Therefore people rarely do that.

Could you or anyone explain why C++ or any high level language is better than assembler. I know that assembler requires an intimate knowledge of the CPU architecture, is not portable, has a steep learning curve, and needs to be documented well. Other than that, could you explain in words, not code, why folks shy away from assembler as if it can't do everything that a high level language can do.

Everything is for the purpose. You select what you think is the best for your task. Assembler may be good for embedded stuff for a number of reasons. Assembler is not very good for OOP.

Usually when you want to abstract, OOP languages are a good choice because they abstract you from hardware and implementation details.

Similarly, if you want to be close to hardware, Assembler would probably be the best choice.
 
Ratchit said:
Could you or anyone explain why C++ or any high level language is better than assembler. I know that assembler requires an intimate knowledge of the CPU architecture, is not portable, has a steep learning curve, and needs to be documented well. Other than that, could you explain in words, not code, why folks shy away from assembler as if it can't do everything that a high level language can do.

Imagine an application written on the PC... Windows 8 or something... Coming close to 47 / 48 meg in size.. Now lets see which would be easier to debug!!! A C++ program or an assembled one... It stands to reason that if I wanted I could write an entire application in assembler, I could... But it would take some time and it would be hard to debug... I'm not saying its impossible to debug, just harder.... If you can use C++, then the job WILL be easier..

Anywho... 3V0's thread... Lets get back to topic...
 
Could you or anyone explain why C++ or any high level language is better than assembler.

Well it's not :D

Assembler is a direct conversion to machine code, so (when correctly written) is as small and fast as possible.

A fine example is the old Commodore Amiga - an ancient device that ran at less than 10MHz clock speed, only 512K of RAM, yet multi-tasked and ran games better than IBM type PC's until relatively recently.

For those who remember the Amiga, it was extensively C based - with the OS loaded from floppy disk, and written mainly in C - but a band of dedicated programmers rewrote much of the OS (in particular the disk based OS commands) in assembler when they then where only a fraction of the size, and ran a great deal faster.

As for games, any arcade type games were exclusively assembler - and ran nice and fast, with colour graphics and stereo digital sound - on really VERY minimum hardware.

High level languages are 'better' in that they make it easier for the programmer - by essentially throwing massive power and resources at a project - does it matter if you need GHz processors and GBytes of memory just to run a game?, as long as you have them available.
 
Ian Rogers,

"Imagine an application written on the PC... Windows 8 or something... Coming close to 47 / 48 meg in size.. Now lets see which would be easier to debug!!! A C++ program or an assembled one... "

For me, the assembled one, provided the source was well documented. I always use a debugger and that helps a great deal.

"It stands to reason that if I wanted I could write an entire application in assembler, I could... But it would take some time and it would be hard to debug... I'm not saying its impossible to debug, just harder.... If you can use C++, then the job WILL be easier.."

It all depends on the proficiency one has with the language.

Nigel Goodwin,

"Assembler is a direct conversion to machine code, so (when correctly written) is as small and fast as possible."

I will say Amen to that, Brother.

Ratch
 
Hi,
I am with Nigel and Ratchit regarding Assembler.
I used the Z80A for many years on some fair sized projects, having to work with 64K limit of memory, split into program and data area.

For PIC's I use Basic or Assembler or a mix of both for program writing, which ever is the easiest to get the required result.
Also I use Javascript and jQueuy ui for writing ETO Tools/Quizzes.

I would not criticise the use of 'C' , there is a place for most languages, its what works best for the guy doing the programming.

Eric
 
I find that when programming the PC ... a mix can be used.... I can write routines in assembler and call them from C / C++, this gives the best of both worlds.... All compilers allow you to create Dll's...
Even when I use VB,I can call these routines...
 
I find that when programming the PC ... a mix can be used.... I can write routines in assembler and call them from C / C++, this gives the best of both worlds.... All compilers allow you to create Dll's...
Even when I use VB,I can call these routines...

I agree with this. A mix of skills is very useful. You can use C with assembly etc. But also, learning higher level programming and low level programming complete each other. Highest level of programming is the philosophy.. or the design. And that is language free. Learning to program is not about learning a syntax. Syntax is easy.
 
NorthGuy,

"Because you cannot attach Assembler pieces to these things as easy as you can do in C. If you write an app for Android, for example, you would need to write an entirely separate Assembler program and invoke it from Java objects. Because of this separate file, you also will have troubles installing this onto the phone. You will go through such thing only if it's really no other way. Therefore people rarely do that."

That is only because the people who encourage you to write apps did not provide the tools for assembler like they did for C. That problem in not due to any inherent defect in assembler.

Ratch
 
Of course not. That is because they intentionally designed their systems that way. Therefore Java and Assembler don't mix well.

It is more correct to say that the Java and assembler combination are not supported, whereas Java and C are supported. As long as everyone understands that if an assembler application is purposely crippled, then that is the reason it does not "mix" well with Java, not the assembler language itself.

Ratch
 
It is more correct to say that the Java and assembler combination are not supported

It is hard to mix Assembler (or anything else for that matter) with Java because they designed Java this way. Thay wanted to abstract from the hardware, and if you want it, that's what are you going to get with Java.
 
well, you can write in java assembler aka bytecode if you really want to ;)
I once had to write a compiler from a made up simple language into java bytecode as a school assignement. Not much fun in there.
 
Ok.. so, how would you implement dependency injection in embedded applications? Sometimes it is hard to separate hardware from software, but it can be done if you are smart enough.. right?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top