大象传媒

Programming languages and Integrated Development Environments - OCROpcodes and operands

Translators are needed to translate programs written in high level languages into the machine code that a computer understands. Tools exist to help programmers develop error-free code.

Part of Computer ScienceComputational thinking, algorithms and programming

Opcodes and operands

Many and assembly contain two parts:

  • the - this is the actual instruction
  • the - this is a value that the instruction uses or manipulates

Both values are represented either in or . Hexadecimal is popular with programmers because it can represent larger values in fewer characters. For example, denary 250 is 11111010 in binary but only FA in hexadecimal. Hexadecimal is therefore easier to read and understand by humans.

Consider this simple machine code :

901 - inputs a value

306 - stores it in memory address 06

5A1 - loads into the accumulator the value held in memory address A1

Each of these instructions has an opcode and an operand:

Machine code instructionOpcodeOperand
901901
306306
5A15A1
Machine code instruction901
Opcode9
Operand01
Machine code instruction306
Opcode3
Operand06
Machine code instruction5A1
Opcode5
OperandA1