Opcode: Difference between revisions

Content deleted Content added
No edit summary
cleaned up this page - wow, it really needed that
Line 1:
{{cleanup}}
 
Opcode stands for '''Op'''eration '''Code'''. Opcodes operate on [[processor register|registers]], values in [[memory]], values stored on the [[Stack (computing)|stack]], [[I/O]] ports, the [[Computer bus|bus]], etc. They are used to perform arithmetic operations and move and change values. [[Operands]] are the things that opcodes operate on. [[Microprocessors]] perform operations using binary [[bit|bits]]. A [[bit]] is either on (1) or off (0). Eight [[bit|bits]] is equal to a [[byte]] (on most modern processors), and two bytes is equal to a word.
Microprocessors perform operations using binary bits (on/off/1or0).
Eight bits is equal to a byte (on most modern processors), and two bytes is equal to a word.
 
Another term for opcodes is [[Byte code]]s. areByte anothercode termis for opcodes,used especially when they are used to describe higher level constructs as is the case with the [[Java programming language|Java Language]]'s JVM ([[Java Virtual Machine]]). For instance, byte code 1A might be the "iconst_2" instruction which pushes the number 2 on the stack. This is a slightly higher level of abstraction than opcodes, which might need to load the number 2 into a register, and then push the register's value on the stack.
As an example let's design a crude 4-bit microprocessor.
 
As an example let's design a crude 4-bit [[microprocessor]].
*First: All registers, ALUs, counters, and addresses must have a data path of 4-bits.
 
Also,*Second: allAll of our instructions must fit in a 3-bit address.
Below is a diagram of the opcodes of the micorprocessor:
 
These are the
op-codes mnemonic operations explanation
000 ADD add A to B and store in b
Line 21 ⟶ 19:
111 end end program
 
whenWhen the op-code values are active at the decoders logic inputs,
the desired operations are performed. <!-- This is a better explanation then whats below..cleanUpLater.. -->
, eachEach of whichthese operations is assigned a numeric code, calledthis is anthe '''opcode'''. To assist in the use of these numeric codes, [[mnemonic]]s are used as textual abbreviations. It's much easier to remember ADD than 05, for example.
 
This is a better explanation then whats below..cleanUpLater..
 
 
 
, each of which is assigned a numeric code called an '''opcode'''. To assist in the use of these numeric codes, [[mnemonic]]s are used as textual abbreviations. It's much easier to remember ADD than 05, for example.
 
Opcodes operate on [[processor register|registers]], values in [[memory]], values stored on the [[Stack (computing)|stack]], [[I/O]] ports, the [[Computer bus|bus]], etc. They are used to perform arithmetic operations and move and change values. Operands are the things that opcodes operate on.
 
[[Byte code]]s are another term for opcodes, especially when they are used to describe higher level constructs as is the case with the [[Java programming language|Java Language]]'s JVM ([[Java Virtual Machine]]). For instance, byte code 1A might be the "iconst_2" instruction which pushes the number 2 on the stack. This is a slightly higher level of abstraction than opcodes, which might need to load the number 2 into a register, and then push the register's value on the stack.
 
==See also==
* [[Machine language]]