Level 0 · Module 1
Machine instructions
Learn how processors carry out small encoded commands.
Not completed
By the end, you can
- Describe a machine instruction as an encoded command.
- Identify an opcode and operands in a simple instruction.
- Explain why assembly language is not the same as machine code.
Summary
Machine instructions are patterns of bits that a particular processor can understand. An instruction usually says what action to take and which data or location to use. Assembly language gives people readable names for those actions; it is not the bits themselves.
Introduction
Code such as JavaScript is designed to be convenient for people to write. A CPU cannot directly run that source code. Before the CPU executes the work, compiler or runtime tools translate it into instructions for that processor design.
Explanation
An opcode is the part that selects an action, such as add or load. Operands are the pieces the action uses: values, registers, or memory locations. The exact bit pattern depends on the processor’s instruction set—the list of operations that processor understands. A pattern that works on one kind of CPU may mean nothing on another.
Real-world example
A compiled checkout program may load numbers into CPU registers, add them, and store the result. Each small step is an instruction, even though the source code expresses the idea in one line.
Separate the action from the data
Interactive exploration
Machine instruction
Step 1 of 4
Registers are tiny, very fast storage locations inside a CPU. An instruction can name registers, a location in memory, or a number written directly in the instruction. The processor can perform only the operations in its instruction set.
Code example
LOAD R1, [price]
ADD R1, R1, R2
STORE [total], R1ADD is the opcode; R1 and R2 are operands in this simplified example.
Common mistakes
- Assuming all computers share one universal machine language.
- Calling assembly text the actual bits stored in memory.
- Expecting one instruction to implement a complete feature such as “send email”.
Quiz
Knowledge check
Try it
Name the pieces
In STORE [total], R1, identify the operation and the operands. Describe the result in plain
language.
Key takeaways
- CPUs execute encoded, architecture-specific instructions.
- Instructions combine an operation with operands.
- Assembly is readable notation for low-level operations, not a replacement for the encoded bytes.