Jump to content

advantage of assembly programming

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
13 replies to this topic

#1
hkp

hkp

    Learning Programmer

  • Members
  • PipPipPip
  • 37 posts
hello friends, I do not anything about assembly programming. can any one tell me the why assembly language is used. I mean to say the for which purpose it is used. And I also want to know that what is the advantage as well as disadvantage of the assembly language.

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,822 posts
Assembly is used for extremely low-level programming. Basically, when you need direct access to the hardware, this is your language. The code tends to be extremely fast. The downside is you have limited tools or protections.

Imagine gutting all the safety devices from your car, stripping out guard rails, etc. You strip off the shell and replace everything with a cloth shell and plastic tubing. You will get a light fast car, but if you crash it'll be messy.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
marwex89

marwex89

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 10,720 posts
Lol, nice one there, Winged... I might add that if you use assembly code you will often/usually need to write a LOT more code than with other (higher level) languages, as with assembly you have to do EVERYTHING yourself.. This means more control, allowing higher speeds, but also reduced productivity (and readability of your code). My father has used assembly a lot working with embedded systems, often with very cheap processors (and other hardware) where assembly is the only option.

Shouldn't this thread be moved to an appropiate forum? This is not a tutorial? :S
Hey! Check out my new Toyota keyboaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,822 posts
Moved.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#5
Sysop_fb

Sysop_fb

    Programmer

  • Members
  • PipPipPipPip
  • 160 posts
Define 'a LOT more code'.
Are you saying as in reference to more lines of code? Or the character count of the source code? I got a 800 line c++ source code file that I'm fairly certain has more characters in it then every assembly source code file on my laptop.
And I use assembly when I want to do something very specific or where speed is crucial.


Even if you never use asm, I would still recommend reading a beginners book. A good beginners assembly book will teach much more then just a programming language. You'll learn how things actually happen.

#6
hkp

hkp

    Learning Programmer

  • Members
  • PipPipPip
  • 37 posts
Thanks for the replay. But mainly I want to know that in which area or field assembly language is use.

#7
Sysop_fb

Sysop_fb

    Programmer

  • Members
  • PipPipPipPip
  • 160 posts
The knowledge you gain from learning assembly will benefit you everywhere, irregardless of what language you're using.

When you do this in C
char buffer[20];
Do you know what's actually happening? Or do you just know what your C book told you is happening on their system? When you reference a char in buffer do you know how it's actually getting referenced?
Do you know why OCaML sucks at doing for loops compare to C? Or do you just take what someone on a forum tells you.

Besides the learning benefit, I use assembly when I need to squeeze optimization out of some code or if I need to work directly with hardware.

#8
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,822 posts
To get a sense of "a lot more code", take a C++ program and use the compiler to compile it to assembly and open the resulting file.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#9
marwex89

marwex89

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 10,720 posts
Thanks for clarifying, Winged... I meant exactly that. The C++ code would compile into physically more assembly code. I guess weird and unusual exceptions are available for our amusement, but that's the general rule.

@ hkp: Assembly today is mostly used in embedded systems, not much for personal computers (because it is a lot of work to program a Windows application in assembly as compared to e.g. C - the possible speed improvement is not worth it, and C compilers are so good that the speed is great anyway). Virus programmers use assembly at times, though (targeting PCs). So do crackers and hackers etc. Assembly gives them easier access to low-level functionality in the computer, and they can reduce unnecessary code => reducing program size. These things are often important to them. In larger applications, sometimes only a critical part of an application is written in assembly, often a part that needs to run really fast or work directly with hardware. Sysop_fb made a good point that simply knowing assembly will be helpful in a lot of cases, you don't necessarily have to program in it.

Just keep asking questions, dude, we'll try to answer you. :)
Hey! Check out my new Toyota keyboaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

#10
JewFro297

JewFro297

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 224 posts
I think you are asking what kind of jobs will use assembly? Most of the time it is used only for drivers and parts of a program that need extreme speed optimization, or to control hardware more efficiently than higher level languages. It would definitely look good on a resume if you knew how to program in assembly.

I am learning assembly right now, and even though I havn't even written my first program I have learned a ton about how memory management and processor cycles work. It is worth it to learn assembly for sure, but a lot of people never even touch the subject.

(edit)
Didn't realize how old this post was... sorry I'm new to this lol

#11
innerLOL

innerLOL

    Newbie

  • Members
  • PipPip
  • 29 posts
asm should be used by beginners, many quit programming because compilers (or IDE's to be exact) are too complicated for start. First you must know what is exception, overflow, library, only then you can try to understand those cryptic errors.

#12
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,822 posts
Assembly is simply a low-level programming language that does very little for you. This is a double-edged sword, in that it makes you do EVERYTHING, but also doesn't add a lot of garbage to your program.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog