Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Opcode

From Wikipedia, the free encyclopedia
Part of a machine instruction

Machine code
General concepts
Instructions

Incomputing, anopcode (abbreviated fromoperation code)[1][2] is anenumerated value that specifies the operation to be performed. Opcodes are employed in hardware devices such asarithmetic logic units (ALUs),central processing units (CPUs), and software instruction sets. In ALUs, the opcode is directly applied to circuitry via an input signal bus. In contrast, in CPUs, the opcode is the portion of amachine languageinstruction that specifies the operation to be performed.

CPUs

[edit]

Opcodes are found in the machine language instructions of CPUs as well as in someabstract computing machines. In CPUs, an opcode may be referred to as aninstruction machine code,[3]instruction code,[4]instruction syllable,[5][6][7][8]instruction parcel, oropstring.[9][2] For any particular processor (which may be a general CPU or a more specialized processing unit), the opcodes are defined by the processor'sinstruction set architecture (ISA).[10] They can be described using anopcode table. The types of operations may includearithmetic, data copying,logical operations, program control, and special instructions (e.g.,CPUID).[10]

In addition to the opcode, many instructions specify the data (known asoperands) the operation will act upon, although some instructions may have implicit operands or none.[10] Some instruction sets have nearly uniform fields for opcode and operand specifiers, whereas others (e.g.,x86 architecture) have a less uniform, variable-length structure.[10][11] Instruction sets can be extended through opcode prefixes, which add a subset of new instructions made up of existing opcodes following reserved byte sequences.[citation needed]

Sample opcode table

[edit]

This table shows opcodes of a simple 8-bit microprocessor, theIntel 8008 from 1972.

Each opcode is 8bits long. Each is shown as abinary pattern of ones and zeros in theOpcode column. Up to two additional fields may be embedded into the opcode. Some 3-bit fields are labeled DDD, SSS, CC, and ALU. The SSS (source) and DDD (destination) fields specify one of the eight possible 8008registers or memory: A, B, C, D, E, H, L, or M. CC specifies a condition that will activate certain JMP, CAL, and RET instructions. ALU specifies one of a possible eightarithmetic logic unit functions to be performed during an instruction, specifically, add, add with carry, subtract, subtract with borrow, logical AND, logical XOR, logical OR, and compare. TheX in some fields means that either a 1 or 0 can be inserted withno effect.

The fixed ones and zeros are combined with the parameter fields to build the 8-bit opcode. Additionally, the full instruction might require one or two additional bytes of operands. These are shown in the second major column of the table, labeled "Operands". If no operands are required, the column is filled with a dash (—).

Since the ones and zeros are difficult to remember, theMnemonic column shows a short, easy to remember letter code that anassembly language programmer may use to invoke the required opcode.

TheDescription column shows the function performed by the microprocessor when it encounters a specific opcode.

OpcodeOperandsMnemonicDescription
76543210b2b3
0000000XHLTHalt
00DDD000INrDDD ← DDD + 1 (except A and M)
00DDD001DCrDDD ← DDD - 1 (except A and M)
00000010RLCA1-7 ← A0-6; A0 ← Cy ← A7
00CC011Rcc (RET conditional)If cc true, P ← (stack)
00ALU100dataADI ACI SUI SBI NDI XRI ORI CPIdataA ← A [ALU operation] data
00N101RSTn(stack) ← P, P ← N x 8
00DDD110dataLrIdata (Load r with immediate data)DDD ← data
00XXX111RETP ← (stack)
00001010RRCA0-6 ← A1-7; A7 ← Cy ← A0
00010010RALA1-7 ← A0-6; Cy ← A7; A0 ← Cy
00011010RARA0-6 ← A1-7; Cy ← A0; A7 ← Cy
01CC000addloaddhiJccadd (JMP conditional)If cc true, P ← add
0100port1INPportA ← Port (ports 0-7 only)
01port1OUTportPort ← A (ports 8-31 only)
01CC010addloaddhiCccadd (CAL conditional)If cc true, (stack) ← P, P ← add
01XXX100addloaddhiJMPaddP ← add
01XXX110addloaddhiCALadd(stack) ← P, P ← add
10ALUSSSADr ACr SUr SBr NDr XRr ORr CPrA ← A [ALU operation] SSS
11DDDSSSLds (Load d with s)DDD ← SSS
11111111HLTHalt
76543210b2b3MnemonicDescription
SSS DDD210CCALU
A000FC, C falseADr ADI (A ← A + arg)
B001FZ, Z falseACr ACI (A ← A + arg + Cy)
C010FS, S falseSUr SUI (A ← A - arg)
D011FP, P oddSBr SBI (A ← A - arg - Cy)
E100TC, C trueNDr NDI (A ← A ∧ arg)
H101TZ, Z trueXRr XRI (A ← A ⊻ arg)
L110TS, S trueORr ORI (A ← A ∨ arg)
M111TP, P evenCPr CPI (A - arg)
SSS DDD210CCALU

Software instruction sets

[edit]

Opcodes can be found inbytecodes and other representations intended for execution by software interpreters. These often employ slightly higher-level data types and operations than those found in hardware opcodes but are nevertheless constructed along similar lines. Examples include the byte code found inJava class files, which are interpreted byJava virtual machines, the byte code used inGNU Emacs for compiledLisp code, and NETCommon Intermediate Language.[12]

See also

[edit]

References

[edit]
  1. ^Barron, David William (1978) [1971, 1969]. "2.1. Symbolic instructions". Written atUniversity of Southampton, Southampton, UK. In Floretin, J. John (ed.).Assemblers and Loaders. Computer Monographs (3 ed.). New York, USA:Elsevier North-Holland Inc. p. 7.ISBN 0-444-19462-2.LCCN 78-19961. (xii+100 pages)
  2. ^abChiba, Shigeru (2007) [1999]."Javassist, a Java-bytecode translator toolkit".Archived from the original on 2020-03-02. Retrieved2016-05-27.
  3. ^"Appendix B - Instruction Machine Codes"(PDF).MCS-4 Assembly Language Programming Manual - The INTELLEC 4 Microcomputer System Programming Manual (Preliminary ed.). Santa Clara, California, USA:Intel Corporation. December 1973. pp. B-1 –B-8. MCS-030-1273-1.Archived(PDF) from the original on 2020-03-01. Retrieved2020-03-02.
  4. ^Raphael, Howard A., ed. (November 1974)."The Functions Of A Computer: Instruction Register And Decoder"(PDF).MCS-40 User's Manual For Logic Designers. Santa Clara, California, USA:Intel Corporation. p. viii.Archived(PDF) from the original on 2020-03-03. Retrieved2020-03-03.[…] Each operation that the processor can perform is identified by a unique binary number known as an instruction code. […]
  5. ^Jones, Douglas W. (June 1988)."A Minimal CISC".ACM SIGARCH Computer Architecture News.16 (3). New York, USA:Association for Computing Machinery (ACM):56–63.doi:10.1145/48675.48684.S2CID 17280173.
  6. ^Domagała, Łukasz (2012)."7.1.4. Benchmark suite".Application of CLP to instruction modulo scheduling for VLIW processors. Gliwice, Poland: Jacek Skalmierski Computer Studio. pp. 80–83 [83].ISBN 978-83-62652-42-6.Archived from the original on 2020-03-02. Retrieved2016-05-28.
  7. ^Smotherman, Mark (2016) [2013]."Multiple Instruction Issue". School of Computing, Clemson University.Archived from the original on 2016-05-28. Retrieved2016-05-28.
  8. ^Jones, Douglas W. (2016) [2012]."A Minimal CISC".Computer Architecture On-Line Collection. Iowa City, USA:The University of Iowa, Department of Computer Science.Archived from the original on 2020-03-02. Retrieved2016-05-28.
  9. ^Schulman, Andrew (2005-07-01)."Finding Binary Clones with Opstrings & Function Digests".Dr. Dobb's Journal. Part I. Vol. 30, no. 7.CMP Media LLC. pp. 69–73.ISSN 1044-789X. #374.Archived from the original on 2020-03-02. Retrieved2020-03-02;Schulman, Andrew (2005-08-01)."Finding Binary Clones with Opstrings & Function Digests".Dr. Dobb's Journal. Part II. Vol. 30, no. 8.CMP Media LLC. pp. 56–61.ISSN 1044-789X. #375.Archived from the original on 2020-03-02. Retrieved2016-05-28;Schulman, Andrew (2005-09-01)."Finding Binary Clones with Opstrings & Function Digests".CMP Media LLC. Part III. Vol. 30, no. 9.United Business Media. pp. 64–70.ISSN 1044-789X. #376.Archived from the original on 2020-03-02. Retrieved2016-05-28.
  10. ^abcdHennessy, John L.; Patterson, David A.;Asanović, Krste; Bakos, Jason D.; Colwell, Robert P.; Bhattacharjee, Abhishek; Conte, Thomas M.; Duato, José; Franklin, Diana; Goldberg, David; Jouppi, Norman P.; Li, Sheng; Muralimanohar, Naveen; Peterson, Gregory D.; Pinkston, Timothy M.; Ranganathan, Parthasarathy; Wood, David A.; Young, Cliff; Zaky, Amr (2017-11-23).Computer architecture: A quantitative approach (6 ed.). Cambridge, Massachusetts, USA:Morgan Kaufmann Publishers.ISBN 978-0-12811905-1.OCLC 983459758.
  11. ^Mansfield, Richard (1983)."Introduction: Why Machine Language?".Machine Language For Beginners.Compute! Books (1 ed.). Greensboro, North Carolina, USA:COMPUTE! Publications, Inc.,American Broadcasting Companies, Inc.;Small System Services, Inc.ISBN 0-942386-11-6.Archived from the original on 2008-02-13. Retrieved2016-05-28.
  12. ^"bytecode Definition".PC Magazine. PC Magazine Encyclopedia. Archived fromthe original on 2012-10-06. Retrieved2015-10-10.


x86 assembly topics
Topics
Assemblers
Programming
issues
Retrieved from "https://en.wikipedia.org/w/index.php?title=Opcode&oldid=1281164740"
Category:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp