Why use Assembly language-VBForums
Results 1 to 34 of 34

Thread: Why use Assembly language

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2005
    Posts
    167

    Question Why use Assembly language

    I don't know Assembly language. I just know that it is Low Level Language.
    I wonder why one still uses Assembly language. Now there are many High Level Language that is easy to develop application. Could one tell me the advantage of using Assembly language today?

  2. #2
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,981

    Re: Why use Assembly language

    Assembly language is very useful for routines that require high speed and highly optimized code. It is also required for Boot Loaders (i.e. LILO, GRUB, etc...) and Operating Systems.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Oct 2005
    Posts
    167

    Question Re: Why use Assembly language

    So it means that we use Assembly Language because of high speed.
    Are there any advantages of Assembly Language?

  4. #4
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,718

    Re: Why use Assembly language

    Quote Originally Posted by ychhuong
    So it means that we use Assembly Language because of high speed.
    Are there any advantages of Assembly Language?
    So, if I will say: The advantages are high speed and highly optimized code (as kasracer was saying)
    Will you still ask what are the advantages ?

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Oct 2005
    Posts
    167

    Question Re: Why use Assembly language

    I think that if the advantages are high speed and highly optimized code, it is not the reason that some body still using Assembly because today computer are very high speed.

  6. #6
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,718

    Re: Why use Assembly language

    Quote Originally Posted by ychhuong
    I think that if the advantages are high speed and highly optimized code, it is not the reason that some body still using Assembly because today computer are very high speed.
    Well, if you need to make a super fast program for... say, a few hundred people, what do you choose ?
    Tell ALL your customers to pay thousands of extra $ to buy super fast computer ? (on top of the cost of your program)
    Or invest extra time and effort (and $) to make a super fast program in ASM, and tell your customers the computers they have now is fine for your program ?

  7. #7
    Noodly Appendage wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,669

    Re: Why use Assembly language

    Most high level languages are very slow in comparison to ASM as has already been stated but this is mainly due to the multiple levels of abstraction that separates native binary from the HL language in question.

    High Level languages have HUGE runtime dependancies, ASM can be optimised to have none whatsoever which is why they are indeed used in bootstrapping and OS installers, it lets you run a program on a completely blank computer.

    The other benefits of knowing ASM include gaining a much deeper understanding of how a computer works at the lowest level. Thi definitely affects the way you write code in HLL too.
    I don't live here any more.

  8. #8
    Frenzied Member yrwyddfa's Avatar
    Join Date
    Aug 2001
    Location
    England
    Posts
    1,250

    Re: Why use Assembly language

    Quote Originally Posted by wossname
    Most high level languages are very slow in comparison to ASM as has already been stated but this is mainly due to the multiple levels of abstraction that separates native binary from the HL language in question.

    High Level languages have HUGE runtime dependancies, ASM can be optimised to have none whatsoever which is why they are indeed used in bootstrapping and OS installers, it lets you run a program on a completely blank computer.

    The other benefits of knowing ASM include gaining a much deeper understanding of how a computer works at the lowest level. Thi definitely affects the way you write code in HLL too.
    Hmmm C# vs ASM . . . .

    I didn't want to bring up the bloated nature of modern HLL, but hey, Wossy . . . .
    "As far as the laws of mathematics refer to reality, they are not certain; and as far as they are certain, they do not refer to reality." - Albert Einstein

    It's turtles! And it's all the way down

  9. #9
    Frenzied Member the182guy's Avatar
    Join Date
    Nov 2005
    Location
    Cheshire, UK
    Posts
    1,473

    Re: Why use Assembly language

    if you know assembly language, stick with it, it is THE BEST, the compiler does not mess with your code, it does not change any of the ASM code, it simply directly, converts each instruction to machine code, and thats it. It wont check for extensive errros like VB or others, such as 'runtime error file not found' - none of that because the compiler has not messed with your code.

    Other advantages...
    The programmer has COMPLETE control over how the program works, unlike other high level languages.

    Final advantage, filezise - a program which only displays a messagbox then quits (including the windows DLLs)

    ASM: 3kb
    VB6: 16kb

    ^thats a huge difference
    Chris

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Oct 2005
    Posts
    167

    Question Re: Why use Assembly language

    Thank all. I have 2 more question.
    What is ASM?
    What do i need if i want to develop application using Assembly Language?

  11. #11
    Frenzied Member yrwyddfa's Avatar
    Join Date
    Aug 2001
    Location
    England
    Posts
    1,250

    Re: Why use Assembly language

    Assembly Language is the closest abstract to machine code. In many cases, you might have a processor directive say 0010101001010101010111111111000111, in assembly - instead of remembering all those 1, an 0's you might have to remember MOV es,ax

    (I have no idea, btw, what that binary sequence means!)

    You then use an assembler to convert your instructions into machine code - with no interference or optimisation done by the assembler.
    "As far as the laws of mathematics refer to reality, they are not certain; and as far as they are certain, they do not refer to reality." - Albert Einstein

    It's turtles! And it's all the way down

  12. #12
    New Member
    Join Date
    Mar 2006
    Posts
    4

    Resolved Re: Why use Assembly language

    Assembler is still a high level programming language and is the next step up in making code easier to understand or human readable, it is still converted to machine language in order for the computer to understand it which is the lowest level.

    It's quicker to develop applications using the latest higher level language tools and the differences in performance these days is hard to notice as most machines tote enough power it doesn't make much of a real difference.

    But in terms of speed, effeciency, can easily create your own programming language and re-invent the wheel, and portability assembler stands out a bit.

    The downside is there's alot missing in terms of all the latest tools and features for using syntax for simplicity and rapid application development.

    The programs are small, lightweight, and don't require bulky runtimes which need to be downloaded, plus you develop totally for free.

    Size and speed isn't so much an issue as time, money, and ease of development these days, plus, people aren't as deeply educated and focus is only on working with the IDE more so than how the internal code itself works, this develops false positives and leaves many security exploit possibilities open in the higher level languages.

    A big comparison would be this, let's say you needed an application with moderate to complicated functionality complete for commercial business application for a client, you aren't well skilled in assembler but could popup something in short amount of time in higher level language, if it takes a few to several years to complete in assembler and you only have a few days to a week your best bet is higher level language to get it done now and get paid.

    Either way, it's all about picking the language that you're comfortable working with and can understand, don't be afraid to try something new and keep developing!

  13. #13

    Thread Starter
    Addicted Member
    Join Date
    Oct 2005
    Posts
    167

    Question Re: Why use Assembly language

    I don't know assembly language at all. I don't know where to start. I don't have any assembly book and assembler. Which book should i read(for beginer)?

  14. #14
    New Member
    Join Date
    Mar 2006
    Posts
    4

    Thumbs up Re: Why use Assembly language

    There are many flavors but the easiest form is the Win32/Microsoft Assembler, it's what the majority of the other programming languages are built from except for the newer .NET which uses ILASM.

    I'd start here you can get free editor with lots of info.:
    http://www.masm32.com

    Here is a place for some source code and other tutorials by ICZelion:
    http://win32assembly.online.fr

    The Win32 API Guide comes in handy when first learning and APIViewer 2004 is nice for quickly finding standard declarations/structures/types/constants.

    And if you ever make your own programming language and IDE and/or re-invent OOP programming style let me know and I'll check it out, lmao.

    -Goodluck!

  15. #15

    Thread Starter
    Addicted Member
    Join Date
    Oct 2005
    Posts
    167

    Re: Why use Assembly language

    Thanks

  16. #16
    Addicted Member
    Join Date
    Aug 2005
    Location
    York
    Posts
    197

    Re: Why use Assembly language

    Just a summarised answer to who uses x86 assembly:

    1.) Compiler & Assembler Developers (Duh!)
    2.) Operating System Developers (Essential)
    3.) Driver Developers (Essential)
    4.) Game Developers (Many major-titles have hand-written assembly to optimise the game performance)
    5.) Database Developers (Speed is a essential part of major databases)
    6.) Programmers with assembly knowledge (there's need for speed)

    Many developers use assembly in conjunction with C - as C is easier to maintain than assembly. Usually they have a C version of a piece of code make a second optimised version in assembly.

    However, there are programmers that do an entire program in assembly. However, these tend to be extremely experienced assembly programmers who know how to keep their code neat and tidy.
    I don't recommend this until you are quite proficient in assembly language. So i suggest you learn some high-level language like C - and then dig into some assembly - and use it inline. This tends to be the more favoured approach.

    Cheers.

  17. #17
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,705

    Re: Why use Assembly language

    Eh... you will never use assembly programming on a pc architecture for any job anymore. Assembly is like the black ninja magic of martial arts. It is not hard at all, just time consuming - and time is costly in software development.

    For a beginner, I would suggest learning 6502 assembly. It was the processor used in the old Atari's and Commodore and Apple computers, and the original Nintendo NES. The processor has only 3 registers you work with and really only used 20 commmands that you work with, and there's an even a .Net application for simulation! That way you can follow along in the numerous books written for it most all free on the web and see the results:

    http://www.atarihq.com/danb/6502.shtml (you want the Sim6502.Net application)

    Her'e's a quick 6502 Assembly first steps (not a long read and a good introduction)
    http://www.geocities.com/oneelkruns/asm1step.html

  18. #18
    Addicted Member
    Join Date
    Aug 2005
    Location
    York
    Posts
    197

    Re: Why use Assembly language

    Quote Originally Posted by nemaroller
    Eh... you will never use assembly programming on a pc architecture for any job anymore. Assembly is like the black ninja magic of martial arts. It is not hard at all, just time consuming - and time is costly in software development.

    Eh......??? you mean OS developers don't use assembly?
    It certainly not a requirement anymore - but it is useful knowledge. And with that knowledge, you tend to incorporate it in some programs you write.

    Cheers.

  19. #19
    Frenzied Member yrwyddfa's Avatar
    Join Date
    Aug 2001
    Location
    England
    Posts
    1,250

    Re: Why use Assembly language

    You shouldn't use assembly; you should design the circuits from scratch
    "As far as the laws of mathematics refer to reality, they are not certain; and as far as they are certain, they do not refer to reality." - Albert Einstein

    It's turtles! And it's all the way down

  20. #20
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,705

    Re: Why use Assembly language

    Quote Originally Posted by Raedwulf
    Eh......??? you mean OS developers don't use assembly?
    It certainly not a requirement anymore - but it is useful knowledge. And with that knowledge, you tend to incorporate it in some programs you write.

    Cheers.
    You could fill the all the currently employed assembly OS developers in the world onto 1 -maybe 2 - Boeing 757's. The rest use C.

  21. #21
    Frenzied Member the182guy's Avatar
    Join Date
    Nov 2005
    Location
    Cheshire, UK
    Posts
    1,473

    Re: Why use Assembly language

    if you code the project that your boss gives you aswell as VB.NET or whatever, you will probably get a BIG FAT ass bonus. Anyway the reward of just being able to program in the lowest level is good enough for me.
    Chris

  22. #22
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,692

    Re: Why use Assembly language

    Everyone's forgetting a very huge world market - most small embedded systems are written in assembly. There's really not much need for listboxes in the controller for a microwave oven.

    Anyone in Hong Kong can see a nice little assembly-language system that's been running for decades - the Hong Kong Space Museum Planetarium is run on 3 Z-80 CPUs, and all the code was written in assembler - back in the Dark Ages.

  23. #23
    New Member
    Join Date
    May 2006
    Posts
    15

    Re: Why use Assembly language

    I think, that u shouldn't comapre Assembly with High Level languages.
    There are a lot of different structures, extened assembler use mnenomics and so on...

    Althought I don't use assembly, but as I remember it's extremely fast, because you can communicate with the machine in its languages(binary, hex etc.) directly, and it don't need to waste time translating this one to understandable methods, functions.

    Th other side, that it's a very complicate and hard-to-learned language, but don't try to write i.e. a whole kernel in HLPL.

    My last oppinion, that always must a Low level language, and it not depends on the year where we currently live in

  24. #24
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,692

    Re: Why use Assembly language

    Quote Originally Posted by reloader81
    Th other side, that it's a very complicate and hard-to-learned language, but don't try to write i.e. a whole kernel in HLPL.
    Why not? The entire PCDOS was written in assembly. So was CP/M, ISIS, SOLOS, TRSDOS, the Mac OS, the Apple OS ... whole entire operating systems. Windows and Linux could be written entirely in assembly, it's just more efficient to write graphic operating systems in a higher level language. (All of CP/M was around 4k of 8 bit code.)

    (BTW, assembler is a lot simpler than, say, VB - it's not complicated at all.)
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  25. #25
    Addicted Member
    Join Date
    Aug 2005
    Location
    York
    Posts
    197

    Re: Why use Assembly language

    Once you understand the fundamentals - say registers, instructions and how they work - basically how a computer works, assembly language is easier than any other language - because what you see is what you get.(unless the model of processor has bugs - which it sometimes has )

    The difficult part of assembly is maintenance - it needs to be well commented because unless your fellow programmers understand assembly really well, understanding other people's assembly code is a real *****. Another small issue is implementing - its easier to work out algos in HLL and then port them to assembly.

    But all in all - knowledge of assembly is essential for any HLL - as it helps optimise code and create decisions in efficiency. This may not apply for Java/.NET unless you want to learn the ILDASM and Java byte codes assembly - this might be useful - but maybe less so.

    Major games, somewhere along the line make use of assembly language - especially when using newer instruction sets on the processor e.g. SSE2, SSE3 because compilers find difficulty optimising parallelisation. However, some compilers (I think MSVC and Intel?) now have methods like loading 4 floating pt stuff into a xmm register etc. so it hints to the compiler what to do
    Alternatively, just using inline assembly is sufficient.

    Another rant on assembly from me .

    Cheers.

    Raedwulf

  26. #26
    Moderator
    Join Date
    Jan 2005
    Location
    Sydney
    Posts
    13,621

    Re: Why use Assembly language

    Quote Originally Posted by nemaroller
    You could fill the all the currently employed assembly OS developers in the world onto 1 -maybe 2 - Boeing 757's. The rest use C.
    I dare you to write an OS that boots, in C. The bootstrapper must be written in ASM. Usually speed intenstive parts of the kernel too. The non-intensive areas are written in C - some in C++.

    MS researchers have been developing an OS - I think it was called "Singularity" or something - which is largely written in C#. This gives it type safety and garbage collection and all those wonderful things you get in a managed environment. Still, it was considered quite a feat that they managed to write even parts of the kernel in .NET - the rest in C and of course ASM to get the whole thing working.

    If you were referring to the whole OS the yes of course you'd never write the whole thing in ASM. But you can't run the thing without it, so it's essential knowledge for anyone trying to get their own OS working. And to say you'd never use it for any PC job is quite clearly wrong as examples have been shown in this thread.

    ASM is most definitely not a high level language. It is the lowest level of anything that could be reasonably called a "language" - one step above raw machine code. A higher level language, but still not a complete HLL, would be something like MASM - which incorporates macros to give something along the lines of C: it has structures etc. with simple syntax so you don't have to write every line in pure assembly.

    There are "generations" that languages can be classified into - look them up on Wikipedia:
    http://en.wikipedia.org/wiki/First-g...mming_language
    http://en.wikipedia.org/wiki/Second-...mming_language
    http://en.wikipedia.org/wiki/Third-g...mming_language
    http://en.wikipedia.org/wiki/Fourth-...mming_language
    http://en.wikipedia.org/wiki/Fifth-g...mming_language

    The vast majority of us, most of the time, would be using 3rd-generation languages - C, C++, VB, .NET, etc.; and 4th gen to a lesser extent (SQL etc.)


    Also, agree 100% with Raedwulf here:
    Quote Originally Posted by Raedwulf
    But all in all - knowledge of assembly is essential for any HLL - as it helps optimise code and create decisions in efficiency.

    Side note: I often see people use the word "assembler" to refer to the language - "assembler" refers to the the tool which converts assembly language into machine code.

  27. #27
    Addicted Member
    Join Date
    Aug 2005
    Location
    York
    Posts
    197

    Re: Why use Assembly language

    Side note: I often see people use the word "assembler" to refer to the language - "assembler" refers to the the tool which converts assembly language into machine code.
    Yes, I see that problem a lot - but I guess we can forgive them because a lot of programmers' native language isn't english. Mine is Visual Basic .

  28. #28
    Fanatic Member damasterjo's Avatar
    Join Date
    Nov 2005
    Location
    In front of my Comp DirectX7 EXpert
    Posts
    819

    Re: Why use Assembly language

    I just wanted to honestly say that I really enjoyed reading this thread and will probably learn some ASM sometime now. Thanks for the detialed discusion.

    (PS Im glad the character counter thing is gone now, that thing lagged like a beast!)
    Software languages known:
    Qbasic - TI-Basic - Liberty Basic - Visual Basic 6
    Software API's known:
    Directx 7 and 8
    Internet languages, in the process of learning:
    HTML - JAVASCRIPT - PHP - CSS - MYSQL - AJAX
    New SEO Project Water Damage Mold Damage Fire Damage Flood Damage

  29. #29
    Addicted Member
    Join Date
    Aug 2005
    Location
    York
    Posts
    197

    Re: Why use Assembly language

    Welcome aboard the asm train

    I recommend you to start with either MASM or FASM.
    They have slightly different syntaxes, but otherwise if you know one, its easyto pick up the other.

    Advantage of MASM:
    - Better tutorials
    - Can assemble asm listings from MS compilers more easily(but some can't be reassembled)
    - Supports debugging information

    Advantage of FASM:
    - Faster assembling than MASM
    - Supports linking within the assembler (so you don't generate obj -> then link them like a compiler, but gen exe files straight from asm)
    - Better code generation (Generates smallest instructions/optimised assembly codes)
    - Actively developed (updates 4/5 times a month!) / bug fixes come very quickly

    HLA:
    - Not tried it but it sounds good(slow though/bascially a syntax translator from HLA to other assembly languages.)

    Advantage of these over other assemblers:
    - Very good support (FASM forums are very friendly - so are the masm ones)
    - Good Macro Support

    I've posted links to tutorials elsewhere on this forum- and i don'thave time now to list out the links again...cheers anyway.
    Last edited by Raedwulf; Jun 6th, 2006 at 02:48 AM.

  30. #30
    Noodly Appendage wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,669

    Re: Why use Assembly language

    I started writing ASM for intel chips last year and I've done almost none this year.
    But I've recently started playing with PIC chip programming in GPASM (Gnu PIC Assembler).

    Basically the only way to write good programs that run on PIC chips is to write them in ASM. There simply isn't enough ROM space to allow things like C libs to reside on the chips themselves so you end up writing everything the low level way.

    Its great though because these little chips are pretty fast (4MHz - 20 MHz depending on your oscillator) and you can do a hell of a lot with them with hardly any complex electronics knowledge.

    Intel ASM is a joy to use because it has a lot of registers and HUGE amounts of ram on modern machines. PIC asm is a joy because the instruction set is small and there is a great challenge in getting your code small and fast enough to run on a PIC.

    I recommend PIC programming to any hobbyist programmer.

    useful resources...
    www.microchip.com (downloads, datasheets)
    forum.microchip.com (decent forums for beginners and pro's alike)
    www.maplin.co.uk

    GPASM is for linux, for windows use MPLab (free download from microchip.com)
    I don't live here any more.

  31. #31
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,692

    Re: Why use Assembly language

    Quote Originally Posted by wossname
    Intel ASM is a joy to use because it has a lot of registers and HUGE amounts of ram on modern machines. PIC asm is a joy because the instruction set is small and there is a great challenge in getting your code small and fast enough to run on a PIC.
    Hello World. Intel? Probably 32k, at the very least, until we get to Vista. PIC? Depending on the display, maybe 20-30 bytes. Slight difference.
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  32. #32
    Noodly Appendage wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,669

    Re: Why use Assembly language

    I never said PIC == intel.

    I was merely saying that they are both good. However most of the rest of your reply made no sense at all.
    I don't live here any more.

  33. #33
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,692

    Re: Why use Assembly language

    I wasn't trying to contradict you - just pointing out that you can do an awful lot in a little PIC, while HLL programming in Windows is bloatware even for the smallest function. I did a little binary counter in a PIC, outputting to a 10-LED display, in about 25 bytes. Even writing a .com program for a PC takes at least that much just to start and end the program if you want to interact with the OS at all. (Unless you use something like FORTH )
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  34. #34
    New Member
    Join Date
    Aug 2011
    Posts
    3

    Re: Why use Assembly language

    Machine language = Binary (0,1)
    Assembly language = machine language but summarised
    C = Summarised Assembly language
    VB = compiled from C

    Got it? Its the lowest form of language. If you have problems in high level language and it cannot be solved you should try debugging with ASM. If again problem in ASM then try 0,1 :P

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.