kids encyclopedia robot

Instruction (computer science) facts for kids

Kids Encyclopedia Facts

A computer instruction is like a tiny command that tells the computer's brain, called the processor, exactly what to do. Think of it as a single step in a recipe that the computer follows. These commands are part of a special list called an instruction set, which is unique to each type of processor.

What is a Computer Instruction?

Every computer program, from a simple game to a complex app, is made up of many instructions. When you click a mouse or type on a keyboard, the computer uses instructions to understand what you want it to do. Each instruction tells the processor to perform one specific action, like adding two numbers, moving data, or checking if something is true.

Parts of an Instruction

Most instructions have two main parts:

  • Opcode: This is short for "operation code." It tells the processor what to do. For example, an opcode might mean "add," "subtract," or "load data."
  • Operands: These are the pieces of information the instruction needs to work with. Operands can be numbers, locations in the computer's memory, or special storage areas called registers.

For example, an instruction might say: "Add (opcode) the number from memory location A (operand) to the number in register B (operand)."

How Big Are Instructions?

The size of an instruction can be different depending on the computer.

  • Some very small computers, like those in microcontrollers (found in things like washing machines or toys), might use instructions as small as 4 bits. A bit is the smallest piece of information a computer understands.
  • Larger computers, like the ones you use every day (personal computers), or huge mainframes and supercomputers, usually have instructions that are between 16 and 64 bits long.
  • Some advanced systems use "VLIW" instructions, which can be much longer. These special instructions can tell the processor to do several things at the same time!

In many modern computer designs, especially those called "RISC" (Reduced Instruction Set Computer), all instructions have the same length. This makes it easier and faster for the processor to read and execute them.

How Are Instructions Made?

You might think programmers write instructions directly, but that's not usually the case.

  • Machine Code: Instructions are actually understood by the computer as a series of numbers, called machine code. This is very hard for humans to read or write.
  • Assembly Language: Some expert programmers use an "assembly language" to write instructions. This language uses short words that are easier for humans to understand than pure machine code, but it's still very detailed.
  • Compilers: Most of the time, programmers write code in higher-level languages like Python, Java, or C++. Then, a special program called a compiler translates this human-friendly code into the machine code instructions that the processor can understand and execute.

Related pages

kids search engine
Instruction (computer science) Facts for Kids. Kiddle Encyclopedia.