|
-
Mar 17th, 2003, 03:44 AM
#1
Thread Starter
Addicted Member
NuB-Why should I learn ASM?
Can someone explain pros/cons of learning ASM other then C++ or another language. Thank You
Sonikku`- First Days of VB
[vbcode]
Dim Text1.Text as String
[/vbcode]
<Sonikku`> Whats wrong with this code, i keep getting an error about reserved keyword?
<od`Sinchro> LOL!
<Sonikku`> ?
-
Mar 23rd, 2003, 03:54 AM
#2
You'll get along without ASM. Yet it is a good language to learn, not as a single language but rather as an amendment to other languages, esp. C/C++. It will teach you things about the workings of a computer and will help you making your code more efficient even without using it. You can use it to make time-critical parts of the code really fast. You can use it to make a bootstrap if you ever feel like it, it's an interesting thing to do.
I see no pro for learning ASM rather than another language, but I see no con for learning ASM in addition to another language (except you might not like it ).
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Mar 24th, 2003, 12:12 PM
#3
Yeah, I agree with CornedBee on this. Assembler may not be a language you would ever write in, but it sure can help you understand what you are actually doing in other languages. Assembler is the real deal. The computer works that way in its most fundamental mode (assembler is only an abstraction away from binary, but binary is really tough to read).
The good point there is that you can learn assembler to the level you want. If you won't actually program in it, you can still learn enough to read it, and will then understand what you are doing elsewhere better.
-
Apr 12th, 2003, 01:36 AM
#4
Dazed Member
Posted by CornedBee
Yet it is a good language to learn, not as a single language but rather as an amendment to other languages, esp. C/C++.
So what would those languages be besides C/C++. I haven't got a clue. Can i use assembly in an interpreted language and if so how is the assembly code executed? Does the runtime spawn a new thread to execute the asm code? Thanks for the help.
-
Apr 15th, 2003, 01:24 AM
#5
Originally posted by Dilenger4
Can i use assembly in an interpreted language and if so how is the assembly code executed
None that I know of, but you could write one
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jul 10th, 2003, 10:32 PM
#6
Fanatic Member
You could probably make an interpreter that uses the assembly instruction set (in terms of its symbolic names) as part of the interpreted language. It won't necessarily be assembly, but it will look like it.
On the other hand, you could be like Java and compile the code (including the assembly) into an intermediate form, and interpret that. You will lose one of the big plusses for interpreted languages though, platform independence.
"Can't" and "shouldn't" are two totally separate things.
All questions should be answered. All answers should be true. That is why I post.
-
Jul 11th, 2003, 02:03 AM
#7
You will lose one of the big plusses for interpreted languages though, platform independence
Uhh... no?
Java is cross-platform, since the intermediate code is still interpreted.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jul 11th, 2003, 09:28 AM
#8
Fanatic Member
Maybe "compile" wasn't the best word.
Really, it should have been:
On the other hand, you could be like Java and translate the code (including the assembly) into an intermediate form...
Thx for the catch.
"Can't" and "shouldn't" are two totally separate things.
All questions should be answered. All answers should be true. That is why I post.
-
Jul 11th, 2003, 09:55 AM
#9
So Unbanned
"Can't" and "shouldn't" are two totally separate things.
Somewhat true... but they're basically synonymous. People just usually lack the condition when they use can't.
Like, I can't steal (according to the law). Of course they can.
Or, I can't fly (because I don't have wings). Of course you can, you just need a plane.
Consider the context of the speaker, and conditions are usually not needed.
Unless you're just plain stupid?
-
Jul 11th, 2003, 03:04 PM
#10
Fanatic Member
Unless you're just plain stupid?
Now that was quite an unprofessional remark, especially to something in my signature. If you are going to post a caustic comment, at least do it through e-mail and not through a thread.
"Can't" and "shouldn't" are two totally separate things.
All questions should be answered. All answers should be true. That is why I post.
-
Jul 11th, 2003, 03:20 PM
#11
Originally posted by DiGiTaIErRoR
Somewhat true... but they're basically synonymous. People just usually lack the condition when they use can't.
Like, I can't steal (according to the law). Of course they can.
Or, I can't fly (because I don't have wings). Of course you can, you just need a plane.
Consider the context of the speaker, and conditions are usually not needed.
Unless you're just plain stupid?
Can't implies the lack of ability to do something.
I can steal.... even though it's against the law. Since it is against the law, I shouldn't steal.
On the other hand, I can't fly. Even with a plane. I stil don't fly. the plane flies. I merely sit in it for the ride.
----
Normally you wouldn't use ASM whithin another language.... back in the days, you could, and people did, but times are different. While it's still possible (you can), you probably shouldn't (not a good idea).
At any rate, I learned ASM a long time ago, and it has helped. I haven't used it one bit since the class I took, but ever since then, I've had a better understanding of the fundamentals of what goes on. With that knowledge, I can write some pretty tight code. I've learned how to optimize if statements, cases/switches and other logic operators in a way that can squeeze a few extra ms here and there. Over time it adds up.
I agree w/ CB and SH on this. Don't learn ASM instead of another language, but as a supplement. You may never use it, but it will help to understand some of the limitations and how to get the extra oomph outta something when you need it.
-
Jul 11th, 2003, 03:31 PM
#12
Fanatic Member
Normally you wouldn't use ASM whithin another language....
C / C++ has inline assembly capabilities used heavily for people who (1) need very fast code and / or (2) people who want very fast code.
Take a look on the forum and there are still people who still use assembly.
"Can't" and "shouldn't" are two totally separate things.
All questions should be answered. All answers should be true. That is why I post.
-
Jul 13th, 2003, 12:21 PM
#13
Originally posted by Darkwraith
Maybe "compile" wasn't the best word.
Really, it should have been:
On the other hand, you could be like Java and translate the code (including the assembly) into an intermediate form...
Thx for the catch.
Huh? Actually compile is the perfect word for what javac does. As I see it, compilation is the process of converting human-readable source code into a binary form.
The catch was not about your terminology, but about the content of your message, which was plain wrong.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jul 13th, 2003, 01:25 PM
#14
Fanatic Member
Ok. That wasn't clear at all.
On the other hand, you could be like Java and translate
the code (including the assembly) into an intermediate form...
Take the code and put it into an intermediate form by implementing the programming language like Java.
If you were to take the inline assembly and somehow put it into machine code while still keeping the program as an intermediate file, the VM might be able to run the machine code directly. After thinking about this for a while, I am not sure if this is able to be done effectively.
On the other hand, you could be like Java and translate the code (including the assembly) into an intermediate form...
I also wanted to draw the distinction between compilation and hybrid implementation systems because they are different (so "compile" is not the best term to use in this case.)
"Can't" and "shouldn't" are two totally separate things.
All questions should be answered. All answers should be true. That is why I post.
-
Jul 13th, 2003, 01:29 PM
#15
But you already did that by using the term "intermediate form".
Of course, when you're using assembly then targetting cross-platform doesn't really make sense anyway
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jul 13th, 2003, 01:33 PM
#16
Fanatic Member
Yea, but it might be easier implement. I haven't tried it so I can't say for sure.
"Can't" and "shouldn't" are two totally separate things.
All questions should be answered. All answers should be true. That is why I post.
-
Nov 2nd, 2003, 01:43 PM
#17
Addicted Member
If you are going to write inline assembly you need to be good because the assembly code the compilers turn C code into is real efficient.
-
Nov 3rd, 2003, 10:15 AM
#18
Fanatic Member
True, but you also have to program well in the first place. Optimizing a bubble sort might give you some extra speed, but it still pales to the almighty radix sort.
Last edited by Darkwraith; Nov 3rd, 2003 at 11:49 AM.
"Can't" and "shouldn't" are two totally separate things.
All questions should be answered. All answers should be true. That is why I post.
-
Nov 3rd, 2003, 11:01 AM
#19
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Nov 3rd, 2003, 11:47 AM
#20
Fanatic Member
Radix Sort
Radix sort is O(N) while bubble sort is O(N^2).
So, no matter how much you optimize your bubble sort, it will still pale to radix.
"Can't" and "shouldn't" are two totally separate things.
All questions should be answered. All answers should be true. That is why I post.
-
Nov 3rd, 2003, 12:22 PM
#21
I'm just taking an algorithms and data structures class at uni, and it's proven that a general sorting algorithm cannot be faster than O(n log n), as merge sort, heap sort and quick sort are.
Radix sort is dependent on the assumption that the sort keys are n integers in the range (0, n²). Otherwise it will fail.
So, while bubble sort still sucks, radix sort is not a real replacement for it. Insertion sort, selection sort, merge sort, quick sort and heap sort are.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Nov 3rd, 2003, 12:24 PM
#22
At least that's how I understand this explanation.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Nov 3rd, 2003, 01:44 PM
#23
Fanatic Member
With radix, each element must be able to be broken down into a finite number of tokens (for lack of a better word) and each token's set must be finite.
If you can apply the previous conditions to your data, then you are capable of using that sorting structure. I just used radix so the first thing that popped into my mind was that sort.
If you want to be picky about it and say that if you are going to use the sort on some group of data that may not follow those conditions, then radix is not a good choice but something else might do.
However, I would not go as far and say that bubble, insertion, and selection are good substitutes .
"Can't" and "shouldn't" are two totally separate things.
All questions should be answered. All answers should be true. That is why I post.
-
Nov 3rd, 2003, 01:45 PM
#24
Fanatic Member
The whole point of this was that good algorithms / good code conquers optimizations.
"Can't" and "shouldn't" are two totally separate things.
All questions should be answered. All answers should be true. That is why I post.
-
Nov 3rd, 2003, 01:46 PM
#25
Yup. Just had to be picky
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Nov 3rd, 2003, 01:48 PM
#26
Fanatic Member
hehe
"Can't" and "shouldn't" are two totally separate things.
All questions should be answered. All answers should be true. That is why I post.
-
Nov 27th, 2003, 12:35 PM
#27
Junior Member
enough crap try answering the original question.
Hi sonikku,
Why learn assembly?
1. It's damn simple. (Simpler than C/C++)
2. It's powerful. (more than anythin else).
3. It's fastest.
4. It's smallest.
Only one thing beats assembly language programming in speed and size--hardware programming, but that's static.
C/C++ compilers do produce far better asm code than pure beginners but not without overhead. But whats the compiler's output asm source for. You learn from the compiler ways and end up producing far better code than the compiler itself.
There's one thing that's said amongst programmers:
"A programmer is not a programmer unless he knows exactly what he is doing."
Don't let the compiler think for you, that is, of course, unless y're a nut. (which doesn't look like a possibility since you're here).
Regards,
Art
-
Nov 27th, 2003, 01:06 PM
#28
Point 1 may or may not apply. Define simple in this context.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Nov 27th, 2003, 03:58 PM
#29
Junior Member
Simple as in easy to understand and not the effort required to learn and implement. No language can be learnt without practice. Try learning French, German, Russian, or any other language that you currently don't know.
Regards,
Art
-
Nov 27th, 2003, 04:17 PM
#30
That wouldn't be German, it's my native language. But that's beside the point.
The CONCEPT of assembly is easy enough to understand. Understanding actual assembly code though...
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Nov 27th, 2003, 04:19 PM
#31
What I mean is this: give me a line of assembly and I can tell you what it does (that's not necessarily the case for a line of C code, not without quite some time deciphering).
Give me a hundred lines of assembly and I can tell you what each line does.
But I won't be able to tell you what the 100 lines do.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Dec 1st, 2003, 09:40 AM
#32
New Member
CornedBee,
If you know what each line does it shouldn't be too hard to figure out what the 100 lines do. I would just take a little effort to fit the pieces together. It's the same thing you have to do with High level languages. But the advantage that asm has is that the intructions themselves are simple and easy to understand while very often the syntax for high level languages is complicated and difficult to read.
-
Dec 1st, 2003, 10:00 AM
#33
Yeah, I guess so. Paper and pencil 
Ah, but I feel so at home with the obscure nested templates of C++
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Dec 1st, 2003, 10:29 AM
#34
New Member
LOL i guess when you're comfortable with something it doesn't matter if it looks cryptic to someone else
-
Dec 8th, 2003, 03:21 PM
#35
Fanatic Member
With assembler, if I gave you 100 lines, those 100 lines could be easily translated.
The problem is determining if those 100 lines are related to each other. Some programmers have not learned about the lessons of the past and continue to spew assembly that is ill-documented and ill-structured.
(NOTE: For whomever wants to program in assembly, take a bit of advice: for each line of code, there should be one line of comment. If everybody followed this rule, the world would be a happier place.)
"Can't" and "shouldn't" are two totally separate things.
All questions should be answered. All answers should be true. That is why I post.
-
Dec 8th, 2003, 04:14 PM
#36
New Member
Sometimes code is self documenting. I only add comments if its not clear what a section of code is doing.
-
Dec 8th, 2003, 05:59 PM
#37
Fanatic Member
Assembler is not (I reapeat NOT) self-documenting.
"Can't" and "shouldn't" are two totally separate things.
All questions should be answered. All answers should be true. That is why I post.
-
Dec 9th, 2003, 04:57 PM
#38
Junior Member
Hi Darkwraith,
Agreed, that to a large extent extent assembly is not self-documenting. yep, it is not self-documenting. but everything comes with experience. if any language was self-documenting by itself, then it wouldn't have had comments built in. it's how you look at it. if you were to be given an entire stack of books (about a 10000 of them, say), you wouldn't attempt to sort them by yourself, but would certainly need help of either a machine or fellow human beings. The point *still* stays. The one who writes code that other fellow programmers can understand is a code god. We are constantly trying to become that, though perfection is only an illusion relative to our perspective and imagination. A drop of it can still be achieved. Get out of the box, and don't look AT the code. Look THROUGH it.
Assembly code *looks* impossible to read. But once you've got yourself trained to it, you'll easily isolate parts of code that you need. for example,
when you see something like this in 32-bit windows code
push ebp
mov ebp, esp
you automatically come to know that it is the start of a procedure.
while
retn x
or
ret
or any other stack balancing act denotes the end of the procedure
once you isolate those, you can either test this code in a debugger or emulator or walk through it using some common sense. And in fact, debuggers and diassemblers do the labeling and code finding stuff for you automatically. Even assemblers support high-level constructs, which can certainly make assembly code highly readable. Check out MASM and HLA for instance. Both support HL constructs, which are in fact very self-documenting. There is no standard for assembly languages. But once you learn one, you easily pick up the rest, because it is only a matter of conversion of syntax rather than concepts.
This still don't mean that assembly code is self-documenting. It isn't, but you can read it, only rather slowly and with proper understanding of the microprocessor architecture. The more you do it, the more you improve and the quicker you do it. This is the art of debugging. If debug engineers would have quit, thinking that assembly or machine code is not self-documenting, you certainly wouldn't have had the software or techonology that you do now.
Everything evolves. So let it. Oh, and bTW, HLA is a high-level assembler that is VERY self-documenting. I think even more than C!
Regards,
Art
-
Dec 10th, 2003, 09:34 PM
#39
Fanatic Member
The art of making self-documenting code is not to write for yourself but for another person.
push ebp
mov ebp, esp
might be easily understood by a Windows programmer but not to a DOS programmer. Unless if the code is blatently obvious like
mov sum, eax
then the line should be commented. There is no excuse to make a 10,000 line assembler project and not have comments in it.
However, I will concede in the fact that the only assembler that I have worked with was through MASM and NASM.
"Can't" and "shouldn't" are two totally separate things.
All questions should be answered. All answers should be true. That is why I post.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|