In
computing
Computing is any goal-oriented activity requiring, benefiting from, or creating computing machinery. It includes the study and experimentation of algorithmic processes, and development of both hardware and software. Computing has scientific, ...
, an opcode
(abbreviated from operation code,
also known as instruction machine code,
instruction code,
instruction syllable,
instruction parcel or opstring
) is the portion of a
machine language instruction that specifies the operation to be performed. Beside the opcode itself, most instructions also specify the data they will process, in the form of
operands. In addition to opcodes used in the
instruction set architectures of various
CPU
A central processing unit (CPU), also called a central processor, main processor or just processor, is the electronic circuitry that executes instructions comprising a computer program. The CPU performs basic arithmetic, logic, controlling, and ...
s, which are hardware devices, they can also be used in
abstract computing machines as part of their
byte code specifications.
Overview
Specifications and format of the opcodes are laid out in the instruction set architecture (
ISA
Isa or ISA may refer to:
Places
* Isa, Amur Oblast, Russia
* Isa, Kagoshima, Japan
* Isa, Nigeria
* Isa District, Kagoshima, former district in Japan
* Isa Town, middle class town located in Bahrain
* Mount Isa, Queensland, Australia
* Mount Is ...
) of the processor in question, which may be a general
CPU
A central processing unit (CPU), also called a central processor, main processor or just processor, is the electronic circuitry that executes instructions comprising a computer program. The CPU performs basic arithmetic, logic, controlling, and ...
or a more specialized processing unit.
Opcodes for a given instruction set can be described through the use of an
opcode table detailing all possible opcodes. Apart from the opcode itself, an instruction normally also has one or more specifiers for
operands (i.e. data) on which the operation should act, although some operations may have ''implicit'' operands, or none at all.
There are instruction sets with nearly uniform fields for opcode and operand specifiers, as well as others (the
x86 architecture for instance) with a more complicated, variable-length structure.
Instruction sets can be extended through the use of
opcode prefixes which add a subset of new instructions made up of existing opcodes following reserved byte sequences.
Operands
Depending on architecture, the ''operands'' may be
register values, values in the
stack
Stack may refer to:
Places
* Stack Island, an island game reserve in Bass Strait, south-eastern Australia, in Tasmania’s Hunter Island Group
* Blue Stack Mountains, in Co. Donegal, Ireland
People
* Stack (surname) (including a list of people ...
, other
memory
Memory is the faculty of the mind by which data or information is encoded, stored, and retrieved when needed. It is the retention of information over time for the purpose of influencing future action. If past events could not be remembered ...
values,
I/O ports (which may also be
memory mapped), etc., specified and accessed using more or less complex
addressing modes. The types of ''operations'' include
arithmetic, data copying,
logical operations, and program control, as well as special instructions (such as
CPUID and others).
Assembly language, or just ''assembly'', is a
low-level programming language, which uses
mnemonic instructions and operands to represent
machine code.
This enhances the readability while still giving precise control over the machine instructions. Most programming is currently done using
high-level programming language
In computer science, a high-level programming language is a programming language with strong abstraction from the details of the computer. In contrast to low-level programming languages, it may use natural language ''elements'', be easier to ...
s,
which are typically easier for humans to understand and write.
These languages need to be compiled (translated into assembly language) by a
system-specific
compiler
In computing, a compiler is a computer program that translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primarily used for programs that ...
, or run through other compiled programs.
Software instruction sets
Opcodes can also be found in so-called
byte codes and other representations intended for a software interpreter rather than a hardware device. These software-based instruction sets often employ slightly higher-level data types and operations than most hardware counterparts, but are nevertheless constructed along similar lines. Examples include the byte code found in
Java class files which are then interpreted by the
Java Virtual Machine (JVM), the byte code used in
GNU Emacs for compiled
Lisp
A lisp is a speech impairment in which a person misarticulates sibilants (, , , , , , , ). These misarticulations often result in unclear speech.
Types
* A frontal lisp occurs when the tongue is placed anterior to the target. Interdental lispi ...
code, .NET
Common Intermediate Language (CIL), and many others.
See also
*
Gadget (machine instruction sequence)
*
Illegal opcode
*
Opcode database
*
Syllable (computing)
References
Further reading
*
{{X86 assembly topics
Machine code