| Line 1: |
Line 1: |
| − | An '''Assembly language''' is a low-level [[Programming language]] that is specific to a given [[CPU]]'s instruction set. For instance, the [[Zilog Z80]] assembly language is different from the [[Intel 8080]] assembly language, despite the similarities in the underlying instruction sets. | + | An '''assembly language''' is a low-level [[programming language]] that is specific to a given [[CPU]]'s instruction set. For instance, the [[Zilog Z80]] assembly language is different from the [[Intel 8080]] assembly language, despite the similarities in the underlying isntruction sets. |
| | | | |
| − | A program, called an '''Assembler''' converts source code written in Assembly Language into the CPU's machine code. Each CPU instruction is assigned a short mnemonic code (traditionally 3 or 4 characters in length). Additional syntax supports registers, addressing modes, labels and other symbolic names, comments, and directives. Assembly languages supporting macro processing (substitution, etc) used to be called Macro Assembly languages, but as most Assembly languages now support macros, the "Macro" prefix has been dropped from common usage. | + | A program, called an '''assembler''' converts source code written in assembly language into the CPU's machine code. Each CPU instruction is assigned a short mnuemonic code (traditionally 3 or 4 characters in length). Additional syntax supports registers, addressing modes, labels and other symbolic names, comments, and directives. Assembly languages supporting macro processing (substitution, etc) used to be called macro assembly languages, but as most assembly languages now support macros, the "macro" prefix has been dropped from common usage. |
| | | | |
| − | The instruction mnemonics are typically defined by the manufacturer of the CPU. Although anyone could assign their own arbitrary set of mnemonics for a CPU's instruction set, in practice this is seldom done. | + | The instruction mnuemonics are typically defined by the manufacturer of the CPU. Although anyone could assign their own arbitrary set of mnuemonics for a CPU's instruction set, in practice this is seldom done. |
| | | | |
| − | ==Advantages and Disadvantages of Assembly Language== | + | ==Advantages and Diadvantages of Assembly Language== |
| | Assembly languages do not provide many of the useful abstractions of high-level languages, such as memory management, object and other complex data structure support, or string manipulation. Such features are often available through libraries of assembly code, though. | | Assembly languages do not provide many of the useful abstractions of high-level languages, such as memory management, object and other complex data structure support, or string manipulation. Such features are often available through libraries of assembly code, though. |
| − | Assembly language is essential when a new CPU is developed since it allows the development of higher-level language compilers for that CPU. Assembly is also required for access to unique and low-level features of a CPU which is why portions of most [[Operating System]]s must be written using assembly language. Because assembly provides no abstractions, code written with it can run faster than equivalent code written in a high-level programming language. However, modern '''optimizing compilers''' are often better at generating efficient machine code than human-crafted assembly. Finally, writing assembly code is more tedious (and therefore more error-prone) than using a high-level language. | + | |
| | + | Assembly language is essential when a new CPU is developed since it allows the development of higher-level language compilers for that CPU. Assembly is also required for access to unique and low-level features of a CPU which is why portions of most [[operating system]]s must be written using assembly language. Because assembly provides no abstractions, code written with it can run faster than equivalent code written in a high-level programming language. However, modern '''optimizing compilers''' are often better at generating efficient machine code than human-crafted assembly. Finally, writing assembly code is more tedious (and therefore more error-prone) than using a high-level language. |
| | | | |
| | ==Macros== | | ==Macros== |
| − | Macros provide short-hand for assembly programmers. The most common macro feature is the '''substitution macro'''. This allows the programmer to define his own mnemonic in place of several preexisting mnemonics. When the macro is used, the assembler will substitute the corresponding mnemonics in place of the macro, as if the programmer had included those mnemonics at that point in the source code. Another form of macro is the '''iteration macro''' which allows the programmer to duplicate something without having the manually duplicate it numerous times. Thus macros can reduce the size, and complexity, of the assembler source code. | + | Macros provide short-hand for assembly programmers. The most common macro feature is the '''substitution macro'''. This allows the programmer to define his own mnuemonic in place of several pre-existing mnuemonics. When the macro is used, the assembler will substitute the corresponding mnuemonics in place of the macro, as if the programmer had included those mnuemonics at that point in the source code. Another form of macro is the '''iteration macro''' which allows the programmer to duplicate something without having the manually duplicate it numerous times. Thus macros can reduce the size, and complexity, of the assembler source code. |
| | | | |
| | ==Example== | | ==Example== |
| − | Without an assembler, a person who wanted to increment the Zilog Z80 "C" register, would have to figure out the numeric code (in this case 4 hexadecimal or 00000100 binary). Assembly allows this operation to be specified with the mnemonic: | + | Without an assembler, a person who wanted to increment the Zilog Z80 "C" register, would have to figure out the numeric code (in this case 4 hexadecimal or 00000100 binary). Assembly allows this operation to be specified with the mnuemonic: |
| | | | |
| | INC C | | INC C |
| Line 53: |
Line 54: |
| | | | |
| | ==References== | | ==References== |
| − | *The 8086 Family User's Manual, Intel Corporation, 1979 | + | *The 8086 Family User's Manual, Intel Coporation, 1979 |
| | *VAX 11 Structured Assembly Language Programming, Robert W. Sebesta, Benjamin/Cummings Publishing, ISBN 0-8053-7001-3 | | *VAX 11 Structured Assembly Language Programming, Robert W. Sebesta, Benjamin/Cummings Publishing, ISBN 0-8053-7001-3 |
| | *Programming the Z80, Rodnay Zaks, Sybex, ISBN 0-89588-069-5 | | *Programming the Z80, Rodnay Zaks, Sybex, ISBN 0-89588-069-5 |