![]() |
![]()
Custom Search
|
Computer History
|
|||||||||||
|
Machine instructionsInstructions in assembly language are generally very simple, unlike in a high-level language. Any instruction that references memory (for data or as a jump target) will also have an addressing mode to determine how to calculate the required memory address. More complex operations must be built up out of these simple operations. Some operations available in most instruction sets include: moving
computing
affecting program flow
Some computers include one or more "complex" instructions in their instruction set. A single "complex" instruction does something that may take many instructions on other computers. Such instructions are typified by instructions that take multiple steps, may issue to multiple functional units, or otherwise appear to be a design exception to the simplest instructions which are implemented for the given processor. Some examples of such instruction include:
A form of complex instructions that has become particularly popular recently are SIMD operations that perform the same arithmetic operation to multiple pieces of data at the same time, which have appeared under various trade names beginning with MMX and AltiVec. The design of instruction sets is a complex issue, with a simpler instruction set (generally grouped under the concept RISC) perhaps offering the potential for higher speeds, while a more complex one (traditionally called CISC) may offer particularly fast implementations of common performance-demanding tasks, may use memory (and thus cache) more efficiently, and be somewhat easier to program directly in assembly. Assembly language directivesIn addition to codes for machine instructions, assembly languages have extra directives for assembling blocks of data, and assigning address locations for instructions or code. They usually have a simple symbolic capability for defining values as symbolic expressions which are evaluated at assembly time, making it possible to write code that is easier to read and understand. Like most computer languages, comments can be added to the source code; these often provide useful additional information to human readers of the code but are ignored by the assembler and so may be used freely. They also usually have an embedded macro language to make it easier to generate complex pieces of code or data. In practice, the absence of comments and the replacement of symbols with actual numbers makes the human interpretation of disassembled code considerably more difficult than the original (high level) source would be. Usage of assembly languageHistorically, a large number of programs have been written entirely in assembly language. A classic example was the early IBM PC spreadsheet program Lotus 123. Even into the 1990s, the majority of console video games were written in assembly language, including most games written for the Sega Genesis and the Super Nintendo Entertainment System. The popular arcade game NBA Jam (1993) was also coded entirely using assembly language. There is some debate over the continued usefulness of assembly language. It is often said that modern compilers can render higher-level languages into codes that run as fast as hand-written assembly, but counter-examples can be made, and there is no clear consensus on this topic. It is reasonably certain that, given the increase in complexity of modern processors, effective hand-optimization is increasingly difficult and requires a great deal of knowledge. However, some discrete calculations can still be rendered into faster running code with assembly, and some low-level programming is actually easier to do with assembly. Some system-dependent tasks performed by operating systems simply cannot be expressed in high-level languages. In particular, assembly is often used in writing the low level interaction between the operating system and the hardware, for instance in device drivers. Many compilers also render high-level languages into assembly first before fully compiling, allowing the assembly code to be viewed for debugging and optimization purposes. It's also common, especially in relatively low-level languages such as C, to be able to embed assembly language into the source code with special syntax. Programs using such facilities, such as the Linux kernel, often construct abstractions where different assembly language is used on each platform the program supports, but it is called by portable code through a uniform interface. Many embedded systems are also programmed in assembly to obtain the absolute maximum functionality out of what is often very limited computational resources, though this is gradually changing in some areas as more powerful chips become available for the same minimal cost. Another common area of assembly language use is in the system BIOS of a computer. This low-level code is used to initialize and test the system hardware prior to booting the OS and is stored in ROM. Once a certain level of hardware initialization has taken place, code written in higher level languages can be used, but almost always the code running immediately after power is applied is written in assembly language. Assembly language is also valuable in reverse engineering, since many programs are distributed only in machine code form, and machine code is usually easy to translate into assembly language and carefully examine in this form, but very difficult to translate into a higher-level language. Tools such as the Interactive Disassembler make extensive use of disassembly for such a purpose. MenuetOS, a floppy-based operating system with a fully functional GUI is written entirely in assembly. A 64bit version is also available. The author claims that only through assembly language could he produce his system in less than 1.4 megabytes. Example listing of assembly language source code: Example of a selection of instructions (for a virtual computer) with the corresponding address in memory where each instruction will be placed. These addresses are not static. Accompanying each instruction is the generated (by the assembler) object code that coincides with the virtual computer's architecture (or ISA). Resources |