 |
|
 |
The is the only language that gives you the most knowledge you will ever need to know about programming.
|
|
|
|
 |
|
 |
In the 1980's assembly language was the way I went.
I designed a cad program that was 330,000 lines.
Assembler taught me to be tidy with my code and make it readable as trying to go back over something uncommented is a nightmare. Assembler also taught me about programming detail like writing directly to the video card hardware. These days you cant do that in assembler as Win7 will kick up a fuss and not allow it.
|
|
|
|
 |
|
 |
I think I found this article on a right time. I know a few high level languages which I learned myself. But in case of assembly language, I think I am going to fail. Right now I am struggling with FASM on a windows machine for two weeks. I couldn't gain more than writing few lines to print something on a DOS console.
Can you please suggest me a good assembler, book, operating environment and debug tool for a beginner?
|
|
|
|
 |
|
 |
Thanks for reading and leaving feedback. Just hang in there, if you practice, you will learn. You do have to write a lot of code to do very little, however, this is because you are spoon feeding the processor it's instructions. You gain an understanding of how your machine works.
As far as books go I'd recommend Assembly Language Step by Step http://www.amazon.com/Assembly-Language-Step-step-Programming/dp/0471375233
An assembler try NASM or MASM
And for a debugger, try DEBUG.
I hope this helps.
Thanks again.
|
|
|
|
 |
|
 |
This link http://www.roesler-ac.de/wolfram/hello.htm[^] lists 428 different programming language examples that all produce the same result: to print 'Hello World' This is a real eye opener into how convoluted even the simplest task can be in some languages! It would have been even more interesting if the author of the article could have stated the size of the executable for programs that produced an executable.
I think computer viruses should count as life. I think it says something about human nature that the only form of life we have created so far is purely destructive. We've created life in our own image.
Stephen Hawking
|
|
|
|
 |
|
 |
Thanks a lot for the resource and comment.
|
|
|
|
 |
|
 |
Assembly is not as widely used in PC programs as it is in embedded systems. The author has not stated this fact to the readers.
|
|
|
|
 |
|
 |
A good understanding of the "Portable Executable" file format is helpful for anyone who wants a better understanding of how an EXE or DLL works. I am interested in creating a vbscript compiler so understanding what is under the hood is a must.
Thanks again for the article.
http://en.wikipedia.org/wiki/Portable_Executable[^]
|
|
|
|
 |
|
 |
I do agree that writing code in assembly gives programmes the feeling that they have achieved something, but most companies would not like to see assembly code in their applications.
The reason being that the time to write and maintain assembly code is many orders greater than using high level languages, thus introducing spiralling costs.
Even writing something as simple as a simple Notepad type of application will take weeks.
I cannot think of an employer who would want to pay you per hour the same amount as someone who can produce the same application within hours using a high level language with more than adequate performance.
Not only is time money but also opportunity, and being able to provide features in the shortest possible time is as important.
Also I cannot thing of an employer who would rather see an application being maintainable by all developers than a special few.
I have found that most of the time that most of the performance problem is either as simple as something within an algorithm or as drastic as a need to change something within the architecture of the application to obtain better performance.
I have used assembly to obtain better performance, but would say that the benefit was not that great.
I do agree that knowing assembly language does give you more an academic advantage, as you would understand the underlining architecture, but would be careful to say it gives you an overall benefit.
|
|
|
|
 |
|
 |
Thanks for the response.
I never said that assembly language was cost effective. I simply stated that we can benifit from learning a language that close to the machine.
Thanks
|
|
|
|
 |
|
 |
danielj wrote: I do agree that writing code in assembly gives programmes the feeling that they have achieved something, but most companies would not like to see assembly code in their applications.
A certain cheap little micro with 0.5KW of code space and 24 bytes of RAM costs $0.33 in quantity. A similar micro with half the code space and 16 bytes of RAM is three cents cheaper. If one is writing code which will go into 100,000 devices, and if using assembly code allows the code to fit in the smaller device, that would save $3,000. If writing the program in assembly code would take six months longer than writing it in C, that would be a silly trade-off. On the other hand, if it would take only one more day of coding, $3,000 for a day of coding could be a pretty good payoff.
|
|
|
|
 |
|
 |
I am sure that you will spend approximately 3 to 4 times more time writing your application in assembly than in a high level language.
You should not only think of the time you spend writing your application but should add time for testing, and maintaining it after it has been shipped.
Somewhere you also need to manage the complexity you added by using assembly language.
Thus in the short run you may have an extra 3,000 but may loose it in the long run.
I personally prefer my programming team spending as little time as possible writing their application and use as must time as possible on testing to ensure a near error free application.
Most customers that I worked with is more than willing to pay that extra one or two dollars for a reliable application.
I am more than willing to live without the quick $3,000 and rather have a reliable flow of income because my customers know that they can trust my work.
I do believe knowing the inner workings of assembly and using one to say 5 lines of assembly code in your application is definitely an advantage, but an advantage that should be carefully managed.
|
|
|
|
 |
|
 |
Thanks for the reply. You must understand that this article is not an advertisement for developing in assembly. It simply illustrates the benefits of learning assembly language to help you better design/optimize the code that you write in a modern high level language.
Thanks again,
|
|
|
|
 |
|
 |
danielj wrote: I am sure that you will spend approximately 3 to 4 times more time writing your application in assembly than in a high level language.
That depends a lot on the application. There are some applications where trying to get the compiler to do what is necessary may actually be harder than coding something in assembly language. This is especially true if the application requires that one do something highly "unusual" (e.g. having an interrupt disrupt the flow of the underlying application). There are others where a high-level language is clearly the way to go.
One thing I have found is that the relative advantages of assembly language are often greater for small pieces of code than for large ones, while the added maintenance cost is much less with small programs than with large ones. The advantages of assembly code in such cases usually have more to do with speed than code size, but for battery-powered applications, improving the speed of operations may improve battery life and/or allow one to use cheaper power-handling components).
I'm reminded of a game I wrote for the PC around 1988. About 1,200 lines of Pascal and 30 lines of assembly code. The program spent 90% of its time in the assembly-code portion, which ran five times as fast as the best possible Pascal code. The guts of the assembly code portion was something like:
copyLp:
mov si,[bx]
add si,ax ; Shape offset
mov di,[bx+2]
add bx,4
movsw
add di,dx ; dx holds constant 0x0050
movsw
add di,dx
movsw
add di,dx
movsw
add di,3F10h
movsw
add di,dx
movsw
add di,dx
movsw
add di,dx
movsw
loop copyLp
Nothing complicated--just an inline-expanded sequence of memory copy instructions, but on an 8088 it executed way faster than anything the Pascal compiler could produce (a C compiler could have done a little better, but still nowhere near as fast as the assembly code).
I could have written more of the game in assembly code, but there was no need. The game could draw almost as many objects as I wanted each frame, and something like the 10% speed boost by having dx hold a constant did more to improve things than would a 100x speed boost on all the non-assembly stuff.
|
|
|
|
 |
|
 |
I had a similar experience in the early 90's. I was working on an application that searched a text file for specific patterns using wildcards (standard DOS style '*' and '?' replacements). Due to the nature of the application, I had to have an execution time of less than a second. Borland's Pascal, as good as it was, couldn't do the wildcard searches in time. A simple replacement of the core search functionality with a small assembler routine reduced the execution time to less than 1/3 of a second.
I certainly don't advocate writing huge sections of critical business systems in assembler, but there are times and situations where it's definitely an advantage to be able to drop to that level.
|
|
|
|
 |
|
 |
nice!
really! I've started learning assembly in this mouth, it's really easy than HLP, I'm shocked! I can't explain it, but assembly is cool, easy we don't need a complex imagination in instructions, and we create a real programs can be executed directly in CPU also memory etc... WOW! also we can create with it a small OS for surpassing Linux (just kidding ^_^)
okay, maybe because I'm beginner I see assembly as magic programming language!
|
|
|
|
 |
|
 |
Wow.. If only I had started with assembly language.. That's an awesome programming language to begin programming with!
|
|
|
|
 |
|
 |
Although I can see your desire to gain leverage over competitor developers, the overall usefulness, in my humble opinion, of learning assembly is it's use for assembly implementations and debugging as the other commenter suggested. To truly understand memory management of a data type, you must study language dependent data types and allocation of memory for these types. Understanding local memory allocation is the most significant part of coding a solution that handles memory properly.
Although gaining a knowledge of assembly language could be beneficial depending on the programs you are developing, I do not see a significant reason to study such a topic unless you want to write your own compilers, etc. With the time it takes you to learn assembly to an advanced level, you could have easily maximized your efficiency with data type memory management in your native language.
Just my thoughts, please don't take this as an attack.
~W3bdev
|
|
|
|
 |
|
 |
Great idea. Though, the article seems a little thin without a basic tutorial
|
|
|
|
 |
|
 |
Thanks for the feedback, however, this article illustrates why a high level developer can still benefit from learning assembly, now how to code in assembly.
Thanks.
|
|
|
|
 |
|
 |
James,
Great article and the points you make about the benefits of learning assembly are well taken. As an embedded systems engineer for over 2 decades, I have seen my typical dev environments evolve from assembly-only to "C", C++ and even C# these days. But the years of early experience with assembly taught me invaluable lessons that last to this day.
I would however add that a small code snippet might drive home the differences in efficiency between high-level languages and assembly for those who don't wish to take the time to delve deeper into learning actual assembly. For example, populating a simple string buffer in 2 code forms (assembly vs. C++, for example) could shock people when they see the overhead that is involved in high-level languages for even this simplest of tasks.
Just a thought! Nice work.
Cheers, Bill
|
|
|
|
 |
|
 |
Thank you so much for your positive input.
I'm sad to say that I have just started my journey into learning assembly so I don't have much to offer in the line of examples.
If anyone here would like to assist in this area, I think it would greatly benifit the article as well and I would greatly appreciate the gesture.
Thanks again,
Bryan James.
|
|
|
|
 |
|
 |
I used to find that my C++ compiler output better assembly than I could write - although I was always far better at C++ than I ever was at assembly so that would go some way to explain it
|
|
|
|
 |
|
 |
You should mention that knowing assembly language can also be incredibly useful when you regularly debug C++ code.
Ash
|
|
|
|
 |
|
 |
Thanks for the input.
I will work to add a section on debugging experience gained by learning assembly.
Thanks again for the input.
|
|
|
|
 |