The Assembly Programming Master Book
| ||
| ||
|
Writing programs in Assembly language for a long time meant writing programs for MS-DOS. The arrival of the Windows 95 operating system has changed the position of the Assembly language programming. In a certain respect, Assembly programming didn't recover its lost position till now. By writing this book, I aim to encourage programmers to pay attention to this interesting field of programming and recover the Assembly language position.
There are lots of books concentrating on the topic of Assembly programming in general and Windows programming using the Assembly language in particular. However, I have done a considerable job revising, improving, and refining such materials. These revisions relate not only to Assembly language but also to the new capabilities of contemporary operating systems of the Windows NT family, including Windows 2000, Windows XP, and Windows Server 2003. For example, the book includes special chapters concentrating on file management, the development of services, and kernel-mode drivers.
I'd also like to mention that all examples included in this book were tested under operating systems of the Windows NT family. Therefore, although I did my best, I cannot guarantee that all examples will work under., Windows 9x and Windows Millennium Edition (ME). The same relates to processors: all examples were tested on computers equipped with Pentium III and Pentium IV.
When developing programs presented in this book, I used two assemblersMicrosoft Assembler (MASM) and Turbo Assembler (TASM). Recently, Borland sold the TASM assembler to Paradigm, and now this product is available under another name PASM. However, because TASM remains popular among programmers writing in Assembly language, I still use the TASM term and, whenever possible, develop programs oriented toward both compilers.
In many respects, this book reflects my point of view on programming and a methodic of teaching programming. This relates to the Assembly macro tools. In my opinion, they substantially hide the beauty of the Assembly language and its capabilities. I think that when explaining programming as a technology and describing programming style, using macro tools makes you forget that programming for many individuals is an art. These two sides of programming often come into conflict. However, this relates to specific philosophical aspects; therefore, this topic will not be covered in this book.
So, why do you need the Assembly language when programming for Windows? After all, there is C language to speak nothing of other high-level programming languages. The simplest and the most convincing answer to this question is that Assembly language is the processor's language; consequently, it will exist as long as processors exist. Other conclusive proof of the importance of Assembly language is that it is needed for optimizing program code, developing drivers, translators, programming some peripheral devices, etc. Finally, programming in Assembly language gives you a sense of power over the computer, and striving for power is a basic human instinct.
As relates to the Windows, [i] programming in Assembly language for this operating system is much easier that programming for MS-DOS, however strange this might seem to most programmers. In this book, I try to prove that programming in Assembly language is no more difficult that doing the same thing using high-level languages such as C language. Furthermore, you'll get compact, efficient, and fast code using Assembly language. Unfortunately, when working with high-level languages, most programmers lose certain algorithmic skills, and the implications of this process are ongoing. Honestly, improving your professional skills alone makes the Assembly language worth studying .
The book also includes material that can be considered hackish. I pay special attention to the methods and tools of analyzing and correcting program code. To those who insist that this practice is illegal and immoral, I would argue that because hackers exist, you should know their methods of work. This knowledge will be useful for most programmers.
It is necessary to mention that contemporary literature on Windows programming has one common drawback. Authors quickly migrated from describing programming API to covering visual components of specific languages. The books concentrating on pure Windows programming using API functions only are not numerous . Happy exceptions from this rule are some books listed in the Bibliography [4, 10, 13]. In this book, I try to follow the approach adopted by the authors of these books and to cover many topics that are not covered in sufficient detail in the existing literature, such as programming for networks, using multitasking, writing virtual device drivers, and file processing.
As a rule, most books on programming tend to take one of two extreme positions : they concentrate either on describing the programming language in as much detail as possible or on describing the capabilities of programming for a specific operating system. My goal was to avoid such extremities and achieve the golden mean. Therefore, this book is neither a detailed manual on Assembly programming nor a manual on Windows programming. It pays equal attention to both topicsAssembly language and Windows programming.
The main principles that I tried to observe when writing this book are as follows :
-
I have provided detailed and comprehensive descriptions of the topics under consideration. As I already mentioned, I am not a fan of macro tools. However, the main goal of this bookwriting Assembly programs that can be translated using both MASM and TASMrequires you to know macro tools, among other things. Therefore, these tools play a subordinated role in this book, although there is a chapter that provides a detailed description of directives and macro tools of the Assembly language.
-
To make the materials as useful as possible, I provide all programs in two versions (for MASM and for TASM) or I supply detailed comments explaining how to migrate to another assembler. As a basis, I have taken MASM version 7.0, TASM32.EXE version 5.0, and TLINK32.EXE version 1.6.71. To compile and build the examples, I recommend that you also use these (or later) versions of MASM and TASM.
-
The book explains Assembly programming step by step, starting with simple programs and continuing to topics related to system programming. Therefore, it might be considered a teaching course on Windows programming. It is highly desirable (although not required) that you be acquainted with the C programming language. Knowing at least the basics of the Assembly language will be a benefit. If you do not have previous knowledge in these fields, I recommend that you read other books beforehand [1, 4, 11]. Detailed explanations of the microprocessor commands can be found in additional books [1, 3, 7, 8, 9].
-
Good knowledge of the Assembly language helps you to easily understand and navigate the program code. Hackers are usually good programmers in Assembly language. The aspects of code analysis are not frequently covered in computing literature. However, sound knowledge in this field will be helpful for every programmer, especially those involved in developing protection mechanisms.
-
If you are only beginning to program in the Assembly language, I recommend that you start with a careful study of the opening chapters, which provide detailed descriptions of the structure of a typical Windows program.
[i] When speaking about Windows, I mean several operating systems of this family: Windows 9x/ME, Windows NT, and Windows 2000/XP. When necessary, I will specify which operating system is meant.
| ||
| ||
|