Jump to content

Opcode

From Simple English Wikipedia, the free encyclopedia
Revision as of 04:15, 27 September 2011 by 202.36.179.68 (talk) (Changed '3th' to '3rd'; simple overlooked grammatical error.)

An opcode is a basic computer operation in the instruction set. It is used when writing machine code. It tells the computer to do something. Its operands are typically memory or registry addresses.

Opcodes are used in machine code for a number of functions, including Float Addition of registers, Two's compliment addition of registers, Shifting register values to memory, or to a hard drive, sopping a program, etc. There are quite literally hundreds of common opcodes employed in modern computers.

Due to the nature of a computer's architecture, opcodes take the form of binary numbers. Alternatively, opcodes can be represented by Hex, (for example, 10110101 = A5) for ease of reading and coding when designing or emulating a machine-code program. These values are then transformed into their binary equivalents to be saved. Modern opcodes are at least two hex characters in length which take up 1 byte of storage space.

Opcodes will vary in capability and 'value' depending on the computer to which they belong, as they are hardware dependent. For instance, the opcode for STORE as expressed in Hex could be FA for one machine and 02 for another. Some opcodes will not be available on some computers due to the two forms of instruction sets, namely form reduced instruction set computing (RISC), as employed by Apple, which offers less possible opcodes in favour of increasing speed for simple processes, and complex instruction set Computing (CISC), as employed by IBM, offering more opcodes in favour of increasing speed for complex processes.

Opcodes are seldom used by programmers directly. Whenever they are directly programmed into memory, they are only ever guaranteed to work on the computer they were designed for. Alternatively, a high level-programming language can be used, say 4th generation, which gets converted to 3rd generation and so on until it reaches 1st generation. From here, an individual computer will convert the program to machine code whenever the program file is read. This way, a program can work on a much larger variety of computers.