An opcode, also op code or operational code is a number that indicates the number of a machine instruction for a specific processor type. All opcodes together form the instruction set of the processor or processor family. Each command has its own opcode, such as addition, multiplication, copying of registers, loading and saving of registers from memory, input and output, etc. Simple opcodes already provide a machine instruction dar. At a part of the opcode must address constants followed, or the like, which then form a machine instruction with the opcode.
Each opcode is assigned a short word or abbreviation, called a mnemonic. With the mnemonics results in the assembly languages , in each of which a mnemonic, optionally followed by addresses or constants, is written in a line of a text file. A special program, the assembler generates machine code by replacing it essentially the mnemonics by their respective opcodes.
Most modern processors have several hundred opcodes.
Older processors often had " undefined " or " illegal" opcodes. Certain, not intended for programming opcodes were by their side effects on the internal circuitry of the processor have all kinds of strange, harmful or rarely also useful effects. Such opcodes were sometimes used in the programming of computer games on home computers and game consoles early in order to run certain operations a little faster or to disguise the operation of copy protection. The disadvantage was that such " undefined opcodes " by the manufacturer were not guaranteed and subsequent models of a processor often does not work anymore. Today's processors either do about anything if they encounter an unknown opcode in a program, or they go into a well-defined error condition.
The 8- bit processor Z80
Note: For the Z80, there are two different mnemonics (LD M, B or LD ( HL ), B), added a third for the previous CPU Intel 8085 ( MOV M, B).
The following Z80 mnemonics
DEC A INC B SUB B LD HL, 1234h produce the following Z80 machine program
05 04 90 21 34 12 Machine programs are now almost always represented in hexadecimal (rare alternatives: decimal, octal). Sometimes 16- bit values are not displayed as two 8 -bit words in the byte order in memory, rather than a 16 -bit word in the logical order:
05 04 90 21 1234 The relay computer Zuse Z3
The Z3 by Konrad Zuse in 1941 had two registers R1 and R2, 64 memory cells and dominated the Ein-/Ausgabe, the four basic arithmetic operations and the root calculation of floating point numbers. Programs were stored on punched tape, the opcodes of the nine commands consisted of the following paper tape codes:
The tape is 8 bits wide. The opcode for the memory accesses occupy only 2 bits, followed by the address of the memory cell. Other opcodes use 5 bits, 3 bits are unused.