Assembly language: Difference between revisions
Jump to navigation
Jump to search
imported>Pancho507 clarify |
imported>Wikideas1 →See also: List of assembly software and tools |
||
| Line 31: | Line 31: | ||
In computing, '''assembly language''' (alternatively '''assembler language'''<ref name="IBM_2014_ASM"/> or '''symbolic machine code'''),<ref name="Ohio_2016"/><ref name="Archer_2016"/><ref name="Streib 2020 p. ">{{cite book | last=Streib | first=James T. | title=Undergraduate Topics in Computer Science | chapter=Guide to Assembly Language | publisher=Springer International Publishing | publication-place=Cham | year=2020 | isbn=978-3-030-35638-5 | issn=1863-7310 | doi=10.1007/978-3-030-35639-2 | page= | s2cid=195930813 | quote=Programming in assembly language has the same benefits as programming in machine language, except it is easier.}}</ref> often referred to simply as '''assembly''' and commonly abbreviated as '''ASM''' or '''asm''', is any [[low-level programming language]] with a very strong correspondence between the instructions in the language and the [[computer architecture|architecture's]] [[machine code]] [[instruction set architecture|instructions]].<ref name="Saxon_1962"/> Assembly language usually has one [[Statement (computer science)|statement]] per machine code instruction (1:1), but constants, [[Comment (computer programming)|comments]], assembler [[Directive (programming)|directives]],<ref name="Kornelis_2010"/> symbolic [[Label (computer science)|labels]] of, e.g., [[memory location]]s, [[processor register|registers]], and [[Macro instruction|macros]]<ref name="IBM_2014_Macro"/><ref name="IBM_2014_ASM"/> are generally also supported. | In computing, '''assembly language''' (alternatively '''assembler language'''<ref name="IBM_2014_ASM"/> or '''symbolic machine code'''),<ref name="Ohio_2016"/><ref name="Archer_2016"/><ref name="Streib 2020 p. ">{{cite book | last=Streib | first=James T. | title=Undergraduate Topics in Computer Science | chapter=Guide to Assembly Language | publisher=Springer International Publishing | publication-place=Cham | year=2020 | isbn=978-3-030-35638-5 | issn=1863-7310 | doi=10.1007/978-3-030-35639-2 | page= | s2cid=195930813 | quote=Programming in assembly language has the same benefits as programming in machine language, except it is easier.}}</ref> often referred to simply as '''assembly''' and commonly abbreviated as '''ASM''' or '''asm''', is any [[low-level programming language]] with a very strong correspondence between the instructions in the language and the [[computer architecture|architecture's]] [[machine code]] [[instruction set architecture|instructions]].<ref name="Saxon_1962"/> Assembly language usually has one [[Statement (computer science)|statement]] per machine code instruction (1:1), but constants, [[Comment (computer programming)|comments]], assembler [[Directive (programming)|directives]],<ref name="Kornelis_2010"/> symbolic [[Label (computer science)|labels]] of, e.g., [[memory location]]s, [[processor register|registers]], and [[Macro instruction|macros]]<ref name="IBM_2014_Macro"/><ref name="IBM_2014_ASM"/> are generally also supported. | ||
The first assembly code in which a language is used to represent machine code instructions is found in [[Kathleen Booth|Kathleen]] and [[Andrew Donald Booth]]'s 1947 work, ''Coding for A.R.C.''.<ref>{{cite book |last1=Booth |first1=Andrew D |last2=Britten |first2=Kathleen HV |title=Coding for A.R.C. |date=1947 |publisher=Institute for Advanced Study, Princeton |url=https://albert.ias.edu/bitstream/handle/20.500.12111/7941/Booth_Britten_Coding_for_ARC_1947.pdf?sequence=1&isAllowed=y |access-date=4 November 2022}}</ref> Assembly code is converted into executable machine code by a [[Utility software|utility program]] referred to as an '' | The first assembly code in which a language is used to represent machine code instructions is found in [[Kathleen Booth|Kathleen]] and [[Andrew Donald Booth]]'s 1947 work, ''Coding for A.R.C.''.<ref>{{cite book |last1=Booth |first1=Andrew D |last2=Britten |first2=Kathleen HV |title=Coding for A.R.C. |date=1947 |publisher=Institute for Advanced Study, Princeton |url=https://albert.ias.edu/bitstream/handle/20.500.12111/7941/Booth_Britten_Coding_for_ARC_1947.pdf?sequence=1&isAllowed=y |access-date=4 November 2022}}</ref> Assembly code is converted into executable machine code by a [[Utility software|utility program]] referred to as an ''assembler''. The term "assembler" is generally attributed to [[Maurice Wilkes|Wilkes]], [[David Wheeler (computer scientist)|Wheeler]] and [[Stanley Gill|Gill]] in their 1951 book ''[[The Preparation of Programs for an Electronic Digital Computer]]'',<ref name="Wilkes_1951"/> who, however, used the term to mean "a program that assembles another program consisting of several sections into a single program".<ref name="Fairhead_2017"/> The conversion process is referred to as ''assembly'', as in ''assembling'' the [[source code]]. The computational step when an assembler is processing a program is called ''assembly time''.{{Citation needed|date=April 2026}} | ||
Because assembly depends on the machine code instructions, each assembly language<ref group=nb>Other than meta-assemblers</ref> is specific to a particular [[computer architecture]].<ref name="OS360_2011"/><ref name="Austerlitz 2003 pp. 326–360">{{cite book | last=Austerlitz | first=Howard | title=Data Acquisition Techniques Using PCs | chapter=Computer Programming Languages | publisher=Elsevier | year=2003 | doi=10.1016/b978-012068377-2/50013-9 | pages=326–360 | isbn=9780120683772 | quote=Assembly language (or Assembler) is a compiled, low-level computer language. It is processor-dependent since it basically translates the Assembler's mnemonics directly into the commands a particular CPU understands, on a one-to-one basis. These Assembler mnemonics are the instruction set for that processor.}}</ref><ref name="Carnes 2022">{{cite web |last=Carnes |first=Beau |date=2022-04-27 |title=Learn Assembly Language Programming with ARM |url=https://www.freecodecamp.org/news/learn-assembly-language-programming-with-arm/ |access-date=2022-06-21 |website=freeCodeCamp.org |language=en-US |quote=Assembly language is often specific to a particular computer architecture so there are multiple types of assembly languages. ARM is an increasingly popular assembly language.}}</ref> | Because assembly depends on the machine code instructions, each assembly language<ref group=nb>Other than meta-assemblers</ref> is specific to a particular [[computer architecture]] such as [[x86]] or [[ARM architecture family|ARM]].<ref name="OS360_2011"/><ref name="Austerlitz 2003 pp. 326–360">{{cite book | last=Austerlitz | first=Howard | title=Data Acquisition Techniques Using PCs | chapter=Computer Programming Languages | publisher=Elsevier | year=2003 | doi=10.1016/b978-012068377-2/50013-9 | pages=326–360 | isbn=9780120683772 | quote=Assembly language (or Assembler) is a compiled, low-level computer language. It is processor-dependent since it basically translates the Assembler's mnemonics directly into the commands a particular CPU understands, on a one-to-one basis. These Assembler mnemonics are the instruction set for that processor.}}</ref><ref name="Carnes 2022">{{cite web |last=Carnes |first=Beau |date=2022-04-27 |title=Learn Assembly Language Programming with ARM |url=https://www.freecodecamp.org/news/learn-assembly-language-programming-with-arm/ |access-date=2022-06-21 |website=freeCodeCamp.org |language=en-US |quote=Assembly language is often specific to a particular computer architecture so there are multiple types of assembly languages. ARM is an increasingly popular assembly language.}}</ref> | ||
Sometimes there is more than one assembler for the same architecture, and sometimes an assembler is specific to an [[operating system]] or to particular operating systems. Most assembly languages do not provide specific [[Syntax (programming languages)|syntax]] for operating system calls, and most assembly languages can be used universally with any operating system,<ref group=nb>However, that does not mean that the assembler programs implementing those languages are universal.</ref> as the language provides access to all the real capabilities of the [[Processor (computing)|processor]], upon which all [[system call]] mechanisms ultimately rest. In contrast to assembly languages, most [[high-level programming language]]s are generally [[porting|portable]] across multiple architectures but require [[Interpreter (computing)|interpreting]] or [[Compiler|compiling]], much more complicated tasks than assembling. | Sometimes there is more than one assembler for the same architecture, and sometimes an assembler is specific to an [[operating system]] or to particular operating systems. Most assembly languages do not provide specific [[Syntax (programming languages)|syntax]] for operating system calls, and most assembly languages can be used universally with any operating system,<ref group=nb>However, that does not mean that the assembler programs implementing those languages are universal.</ref> as the language provides access to all the real capabilities of the [[Processor (computing)|processor]], upon which all [[system call]] mechanisms ultimately rest. In contrast to assembly languages, most [[high-level programming language]]s are generally [[porting|portable]] across multiple architectures but require [[Interpreter (computing)|interpreting]] or [[Compiler|compiling]], much more complicated tasks than assembling. | ||
| Line 42: | Line 42: | ||
==Assembly language syntax== | ==Assembly language syntax== | ||
Assembly language uses a [[mnemonic]] to represent | Assembly language uses a [[mnemonic]] to represent low-level [[machine code|machine instructions]] ([[Opcode|opcodes]]), [[directive (programming)|directives]], and usually [[register (computing)#ARCHITECTURAL|architectural registers]] and [[bit field|flags]].<ref>{{Cite web |date=2023-10-19 |title=What is Assembly Language? |url=https://www.geeksforgeeks.org/computer-organization-architecture/what-is-assembly-language/ |access-date=2026-04-24 |website=GeeksforGeeks |language=en}}</ref> Some of the mnemonics may be built-in and some user-defined. Many operations require one or more [[Operand#Computer science|operands]] in order to form a complete instruction. Most assemblers permit named constants, registers, and [[Label (computer science)|labels]] for program and memory locations, and can calculate [[Expression (computer science)|expressions]] for operands. Thus, programmers are freed from tedious repetitive calculations and assembler programs are much more readable than machine code. Depending on the architecture, these elements may also be combined for specific instructions or [[addressing mode]]s using [[offset (computer science)|offset]]s or other data as well as fixed addresses. Many assemblers offer additional mechanisms to facilitate program development, to control the assembly process, and to aid [[debugging]]. | ||
Some are column oriented, with specific fields in specific columns; this was very common for machines using [[punched card]]s in the 1950s and early 1960s. Some assemblers have free-form syntax, with fields separated by delimiters, e.g., punctuation, [[Whitespace character|white space]]. Some assemblers are hybrid, with, e.g., labels, in a specific column and other fields separated by delimiters; this became more common than column-oriented syntax in the 1960s. | Some are column oriented, with specific fields in specific columns; this was very common for machines using [[punched card]]s in the 1950s and early 1960s. Some assemblers have free-form syntax, with fields separated by delimiters, e.g., punctuation, [[Whitespace character|white space]]. Some assemblers are hybrid, with, e.g., labels, in a specific column and other fields separated by delimiters; this became more common than column-oriented syntax in the 1960s. | ||
| Line 63: | Line 63: | ||
Assemblers have been available since the 1950s, as the first step above machine language and before [[high-level programming language]]s such as [[Fortran]], [[ALGOL|Algol]], [[COBOL]] and [[Lisp (programming language)|Lisp]]. There have also been several classes of translators and semi-automatic [[code generation (compiler)|code generators]] with properties similar to both assembly and high-level languages, with [[Speedcode]] as perhaps one of the better-known examples. | Assemblers have been available since the 1950s, as the first step above machine language and before [[high-level programming language]]s such as [[Fortran]], [[ALGOL|Algol]], [[COBOL]] and [[Lisp (programming language)|Lisp]]. There have also been several classes of translators and semi-automatic [[code generation (compiler)|code generators]] with properties similar to both assembly and high-level languages, with [[Speedcode]] as perhaps one of the better-known examples. | ||
There may be several assemblers with different [[Syntax (programming languages)|syntax]] for a particular [[Central processing unit|CPU]] or [[instruction set architecture]]. For instance, an instruction to add memory data to a register in a [[x86]]-family processor might be <code>add eax,[ebx]</code>, in original ''[[Intel syntax]]'', whereas this would be written <code>addl (%ebx),%eax</code> in the ''[[AT&T syntax]]'' used by the [[GNU Assembler]]. Despite different appearances, different syntactic forms generally generate the same numeric [[machine code]]. A single assembler may also have different modes in order to support variations in syntactic forms as well as their exact semantic interpretations (such as [[FASM]]-syntax, [[TASM]]-syntax, ideal mode, etc., in the special case of [[x86 assembly language|x86 assembly]] programming). | There may be several assemblers with different [[Syntax (programming languages)|syntax]] for a particular [[Central processing unit|CPU]] or [[instruction set architecture]]. For instance, an instruction to add memory data to a register in a [[x86]]-family processor might be <code>add eax,[ebx]</code>, in original ''[[Intel syntax]]'', whereas this would be written <code>addl (%ebx),%eax</code> in the ''[[AT&T syntax]]'' used by the [[GNU Assembler]]. Despite different appearances, different syntactic forms generally generate the same numeric [[machine code]]. A single assembler may also have different modes in order to support variations in syntactic forms as well as their exact semantic interpretations (such as [[FASM]]-syntax, [[Turbo Assembler|TASM]]-syntax, ideal mode, etc., in the special case of [[x86 assembly language|x86 assembly]] programming). | ||
==== {{Anchor|Two-pass assembler}} Number of passes==== | ==== {{Anchor|Two-pass assembler}} Number of passes==== | ||
| Line 89: | Line 89: | ||
* High-level abstract data types, including structures/records, unions, classes, and sets | * High-level abstract data types, including structures/records, unions, classes, and sets | ||
* Sophisticated macro processing (although available on ordinary assemblers since the late 1950s for, e.g., the [[IBM 700/7000 series|IBM 700 series]] and [[IBM 700/7000 series|IBM 7000 series]], and since the 1960s for [[IBM System/360]] (S/360), amongst other machines) | * Sophisticated macro processing (although available on ordinary assemblers since the late 1950s for, e.g., the [[IBM 700/7000 series|IBM 700 series]] and [[IBM 700/7000 series|IBM 7000 series]], and since the 1960s for [[IBM System/360]] (S/360), amongst other machines) | ||
* [[Object-oriented programming]] features such as [[ | * [[Object-oriented programming]] features such as [[Class (programming)|class]]es, [[Object (computer science)|object]]s, [[Abstraction (computer science)|abstraction]], [[Polymorphism (computer science)|polymorphism]], and [[inheritance (object-oriented programming)|inheritance]]<ref name="Hyde_2003"/> | ||
See [[#Language design|Language design]] below for more details. | See [[#Language design|Language design]] below for more details. | ||
| Line 102: | Line 102: | ||
<syntaxhighlight lang="nasm">MOV AL, 61h ; Load AL with 97 decimal (61 hex)</syntaxhighlight> | <syntaxhighlight lang="nasm">MOV AL, 61h ; Load AL with 97 decimal (61 hex)</syntaxhighlight> | ||
In some assembly languages (including this one) the same mnemonic, such as MOV, may be used for a family of related instructions for loading, copying and moving data, whether these are immediate values, values in registers, or memory locations pointed to by values in registers or by | In some assembly languages (including this one) the same mnemonic, such as MOV, may be used for a family of related instructions for loading, copying and moving data, whether these are immediate values, values in registers, or memory locations pointed to by values in registers or by direct addresses embedded in the instruction. Other assemblers may use separate opcode mnemonics such as L for "move memory to register", ST for "move register to memory", LR for "move register to register", MVI for "move immediate operand to memory", etc. | ||
If the same mnemonic is used for different instructions, that means that the mnemonic corresponds to several different binary instruction codes, excluding data (e.g. the <code>61h</code> in this example), depending on the operands that follow the mnemonic. For example, for the x86/IA-32 CPUs, the Intel assembly language syntax <code>MOV AL, AH</code> represents an instruction that moves the contents of register ''AH'' into register ''AL''. The<ref group="nb" name="NB3"/> hexadecimal form of this instruction is: | If the same mnemonic is used for different instructions, that means that the mnemonic corresponds to several different binary instruction codes, excluding data (e.g. the <code>61h</code> in this example), depending on the operands that follow the mnemonic. For example, for the x86/IA-32 CPUs, the Intel assembly language syntax <code>MOV AL, AH</code> represents an instruction that moves the contents of register ''AH'' into register ''AL''. The<ref group="nb" name="NB3"/> hexadecimal form of this instruction is: | ||
| Line 127: | Line 127: | ||
In each case, the MOV mnemonic is translated directly into one of the opcodes 88-8C, 8E, A0-A3, B0-BF, C6 or C7 by an assembler, and the programmer normally does not have to know or remember which.<ref name="Intel_1999"/> | In each case, the MOV mnemonic is translated directly into one of the opcodes 88-8C, 8E, A0-A3, B0-BF, C6 or C7 by an assembler, and the programmer normally does not have to know or remember which.<ref name="Intel_1999"/> | ||
An assembler transforms assembly language into machine code, and the reverse can at least partially be achieved by a [[disassembler]]. Unlike [[high-level programming language|high-level languages]], there is a [[bijection|one-to-one correspondence]] between many simple assembly statements and machine language instructions. However, in some cases, an assembler may provide ''pseudoinstructions'' (essentially macros) which expand into several machine language instructions to provide commonly needed functionality. For example, for a machine that lacks a "branch if greater or equal" instruction, an assembler may provide a pseudoinstruction that expands to the machine's "set if less than" and "branch if zero (on the result of the set instruction)". Most full-featured assemblers also provide a rich [[macro (computer science)|macro]] language (discussed below) which is used by vendors and programmers to generate more complex code and data sequences. Since the information about pseudoinstructions and macros defined in the assembler environment is not present in the object program, a disassembler cannot reconstruct the macro and pseudoinstruction invocations but can only disassemble the actual machine instructions that the assembler generated from those abstract assembly-language entities. Likewise, since comments in the assembly language source file are ignored by the assembler and have no effect on the object code it generates, a disassembler is always completely unable to recover source comments.{{Citation needed|date=April 2026}} | |||
Each [[computer architecture]] has its own machine language. Computers differ in the number and type of operations they support, in the different sizes and numbers of registers, and in the representations of data in storage. While most general-purpose computers are able to carry out essentially the same functionality, the ways they do so differ; the corresponding assembly languages reflect these differences. | Each [[computer architecture]] has its own machine language. Computers differ in the number and type of operations they support, in the different sizes and numbers of registers, and in the representations of data in storage. While most general-purpose computers are able to carry out essentially the same functionality, the ways they do so differ; the corresponding assembly languages reflect these differences. | ||
| Line 133: | Line 133: | ||
Multiple sets of [[mnemonic]]s or assembly-language syntax may exist for a single instruction set, typically instantiated in different assembler programs. In these cases, the most popular one is usually that supplied by the CPU manufacturer and used in its documentation. | Multiple sets of [[mnemonic]]s or assembly-language syntax may exist for a single instruction set, typically instantiated in different assembler programs. In these cases, the most popular one is usually that supplied by the CPU manufacturer and used in its documentation. | ||
Two examples of CPUs that have two different sets of mnemonics are the Intel 8080 family and the Intel 8086/8088. Because Intel claimed copyright on its assembly language mnemonics (on each page of their documentation published in the 1970s and early 1980s, at least), some companies that independently produced CPUs compatible with Intel instruction sets invented their own mnemonics. The [[Zilog Z80]] CPU, an enhancement of the [[Intel 8080A]], supports all the 8080A instructions plus many more; Zilog invented an entirely new assembly language, not only for the new instructions but also for all of the 8080A instructions. For example, where Intel uses the mnemonics ''MOV'', ''MVI'', ''LDA'', ''STA'', ''LXI'', ''LDAX'', ''STAX'', ''LHLD'', and ''SHLD'' for various data transfer instructions, the Z80 assembly language uses the mnemonic ''LD'' for all of them. A similar case is the [[NEC V20]] and [[NEC V30|V30]] CPUs, enhanced copies of the Intel 8086 and 8088, respectively. Like Zilog with the Z80, NEC invented new mnemonics for all of the 8086 and 8088 instructions, to avoid accusations of infringement of Intel's copyright. (It is questionable whether such copyrights can be valid, and later CPU companies such as [[AMD]]<ref group="nb" name="NB1"/> and [[Cyrix]] republished Intel's x86/IA-32 instruction mnemonics exactly with neither permission nor legal penalty.) It is doubtful whether in practice many people who programmed the V20 and V30 actually wrote in NEC's assembly language rather than Intel's; since any two assembly languages for the same instruction set architecture are isomorphic (somewhat like English and [[Pig Latin]]), there is no requirement to use a manufacturer's own published assembly language with that manufacturer's products. | Two examples of CPUs that have two different sets of mnemonics are the Intel 8080 family and the Intel 8086/8088. Because Intel claimed copyright on its assembly language mnemonics (on each page of their documentation published in the 1970s and early 1980s, at least), some companies that independently produced CPUs compatible with Intel instruction sets invented their own mnemonics. The [[Zilog Z80]] CPU, an enhancement of the [[Intel 8080A]], supports all the 8080A instructions plus many more; Zilog invented an entirely new assembly language, not only for the [[Z80 instruction set|new instructions]] but also for all of the 8080A instructions. For example, where Intel uses the mnemonics ''MOV'', ''MVI'', ''LDA'', ''STA'', ''LXI'', ''LDAX'', ''STAX'', ''LHLD'', and ''SHLD'' for various data transfer instructions, the Z80 assembly language uses the mnemonic ''LD'' for all of them. A similar case is the [[NEC V20]] and [[NEC V30|V30]] CPUs, enhanced copies of the Intel 8086 and 8088, respectively. Like Zilog with the Z80, NEC invented new mnemonics for all of the 8086 and 8088 instructions, to avoid accusations of infringement of Intel's copyright. (It is questionable whether such copyrights can be valid, and later CPU companies such as [[AMD]]<ref group="nb" name="NB1"/> and [[Cyrix]] republished Intel's x86/IA-32 instruction mnemonics exactly with neither permission nor legal penalty.) It is doubtful whether in practice many people who programmed the V20 and V30 actually wrote in NEC's assembly language rather than Intel's; since any two assembly languages for the same instruction set architecture are isomorphic (somewhat like English and [[Pig Latin]]), there is no requirement to use a manufacturer's own published assembly language with that manufacturer's products. | ||
=== "Hello, world!" on bare hardware === | |||
"Hello, world!" can be printed using 32-bit assembly language for an [[x86]] processor with little help from an operating system. "Call outchr" calls some mechanism that prints a character in AL to the console. A non zero-length string must be terminated with a byte of zero. | |||
<syntaxhighlight lang="nasm"> | |||
hello: | |||
mov esi,msg ; address of string into ESI | |||
cld ; Set direction to increment ESI | |||
lodsb ; Load first char in AL, inc ESI | |||
chrlp: | |||
call outchr ; Print character in AL | |||
lodsb ; Load next character in AL, inc ESI | |||
or al, al ; Is it a zero terminator? | |||
bne chrlp ; If not, continue | |||
ret ; Return to caller | |||
msg: db 'Hello, world!', 0xa, 0x0 ; string to be printed | |||
</syntaxhighlight> | |||
=== "Hello, world!" on x86 Linux === | === "Hello, world!" on x86 Linux === | ||
In 32-bit assembly language for Linux on an [[x86]] processor, "Hello, world!" | In 32-bit assembly language for Linux on an [[x86]] processor, "Hello, world!" would be printed by an single operating system call: | ||
<syntaxhighlight lang="nasm"> | <syntaxhighlight lang="nasm"> | ||
section .text | section .text ; start of the code segment | ||
global _start | global _start ; declare _start to be visible in the generated object file | ||
_start: | _start: | ||
| Line 152: | Line 170: | ||
int 0x80 ; system call trap | int 0x80 ; system call trap | ||
section .data | section .data ; start of data segment | ||
msg db 'Hello, world!', 0xa | msg db 'Hello, world!', 0xa ; string to be printed | ||
len equ $ - msg | len equ $ - msg ; length of that string as a constant calculated at assembly time | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 216: | Line 234: | ||
===Support for structured programming=== | ===Support for structured programming=== | ||
<!-- With rare exceptions, macros are not part of the assembler but reside in the source code or in macro libraries. --> | <!-- With rare exceptions, macros are not part of the assembler but reside in the source code or in macro libraries. --> | ||
Packages of macros have been written providing [[structured programming]] elements to encode execution flow. The earliest example of this approach was in the | Packages of macros have been written providing [[structured programming]] elements to encode execution flow. The earliest example of this approach was in the Concept-14 macro set,<ref name="Kessler_1970"/> originally proposed by [[Harlan Mills]] (March 1970), and implemented by Marvin Kessler at IBM's Federal Systems Division, which provided IF/ELSE/ENDIF and similar control flow blocks for OS/360 assembler programs. This was a way to reduce or eliminate the use of [[GOTO]] operations in assembly code, one of the main factors causing [[spaghetti code]] in assembly language. This approach was widely accepted in the early 1980s (the latter days of large-scale assembly language use). IBM's High Level Assembler Toolkit<ref>{{cite web | ||
| title = High Level Assembler Toolkit Feature Increases Programmer Productivity | | title = High Level Assembler Toolkit Feature Increases Programmer Productivity | ||
| id = A95-1432 | | id = A95-1432 | ||
| Line 229: | Line 247: | ||
</ref> includes such a macro package. | </ref> includes such a macro package. | ||
Another design was | Another design was A-Natural,<ref>{{Cite book |last=Whitesmiths Ltd |url=http://archive.org/details/a-natural-manual |title=A-Natural Language Reference Manual |date=1980-07-15}}</ref> a "stream-oriented" assembler for 8080/[[Zilog Z80|Z80]] processors from [[Whitesmiths|Whitesmiths Ltd.]] (developers of the [[Unix]]-like [[Idris (operating system)|Idris]] operating system, and what was reported to be the first commercial [[C (programming language)|C]] [[compiler]]). The language was classified as an assembler because it worked with raw machine elements such as [[opcode]]s, [[processor register|registers]], and memory references; but it incorporated an expression syntax to indicate execution order. Parentheses and other special symbols, along with block-oriented structured programming constructs, controlled the sequence of the generated instructions. A-natural was built as the object language of a C compiler, rather than for hand-coding, but its logical syntax won some fans. | ||
There has been little apparent demand for more sophisticated assemblers since the decline of large-scale assembly language development.<ref name="assembly-language?cat=technology"/> In spite of that, they are still being developed and applied in cases where resource constraints or peculiarities in the target system's architecture prevent the effective use of higher-level languages.<ref name="Provinciano_2005"/> | There has been little apparent demand for more sophisticated assemblers since the decline of large-scale assembly language development.<ref name="assembly-language?cat=technology"/> In spite of that, they are still being developed and applied in cases where resource constraints or peculiarities in the target system's architecture prevent the effective use of higher-level languages.<ref name="Provinciano_2005"/> | ||
| Line 279: | Line 297: | ||
Numerous programs were written entirely in assembly language. The [[Burroughs MCP]] (1961) was the first computer for which an operating system was not developed entirely in assembly language; it was written in [[Executive Systems Problem Oriented Language]] (ESPOL), an Algol dialect. Many commercial applications were written in assembly language as well, including a large amount of the [[IBM mainframe]] software developed by large corporations. [[COBOL]], [[FORTRAN]] and some PL/I eventually displaced assembly language, although a number of large organizations retained assembly-language application infrastructures well into the 1990s. | Numerous programs were written entirely in assembly language. The [[Burroughs MCP]] (1961) was the first computer for which an operating system was not developed entirely in assembly language; it was written in [[Executive Systems Problem Oriented Language]] (ESPOL), an Algol dialect. Many commercial applications were written in assembly language as well, including a large amount of the [[IBM mainframe]] software developed by large corporations. [[COBOL]], [[FORTRAN]] and some PL/I eventually displaced assembly language, although a number of large organizations retained assembly-language application infrastructures well into the 1990s. | ||
Assembly language was the primary development language for 8-bit home computers such as the [[Apple II]], [[Atari 8-bit computers]], [[ZX Spectrum]], and [[Commodore 64]]. [[Interpreter (computing)|Interpreted]] [[BASIC]] on these systems did not offer maximum execution speed and full use of facilities to take full advantage of the available hardware. Assembly language was the default choice for programming 8-bit consoles such as the [[Atari 2600]] and [[Nintendo Entertainment System]]. | Assembly language was the primary development language for 8-bit home computers such as the [[Apple II]], [[Atari 8-bit computers]], [[ZX Spectrum]], and [[Commodore 64]]. [[Interpreter (computing)|Interpreted]] [[BASIC]] on these systems did not offer maximum execution speed and full use of facilities to take full advantage of the available hardware. Assembly language was the default choice for programming 8-bit consoles such as the [[Atari 2600]] and [[Nintendo Entertainment System]].<ref>{{Cite web |title=Oversimplified History of Retro Game Consoles for Programmers |url=https://pikuma.com/blog/game-console-history-for-programmers |access-date=2026-04-16 |website=pikuma.com |language=en-us}}</ref> | ||
Key software for [[IBM PC compatible]]s such as [[MS-DOS]], [[Turbo Pascal]], and the [[Lotus 1-2-3]] spreadsheet was written in assembly language. As computer speed grew exponentially, assembly language became a tool for speeding up parts of programs, such as the rendering of ''[[Doom (1993 video game)|Doom]]'', rather than a dominant development language. In the 1990s, assembly language was used to maximise performance from systems such as the [[Sega Saturn]],<ref name="Pettus_2008"/> and as the primary language for arcade hardware using the [[TMS34010]] integrated CPU/GPU such as ''[[Mortal Kombat (1992 video game)|Mortal Kombat]]'' and ''[[NBA Jam (1993 video game)|NBA Jam]]''. | Key software for [[IBM PC compatible]]s such as [[MS-DOS]], [[Turbo Pascal]], and the [[Lotus 1-2-3]] spreadsheet was written in assembly language. As computer speed grew exponentially, assembly language became a tool for speeding up parts of programs, such as the rendering of ''[[Doom (1993 video game)|Doom]]'', rather than a dominant development language. In the 1990s, assembly language was used to maximise performance from systems such as the [[Sega Saturn]],<ref name="Pettus_2008"/> and as the primary language for arcade hardware using the [[TMS34010]] integrated CPU/GPU such as ''[[Mortal Kombat (1992 video game)|Mortal Kombat]]'' and ''[[NBA Jam (1993 video game)|NBA Jam]]''. | ||
| Line 302: | Line 320: | ||
* Cryptographic algorithms that must always take strictly the same time to execute, preventing [[timing attack]]s. | * Cryptographic algorithms that must always take strictly the same time to execute, preventing [[timing attack]]s. | ||
* Video encoders and decoders such as rav1e (an encoder for [[AV1]])<ref>{{cite web |url=https://github.com/xiph/rav1e/blob/v0.6.3/README.md#features-1= |title=rav1e/README.md at v0.6.3 |website=[[GitHub]] |access-date=21 February 2023 |archive-date=22 February 2023 |archive-url=https://web.archive.org/web/20230222005925/https://github.com/xiph/rav1e/blob/v0.6.3/README.md |url-status=live}}</ref> and dav1d (the reference decoder for AV1)<ref>{{cite web |url=https://code.videolan.org/videolan/dav1d/-/blob/1.1.0/README.md |title=README.md · 1.1.0 · VideoLAN / dav1d |date=13 February 2023 |access-date=21 February 2023 |archive-date=22 February 2023 |archive-url=https://web.archive.org/web/20230222004317/https://code.videolan.org/videolan/dav1d/-/blob/1.1.0/README.md |url-status=live}}</ref> contain assembly to leverage [[AVX2]] and [[Neon (instruction set)|ARM Neon]] instructions when available. | * Video encoders and decoders such as rav1e (an encoder for [[AV1]])<ref>{{cite web |url=https://github.com/xiph/rav1e/blob/v0.6.3/README.md#features-1= |title=rav1e/README.md at v0.6.3 |website=[[GitHub]] |access-date=21 February 2023 |archive-date=22 February 2023 |archive-url=https://web.archive.org/web/20230222005925/https://github.com/xiph/rav1e/blob/v0.6.3/README.md |url-status=live}}</ref> and dav1d (the reference decoder for AV1)<ref>{{cite web |url=https://code.videolan.org/videolan/dav1d/-/blob/1.1.0/README.md |title=README.md · 1.1.0 · VideoLAN / dav1d |date=13 February 2023 |access-date=21 February 2023 |archive-date=22 February 2023 |archive-url=https://web.archive.org/web/20230222004317/https://code.videolan.org/videolan/dav1d/-/blob/1.1.0/README.md |url-status=live}}</ref> contain assembly to leverage [[AVX2]] and [[Neon (instruction set)|ARM Neon]] instructions when available. | ||
* Modify and extend legacy code written for IBM mainframe computers.<ref name="Bosworth_2016"/><ref>{{cite web |url=https://www-01.ibm.com/servers/resourcelink/svc00100.nsf/pages/zOSV2R3sc236852/$file/idad500_v2r3.pdf |title=z/OS Version 2 Release 3 DFSMS Macro Instructions for Data Sets |publisher=IBM |date=15 February 2019 |access-date=14 September 2021 |url-status=live|archive-url=https://web.archive.org/web/20210625140314/https://www-01.ibm.com/servers/resourcelink/svc00100.nsf/pages/zOSV2R3sc236852/$file/idad500_v2r3.pdf |archive-date=25 June 2021 }}</ref> | * Modify and extend legacy code written for [[IBM mainframe]] computers.<ref name="Bosworth_2016"/><ref>{{cite web |url=https://www-01.ibm.com/servers/resourcelink/svc00100.nsf/pages/zOSV2R3sc236852/$file/idad500_v2r3.pdf |title=z/OS Version 2 Release 3 DFSMS Macro Instructions for Data Sets |publisher=IBM |date=15 February 2019 |access-date=14 September 2021 |url-status=live|archive-url=https://web.archive.org/web/20210625140314/https://www-01.ibm.com/servers/resourcelink/svc00100.nsf/pages/zOSV2R3sc236852/$file/idad500_v2r3.pdf |archive-date=25 June 2021 }}</ref> | ||
* Situations where complete control over the environment is required, in extremely high-security situations where [[Trusting trust#Reflections on Trusting Trust|nothing can be taken for granted]]. | * Situations where complete control over the environment is required, in extremely high-security situations where [[Trusting trust#Reflections on Trusting Trust|nothing can be taken for granted]]. | ||
* [[Computer virus]]es, [[bootloader]]s, certain [[device driver]]s, or other items very close to the hardware or low-level operating system. | * [[Computer virus]]es, [[bootloader]]s, certain [[device driver]]s, or other items very close to the hardware or low-level operating system. | ||
| Line 324: | Line 342: | ||
==See also== | ==See also== | ||
{{Portal|Computer programming}} | {{Portal|Computer programming}} | ||
* [[Compiler]] | * {{Annotated link|[[Compiler]]}} | ||
* [[Comparison of assemblers]] | * {{Annotated link|[[Comparison of assemblers]]}} | ||
* [[Disassembler]] | * {{Annotated link|[[Disassembler]]}} | ||
* [[Hexadecimal]] | * {{Annotated link|[[Hexadecimal]]}} | ||
* [[Instruction set architecture]] | * {{Annotated link|[[Information Processing Language]]}} | ||
* [[Little man computer]] | * {{Annotated link|[[Instruction set architecture]]}} | ||
* [[Nibble]] | * [[List of assembly software and tools]] | ||
* [[Typed assembly language]] | * {{Annotated link|[[Little man computer]]}} | ||
* {{Annotated link|[[Nibble]]}} | |||
* {{Annotated link|[[Typed assembly language]]}} | |||
==Notes== | ==Notes== | ||
| Line 380: | Line 400: | ||
<ref name="Kessler_1970">{{cite web |author-first=Marvin M. |author-last=Kessler |title=*Concept* Report 14 - Implementation of Macros To Permit Structured Programming in OS/360 |publisher=[[International Business Machines Corporation]] |location=Gaithersburg, Maryland, US |date=1970-12-18 |work=MVS Software: Concept 14 Macros |url=http://skycoast.us/pscott/software/mvs/concept14.html |access-date=2009-05-25 |url-status=live |archive-url=https://web.archive.org/web/20200324160528/http://skycoast.us/pscott/software/mvs/concept14.html |archive-date=2020-03-24}}</ref> | <ref name="Kessler_1970">{{cite web |author-first=Marvin M. |author-last=Kessler |title=*Concept* Report 14 - Implementation of Macros To Permit Structured Programming in OS/360 |publisher=[[International Business Machines Corporation]] |location=Gaithersburg, Maryland, US |date=1970-12-18 |work=MVS Software: Concept 14 Macros |url=http://skycoast.us/pscott/software/mvs/concept14.html |access-date=2009-05-25 |url-status=live |archive-url=https://web.archive.org/web/20200324160528/http://skycoast.us/pscott/software/mvs/concept14.html |archive-date=2020-03-24}}</ref> | ||
<ref name="assembly-language?cat=technology">{{cite web |title=assembly language: Definition and Much More from Answers.com |website=answers.com |url=http://www.answers.com/topic/assembly-language?cat=technology |access-date=2008-06-19 |url-status=dead |archive-url=https://web.archive.org/web/20090608215406/http://www.answers.com/topic/assembly-language?cat=technology |archive-date=8 June 2009 }}</ref> | <ref name="assembly-language?cat=technology">{{cite web |title=assembly language: Definition and Much More from Answers.com |website=answers.com |url=http://www.answers.com/topic/assembly-language?cat=technology |access-date=2008-06-19 |url-status=dead |archive-url=https://web.archive.org/web/20090608215406/http://www.answers.com/topic/assembly-language?cat=technology |archive-date=8 June 2009 }}</ref> | ||
<ref name="Provinciano_2005">{{cite web |author-last=Provinciano |author-first=Brian |title=NESHLA: The High Level, Open Source, 6502 Assembler for the Nintendo Entertainment System |date=2005-04-17 |url= | <ref name="Provinciano_2005">{{cite web |author-last=Provinciano |author-first=Brian |title=NESHLA: The High Level, Open Source, 6502 Assembler for the Nintendo Entertainment System |date=2005-04-17 |url=https://neshla.sourceforge.net/ |access-date=2020-03-24 |url-status=live |archive-url=https://web.archive.org/web/20200324161216/http://neshla.sourceforge.net/ |archive-date=2020-03-24}}</ref> | ||
<ref name="Dufresne_2018">{{cite web |author-first=Steven |author-last=Dufresne |date=2018-08-21 |title=Kathleen Booth: Assembling Early Computers While Inventing Assembly |url=https://hackaday.com/2018/08/21/kathleen-booth-assembling-early-computers-while-inventing-assembly |access-date=2019-02-10 |url-status=live |archive-url=https://web.archive.org/web/20200324150537/https://hackaday.com/2018/08/21/kathleen-booth-assembling-early-computers-while-inventing-assembly/ |archive-date=2020-03-24}}</ref> | <ref name="Dufresne_2018">{{cite web |author-first=Steven |author-last=Dufresne |date=2018-08-21 |title=Kathleen Booth: Assembling Early Computers While Inventing Assembly |url=https://hackaday.com/2018/08/21/kathleen-booth-assembling-early-computers-while-inventing-assembly |access-date=2019-02-10 |url-status=live |archive-url=https://web.archive.org/web/20200324150537/https://hackaday.com/2018/08/21/kathleen-booth-assembling-early-computers-while-inventing-assembly/ |archive-date=2020-03-24}}</ref> | ||
<ref name="Booth_1947">{{cite book |author-first1=Andrew Donald |author-last1=Booth |author-link1=Andrew Donald Booth |author-first2=Kathleen Hylda Valerie |author-last2=Britten |author-link2=Kathleen Hylda Valerie Britten |title=General considerations in the design of an all purpose electronic digital computer<!-- (Coding for the ARC) --> |edition=2 |location=The Institute for Advanced Study, Princeton, New Jersey, US |publisher=[[Birkbeck College, London]] |date=September 1947 |orig-year=August 1947 |url=http://mt-archive.info/Booth-1947.pdf |access-date=2019-02-10 |url-status=live |archive-url=https://web.archive.org/web/20200324161441/http://mt-archive.info/Booth-1947.pdf |archive-date=2020-03-24 |quote=The non-original ideas, contained in the following text, have been derived from a number of sources, ... It is felt, however, that acknowledgement should be made to Prof. John von Neumann and to Dr. Herman Goldstein for many fruitful discussions ...}}</ref> | <ref name="Booth_1947">{{cite book |author-first1=Andrew Donald |author-last1=Booth |author-link1=Andrew Donald Booth |author-first2=Kathleen Hylda Valerie |author-last2=Britten |author-link2=Kathleen Hylda Valerie Britten |title=General considerations in the design of an all purpose electronic digital computer<!-- (Coding for the ARC) --> |edition=2 |location=The Institute for Advanced Study, Princeton, New Jersey, US |publisher=[[Birkbeck College, London]] |date=September 1947 |orig-year=August 1947 |url=http://mt-archive.info/Booth-1947.pdf |access-date=2019-02-10 |url-status=live |archive-url=https://web.archive.org/web/20200324161441/http://mt-archive.info/Booth-1947.pdf |archive-date=2020-03-24 |quote=The non-original ideas, contained in the following text, have been derived from a number of sources, ... It is felt, however, that acknowledgement should be made to Prof. John von Neumann and to Dr. Herman Goldstein for many fruitful discussions ...}}</ref> | ||
| Line 398: | Line 418: | ||
<ref name="Hyde_2008">{{cite web |title=The Great Debate |access-date=2008-07-03 |author-first=Randall |author-last=Hyde |author-link=Randall Hyde |url=http://webster.cs.ucr.edu/Page_TechDocs/GreatDebate/debate1.html |url-status=dead |archive-url=https://web.archive.org/web/20080616110102/http://webster.cs.ucr.edu/Page_TechDocs/GreatDebate/debate1.html |archive-date=2008-06-16}}</ref> | <ref name="Hyde_2008">{{cite web |title=The Great Debate |access-date=2008-07-03 |author-first=Randall |author-last=Hyde |author-link=Randall Hyde |url=http://webster.cs.ucr.edu/Page_TechDocs/GreatDebate/debate1.html |url-status=dead |archive-url=https://web.archive.org/web/20080616110102/http://webster.cs.ucr.edu/Page_TechDocs/GreatDebate/debate1.html |archive-date=2008-06-16}}</ref> | ||
<ref name="compiler-fails1">{{cite web |title=Code sourcery fails again |website=hardwarebug.org |date=2010-01-30 |url=http://hardwarebug.org/2008/11/28/codesourcery-fails-again/ |access-date=2010-03-04 |url-status=dead |archive-url=https://web.archive.org/web/20100402221204/http://hardwarebug.org/2008/11/28/codesourcery-fails-again/ |archive-date=2010-04-02}}</ref> | <ref name="compiler-fails1">{{cite web |title=Code sourcery fails again |website=hardwarebug.org |date=2010-01-30 |url=http://hardwarebug.org/2008/11/28/codesourcery-fails-again/ |access-date=2010-03-04 |url-status=dead |archive-url=https://web.archive.org/web/20100402221204/http://hardwarebug.org/2008/11/28/codesourcery-fails-again/ |archive-date=2010-04-02}}</ref> | ||
<ref name="Click_2014">{{cite web |author-last1=Click |author-first1=Cliff |author-first2=Brian |author-last2=Goetz |title=A Crash Course in Modern Hardware |url=http://www.infoq.com/presentations/click-crash-course-modern-hardware |access-date=2014-05-01 |url-status=live |archive-url=https://web.archive.org/web/20200324164402/https://www.infoq.com/presentations/click-crash-course-modern-hardware/ |archive-date=2020-03-24}}</ref> | <ref name="Click_2014">{{cite web |author-last1=Click |author-first1=Cliff |author-link1=Cliff Click|author-first2=Brian |author-last2=Goetz |title=A Crash Course in Modern Hardware |url=http://www.infoq.com/presentations/click-crash-course-modern-hardware |access-date=2014-05-01 |url-status=live |archive-url=https://web.archive.org/web/20200324164402/https://www.infoq.com/presentations/click-crash-course-modern-hardware/ |archive-date=2020-03-24}}</ref> | ||
<ref name="Fargo_2008">{{cite web |title=68K Programming in Fargo II |url=http://tifreakware.net/tutorials/89/a/calc/fargoii.htm |access-date=2008-07-03 |url-status=live |archive-url=https://web.archive.org/web/20080702181616/http://tifreakware.net/tutorials/89/a/calc/fargoii.htm |archive-date=2008-07-02}}</ref> | <ref name="Fargo_2008">{{cite web |title=68K Programming in Fargo II |url=http://tifreakware.net/tutorials/89/a/calc/fargoii.htm |access-date=2008-07-03 |url-status=live |archive-url=https://web.archive.org/web/20080702181616/http://tifreakware.net/tutorials/89/a/calc/fargoii.htm |archive-date=2008-07-02}}</ref> | ||
<ref name="BLAS_2008">{{cite web |title=BLAS Benchmark-August2008 |publisher=eigen.tuxfamily.org |date=2008-08-01 |url=http://eigen.tuxfamily.org/index.php?title=Benchmark-August2008 |access-date=2010-03-04 |url-status=live |archive-url=https://web.archive.org/web/20200324164844/http://eigen.tuxfamily.org/index.php?title=Benchmark-August2008 |archive-date=2020-03-24}}</ref> | <ref name="BLAS_2008">{{cite web |title=BLAS Benchmark-August2008 |publisher=eigen.tuxfamily.org |date=2008-08-01 |url=http://eigen.tuxfamily.org/index.php?title=Benchmark-August2008 |access-date=2010-03-04 |url-status=live |archive-url=https://web.archive.org/web/20200324164844/http://eigen.tuxfamily.org/index.php?title=Benchmark-August2008 |archive-date=2020-03-24}}</ref> | ||
| Line 426: | Line 446: | ||
* [http://wiki.c2.com/?AssemblyLanguage Assembly Language] and [http://wiki.c2.com/?LearningAssemblyLanguage Learning Assembly Language] pages on [[WikiWikiWeb]] | * [http://wiki.c2.com/?AssemblyLanguage Assembly Language] and [http://wiki.c2.com/?LearningAssemblyLanguage Learning Assembly Language] pages on [[WikiWikiWeb]] | ||
* [http://www.azillionmonkeys.com/qed/asmexample.html Assembly Language Programming Examples] | * [http://www.azillionmonkeys.com/qed/asmexample.html Assembly Language Programming Examples] | ||
* [https://ethical.blue/en/c3a1 Introduction to Windows x64 Assembly Language] | |||
{{Types of programming languages}} | {{Types of programming languages}} | ||