Server Help

Trash Talk - Why Learning Assembly Language is Still a Good Idea?

nintendo64 - Fri May 07, 2004 12:48 am
Post subject: Why Learning Assembly Language is Still a Good Idea?
Good read for programmers,

http://www.onlamp.com/pub/a/onlamp/2004/05/06/writegreatcode.html

I see your point, Mr Ekted, i do beleive the internals should be the main focus, even thought the author of this article shows learning assembly is a good way for gaining this knowledge. I admit, he was advertising assembly icon_smile.gif, he went a little overboard.

-nintendo64
Mr Ekted - Fri May 07, 2004 1:39 am
Post subject:
Nice. And agreed. L1K

It's not even the point to learn ASM per se, just to understand the kinds of things that happen on the inside. Most programs treat the computer like a black box, and they end up writing slow bloated crap like ICQ, Internet Explorer, WinAmp, Windows Media Player, etc.
Qndre - Fri May 07, 2004 8:57 am
Post subject:
You can write everything in ASM, you can also write in other languages. (Because every high-language becomes ASM after compilation!) But in ASM you can do more. And it's very useful for reverse-engineering. But it's hard to learn.
Mine GO BOOM - Fri May 07, 2004 9:26 am
Post subject:
Qndre wrote:
But it's hard to learn.

Its easy to learn, as there are only so many different instructions. Its just difficult to master, because there nothing watching over you saying "oops, there is an error."
Cyan~Fire - Fri May 07, 2004 10:26 am
Post subject:
Read the article before you comment, Qndre.

I think telling all modern-day programmers to learn ASM is a little over-the-top, since many would not do it. I think the simplest way to improve code is just to know smaller code is smaller compiled code (usually), and also take into consideration what external methods they are using to accomplish their goals. If everyone wrote windows apps with the Windows API instead of the bloated MFC, programs would shave off huge chunks of their run-time bulk.
NightHawk - Fri May 07, 2004 1:47 pm
Post subject:
I'm getting my Comp Sci degree at a University, and had to take an assembly course in my second year. I thought that this would be standard material at other institution.. am I wrong?
Smong - Fri May 07, 2004 3:46 pm
Post subject:
I had a look at some U's and only one said the asm was an optional module that was taken in the electronics department. My main impression was that they were focusing on AI/neural networks and consultancy ('we don't live in India so we don't have to code' was the message I got).
Mr Ekted - Fri May 07, 2004 4:08 pm
Post subject:
I am not saying that people should write their apps in ASM. I am saying that by learning ASM it helps you understand HOW to design and write better code in whatever language you choose -- orders of magnitude better.
nintendo64 - Fri May 07, 2004 4:45 pm
Post subject:
For the people that are saying, "not everything should be written in assembly", they are right, but that's not what the article is saying, why don't go read it? The Article is talking about that many programmers don't know how the internals works, hence the bloatware applications.

Assembly is a just a good way to learn how the computer treats your variables (on the stack or on the heap), etc.. the internals.

Main point of the Article

Quote:
The only problem with the demise of assembly language is that as its popularity waned, so did the percentage of programmers who understood the low-level ramifications of the code they were writing. Those programmers who were claiming that assembly language was dead already knew how to think in assembly language and how to apply that low-level thinking to their high-level code; in effect, enjoying the benefits of assembly language while writing high-level language code. However, as new programmers worked their way into the system, without the benefits of having written several applications in assembly, the efficiency of software applications began to decline.


-nintendo64
Helicon - Fri May 07, 2004 4:49 pm
Post subject:
the difference here is between a designer and a computer scientist. This is not to say that great coders can't benefit, they certainly will. However, many of the low-level protocols and high-efficiency environments are merely implemented by coders, while the actual theory behind them is implemented by true nuts and bolts computer scientists.

try to look at it this way, in a game like Quake or Unreal, the engine itself is hot-wired for speed speed speed. I would venture to say that many of algorithms in either engine bank on ASM code or snippets for fast and efficient access to system resources. I haven't seen said code, of course, but it seems only logical given the tremendous performance achieved.
Even less impressive apps benefit from assembly procedures, especially in processing large data structures ie image editing, sound, and scientific data processing.

in approaching assembly, i never set out to actively code in assembly, as that is a step into an expertise which i share no stake in. I did, however, take the time to learn how a program is written in ASM and try to comprehend the small ASM parts that make up the implementation of higher-level processes (ie other language constructs). in other words, mentally comprehending, step by step, the transfer from C to ASM in terms of what the programmer indicated and what was accomplished.

i suppose an auto mechanic analogy would be good in this case. A good mechanic can fix a belt or true an axle or fix even trivial engine problems, yet they can do nothing immediate about malfunctions in the high precision machined parts within the engine. the good ones know what goes on inside and how to prevent wear, tear, and get the highest performance, but they don't necessarily carry qualifications for developing such parts.

becoming familiar with assembly language shares a common purpose. you will understand better how to transfer ideas from your mental process into computer instructions, even if that process does not take place in ASM, but in another language...

java programmers needn't bother
Helicon - Fri May 07, 2004 4:52 pm
Post subject:
Mr Ekted wrote:
I am not saying that people should write their apps in ASM. I am saying that by learning ASM it helps you understand HOW to design and write better code in whatever language you choose -- orders of magnitude better.

(my preceding post): no shit
Mr Ekted - Fri May 07, 2004 4:57 pm
Post subject:
I was replying to Qndre mostly. I should have quoted him.
Mr Ekted - Fri May 07, 2004 7:15 pm
Post subject:
Code: Show/Hide
int i;
char buffer[256];

// code that sets buffer here

for (i = 0; i < strlen(buffer); i++)
   if (buffer[i] == ' ')
      buffer[i] = '_';


What's wrong with this?

1. strlen() is called every loop. This will easily make this loop 10x slower, maybe more.

2. Indexing is expensive, even for char arrays. If you are sequentially walking an array, use a pointer.

Code: Show/Hide
char *p;
char ch;
char buffer[256];

// code that sets buffer here

p = buffer;

while (ch = *p)
   {
   if (ch == ' ')
      *p = '_';

   p++;
   }


This is a tiny example. You can't fix most poorly written apps by tweaking 10 lines of code at a time. They have inefficiencies in design (functional, data structures, etc).
Mine GO BOOM - Fri May 07, 2004 8:29 pm
Post subject:
Mr Ekted wrote:
strlen() is called every loop

Actually, Microsoft's optimizing compiler fixes this problem for people, as it does for the simple indexing code you wrote. But that doesn't excuse people from writing sloppy in the first place.
Mr Ekted - Fri May 07, 2004 8:59 pm
Post subject:
Only because strlen() can be an "intrinsic" function. If it was an arbitrary function, the compiler cannot make the assumption that it only needs to call it once. Agreed otherwise.
Cyan~Fire - Sat May 08, 2004 12:07 pm
Post subject:
Code: Show/Hide
char *p;
char ch;
char buffer[256];

// code that sets buffer here

p = buffer;

while (ch = *p)
   {
   if (ch == ' ')
      *p = '_';

   p++;
   }

Can't you just do
Code: Show/Hide
while (*p)
{
   if (*p == ' ')
      *p = '_';
}

Maybe I'm just overlooking something obvious.
SuSE - Sat May 08, 2004 12:28 pm
Post subject:
<measures dick>
Dustpuppy - Sat May 08, 2004 1:48 pm
Post subject:
Cyan~Fire wrote:
Code: Show/Hide

while (*p)
{
   if (*p == ' ')
      *p = '_';
}



That would be an infinite loop because p is never advanced...
Anonymous - Sat May 08, 2004 2:17 pm
Post subject:
I think char ch will probably be a register so the if() is faster. Although it's not the sort of think I would think up myself.
Mr Ekted - Sat May 08, 2004 3:31 pm
Post subject:
I prefer to be explicit. If you do:

Code: Show/Hide
while (*p)
   {
   if (*p == ' ')
      *p = '_';

   p++;
   }


you are dereferencing p twice (testing *p). Granted the optimizer should handle it, but who knows.
Anonymous - Sun May 09, 2004 11:05 am
Post subject:
I totaly agree, understanding the very basic principals is the most important thing.
Take math for example, sin, cosin, tangent, log, etc., today's kids - they just push buttons, they rarely understand what exactly is going on there.
Tell them to do manual calculations for a square root of 1, they won't know how to, they'll ask for a computer.
I always argued against the education system in that fashion, being able to know how to operate a hand held computer is all nice and dandy and sure, it makes calculations easier and faster, but it also dulls the brain, you need to know for yourself and understand what exactly is happening there.

Take McGuyver for an example, sure most of the time it was a bit over the top and more lcuky than one should and would be, but still, it pushed a strong message of relaying upon intelligence, knowledge, understanding, brain power instead of brawn power.


P.S.

Efficient Coding: http://www.theprodukkt.com/


P.P.S:
DIE SCUM!
Anonymous - Sun May 09, 2004 11:08 am
Post subject:
Also for example, there was back then BATTLETECH 3025.
The entire MMOFPS ran on 36MBs total!!!
I have no idea how they compressed shit so tight and so forth, but boy, they did it.
Anonymous - Sun May 09, 2004 11:09 am
Post subject:
In addition: assembly rox
Cyan~Fire - Sun May 09, 2004 11:43 am
Post subject:
Ekted wrote:
you are dereferencing p twice (testing *p). Granted the optimizer should handle it, but who knows.

icon_eek.gif I think I'll just go with Akai...
Mr Ekted - Sun May 09, 2004 11:49 am
Post subject:
SuSE wrote:
<measures dick>


... in pixels.
Mine GO BOOM - Sun May 09, 2004 3:40 pm
Post subject:
Mr Ekted wrote:
... in pixels.

... in binary without needing more than a bit.
Dr Brain - Sun May 09, 2004 3:55 pm
Post subject:
Haha, nice jab, Ekted.

Akai and I had a long argument in game about that a while back.
Helicon - Sun May 09, 2004 5:19 pm
Post subject:
Grav(FU OL) wrote:
Take math for example, sin, cosin, tangent, log, etc., today's kids - they just push buttons, they rarely understand what exactly is going on there.

oh yeah, in the olden days, we had to use charts... that was understanding.
(Actually, it was just slow as hell...)
Anonymous - Sun May 09, 2004 5:38 pm
Post subject:
Trig isn't all button pushing, first you have to cope with an irrational number, pi. Then the functions also repeat forever, so you've got things like sin(n+2pi) your calculator won't print out all the possible solutions for you.

I have my doubts about the 96k game, it could be a virus, or a hoax like a certain xbox emulator. You can get a load of 'demos' at www.pouet.net
ExplodyThingy - Sun May 09, 2004 5:48 pm
Post subject:
Its probably just like Minuete OS with really bitching code optimization, compression and such.
Mr Ekted - Sun May 09, 2004 6:38 pm
Post subject:
Dr Brain wrote:
Haha, nice jab, Ekted.

Akai and I had a long argument in game about that a while back.


I still laugh at him (and Ancient Power) about it when I can. icon_smile.gif
Anonymous - Mon May 10, 2004 1:33 am
Post subject:
Like I said, buttons or charts, same shit.
There are quite few constant angles to which there's a percise root which gives you the requested number.
You should know it, you should understand it.
But you don't.


You are weak.
Cyan~Fire - Mon May 10, 2004 4:36 pm
Post subject:
Understanding sine, cosine, and tangent really isn't that hard. I think most people here get it.
Helicon - Mon May 10, 2004 6:09 pm
Post subject:
Cyan~Fire wrote:
Understanding sine, cosine, and tangent really isn't that hard. I think most people here get it.

ExplodyThingy - Wed May 12, 2004 7:33 pm
Post subject:
So after all that, does anyone here actually know of a way to learn this language? If so, link me, most things I've found require that I be very intimate with the guts of a system, which im not, hence me learning this, or assume Im a completel idiot and define what a compiler is.
Mine GO BOOM - Wed May 12, 2004 10:45 pm
Post subject:
ExplodyThingy wrote:
So after all that, does anyone here actually know of a way to learn this language?

Can't get better for free than Art of Assembly Language. Free, huge online text book. Uses HLA (High Level Assembly) for the language, which allows you to learn x86 very easily in the beginning since you don't need to make your own I/O functions. HLA also allows you to work in pure assembly also, so once you learn a bunch, you can do pure assembly to your heart's content.

I'd recommend that over anything else. But remember, that book is designed to be skipped around, so don't expect it to teach you straight through, chapter by chapter.
Mr Ekted - Wed May 12, 2004 11:08 pm
Post subject:
Another thing you can do is program in C but have your compiler output ASM/source listings. In MSVC do Project/Settings/C-C++/Listing-Files/Source-ASM-Machine. After you build there will be .COD files in your output folders. You can see what your code traslates to. Understanding at least some of it helps quite a bit when you are debugging stuff.
Anonymous - Thu May 13, 2004 3:07 am
Post subject:
I use an old book, ~10 years in age, which teaches 80386.
Ha Ha Ha.
Dustpuppy - Thu May 13, 2004 5:58 am
Post subject:
Mr Ekted wrote:
Another thing you can do is program in C but have your compiler output ASM/source listings.


Nice to know how to do that.
I've done little bits in ASM before so using this in the right places could help me improve code efficiency and learn ASM...
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group