Wednesday, April 29, 2020

Introduction to 64 Bit Windows Assembly Programming



Why study assembly language? 



In a time when the latest fads in programming tend to be object-oriented high-level languages implemented using byte-code interpreters, the trend is clearly to learn to write portable programs with high reliability in record time. It seems that worrying about memory usage and CPU cycles is a relic from a by-gone era. So why would anyone want to learn assembly language programming? Assembly language programming has some of the worst “features” known in computing. First, assembly language is the poster child for nonportable code. Certainly every CPU has its own assembly language and many of them have more than one.

The most common example is the Intel CPU family along with the quite similar AMD CPU collection. The latest versions of these chips can operate in 16 bit, 32 bit and 64 bit modes. In each of these modes there are differences in the assembly language. In addition the operating system imposes additional differences. Further the function call interface (ABI) employed in x86-64 Linux and OS X systems differs from that used in Microsoft Windows systems. Portability is difficult if not impossible in assembly language. An even worse issue with assembly language programming is reliability.

 In modern languages like Java the programmer is protected from many possible problems like pointer errors. Pointers exist in Java, but the programmer can be blissfully unaware of them. Contrast this to assembly language where every variable access is essentially a pointer access. Furthermore high level language syntax resembles mathematical syntax, while assembly language is a sequence of individual machine instructions which bears no syntactic resemblance to the problem being solved. Assembly language is generally accepted to be much slower to write than higher level languages. While experience can increase one’s speed, it is probably twice as slow even for experts. This makes it more expensive to write assembly code and adds to the cost of maintenance.

Preface

 The Intel CPU architecture has evolved over 3 decades from a 16 bit CPU with no memory protection, through a period with 32 bit processors with sophisticated architectures into the current series of processors which support all the old modes of operation in addition to a greatly expanded 64 bit mode of operation. Assembly textbooks tend to focus on the history and generally conclude with a discussion of the 32 bit mode. Students are introduced to the concepts of 16 bit CPUs with segment registers allowing access to 1 megabyte of internal memory. This is an unnecessary focus on the past.


Download Link:-
Disqus Comments