BitsAndPieces        

 

July 2007

                                                 

Jul 30, 2007: 12.  Why learn assembler?

 


Assembler is reputedly difficult to learn and difficult to program in, and these facts, in the days of DOS and before, have motivated HLLs (High Level Languages), to make programming easier to learn and to do.

Therefore the question Why learn assembler? is a good one, especially since computers as hardware are a lot faster and have a lot more memory than in the days of DOS.

My answer comes in two:

  • Knowledge
  • Power

Why is this so? I'll argue it in a moment, after briefly explaining the basics of my reasoning.

A HLL, any HLL - for illustration's sake say Delphi, since this is both widely known and a very fine example of an implementation of a HLL (ObjectPascal here), but what follows is true of any HLL - is in fact syntactically sugared assembler.

What is syntactic sugar? A way of rewriting a language in a format that is close(r) to English (*), that is more easy to read and write and understand for humans, and that has at least part of the expressive or computing power of the more complicated looking original.

In the end, the original is .... assembler (though there also are HLLs that are based on some other HLL - some Prologs, for example, are translated first to C and then compiled as C), and indeed assembler is about as close to the actual machine opcode as one can get, since it in fact consists of a brief mnemonic plus opcodes (or something close to it).

So lets consider the two reasons I gave to learn assembler.

Knowledge:

Assembler gives one the real thing, or as close to it as is humanly feasible and practical. It codes directly for the machine, so when one has an assembler with a good debugger working in synch with the code - like RosAsm, and see BAP009 - one can really see what one's code really does, amounts to and involves, down to bit-level, if one desires it.

No HLL provides as full and as precize an insight and indeed illustration, by means of the debugger working in synch with the code, of what happens in a computer and why it does, as one can get with a good assembler + debugger.

And indeed a considerable part of this knowledge one can get with only a little investment of time and thinking, for all it really requires is installing such an assembler, and playing with it, and trying to make sense of what one has in front of one's nose: The precize and literal stepping through of what the machine code looks like and does with the machine.

Power:

Assembler gives one as full a measure of control of the computer as is humanly possible, for one can program and track the machine in its most elementary moves with its bits and bytes, in its registers and memory.

What is true, though, is that this power of assembler is considerably less easy to acquire than some knowledge of and with it, for the power requires the ability to program in assembler, and learning to program well in any language, including all HLLs, takes time, effort and persistence, and also requires at least some capacity and willingness for abstract thinking of a mathematical kind.

In any case, it seems to me that if you really want to understand why and how modern computers work, the best thing you can do is to learn some assembler (**).

Even if you never program much in it, you will learn much from this about the basics of the HLL(s) you do your programming in, and indeed about the computer you use.


(*) As a matter of fact, programming languages tend to be dialects of English. Indeed, I have never seen a programming language that was not, though I am sure they exist. But again, also in programming, English serves as the lingua franca for all.

(**) I should add here that RosAsm is, in my experience, by far the best here, at least for displaying and showing what really happens with one's code in the debugger.


Maarten Maartensz

 

        home - index - top - mail