Why Assembly Language?

Hi guys,
Assembly language is a low level language designed in 1950's, both system and application programs were written in assembly at that time. There is no question of assembly being very effecient compared to the other high level languages. But it is very cumbersome to write programs in assembly. My question is that where does Assembly language stand today against the high level languages, I mean what can assembly do, that the other langues can't????

I hope you will explain your good points.
Thanks alot!

Hi,

have a look at
Assembly language - Wikipedia, the free encyclopedia - Current Usage

see ya
fra

1 Like

The most vital thing about assembly is that it's freestanding. It makes extremely few assumptions about the environment you're writing code for, and can create code which needs no operating system at all. That's what makes it almost impossible to get rid of.

When you're programming in assembly, all it amounts to in the end is "put these exact bytes in this exact location in memory" except you can give it instructions as well as bytes, and it does the conversion for you. That's precisely the kind of thing you need when writing a BIOS for example, when the computer does in fact start up blindly looking for its very first instruction at a very specific place.

You also need it to write a bootloader, which gets loaded from a hardcoded location on disk then blindly executed from, again, a specific spot inside that location.

You also need at least some of it to write an operating system. That gets loaded by the bootloader and, again, blindly executed starting from a very specific spot.

You don't get a nice, programmer-friendly environment where you can load whatever language you like to do whatever you please until after all these things have already happened. Even after that, assembly language is still useful.

The other thing about being freestanding is that, since machine code is executed by the host processor, there's no interpretation step. That's why you can write a better C compiler in C. C code isn't a program, it's a design which a C compiler uses to build a program out of raw assembly. You certainly couldn't write a better Perl inside Perl.

You can also write other languages in C. Name any language -- Perl, PHP, Java, C#, awk, Python, sh -- and chances are, it was written in C.

1 Like

Am I making a correct assertion that the runtime components of these languages (java, c#, python, etc) contain allot of assembler? What allows for allot of the interpretation in interpreted languages is the fact that there is already allot of code that has been compiled into assembler and is all ready to call on when needed.

LMHmedchem

1 Like

Gabam ,that is a very good question you have come up with.Many people think assembly language is no more used today.But their is lot more to it.It is used primarily for direct hardware manipulation, It iworks wonders for speed optimization because it is more close to processor.

1 Like

Thanks for your complement. One more thing, I have to prove that assembly is faster than c and java. For c, I compiled the hello world program, which has an exetuable of size 50 kb. The same hello world program in assembly that I have assembled has a size of only 15kb, it shows that assembly is faster than c. How can I do the same in case of java, java doesn't give you binary exeutables????

Thanks!

---------- Post updated at 12:58 AM ---------- Previous update was at 12:57 AM ----------

One more thing, I have to prove that assembly is faster than c and java. For c, I compiled the hello world program, which has an exetuable of size 50 kb. The same hello world program in assembly that I have assembled has a size of only 15kb, it shows that assembly is faster than c. How can I do the same in case of java, java doesn't give you binary exeutables????

Because this is homework/classroom work, right?

Basically my question should be put this way, how to produce binary executable of java? I am going to a java forum, thanks for your help!

Sweeping generalizations like that are never entirely true. Some versions of Java have a very good optimizer these days, and can compile parts of itself into native assembly; in rare circumstances it's possible for it to outperform C in a tight loop. I was quite surprised.

---------- Post updated at 09:05 AM ---------- Previous update was at 09:03 AM ----------

Of course they do -- being written in C, they get converted directly to assembly language.

That doesn't mean they're not interpreted languages. Try writing a perl interpreter, in perl, you will get slowdown because of the extra layer of interpretation.

Java programs are run a bit differently than C; they are compiled into Java bytecode, not machine code.
You write your code in a text file with extension ".java". (The file name must be the same as the public class name in the program.) So if the file name is "Hello.java", you compile it using the "javac" compiler -

javac Hello.java

This creates a binary file called "Hello.class" in the same directory as Hello.java. You then feed this class file to the JVM -

java Hello.class

and it runs your program.

tyler_durden