Any micro controller (or a micro processor of a computer) executes a set of instructions. Depending upon the architecture, this set changes. However some basic characteristics are common. First about the instruction set…..
The instruction set
Micro controller “understands” logic. Micro controller understands arithmetic. It has the sense of time, so it can “memorise” numbers.
An instruction set is a list of “tasks” that a controller can do.
- It can add, subtract, divide, multiply: A micro controller has in-built hardware circuit that can perform these arithmetic operations. This hardware is part of the section ALU. (Arithmetic Logic Unit). Consider this section as machine-shop in a factory. Each circuit is like a machine. An adder, subtractor, divider and multiplier circuits are situated on the shop floor. Each machine has its own address. What ever job (data) is sent to the specific machine is operated accordingly. Instructions make the data available to the “machine”, operate the “machine” and send the outcome to the destination.
- Jump from one memory location to another: Programme means an ordered list of instructions. Some time (may depend on conditions) the programme flow must change its route. This is done by the JUMP instructions.
- It can repeat a bunch of ordered instructions: An ordered list of instructions is useful to serve some particular purpose (say divide any number by 32). This bunch can be used to divide a number by 32 again and again. The bunch is called as the routine or subroutine. “CALL” instructions are useful to work this out.
- A controller can handle a single bit or a complete byte or word: This is the advantage of a micro controller over micro-processor. A micro controller has in-built instructions which can handle single bits (making devices ON or OFF individually). Micro controllers can also handle bytes and (some times) words i.e. 16bit data.
- It can “understand” logic, like “if-else-then” indirectly: Conditional jumps are used to implement this logic.
- It can go into loop till some condition is true or not true: In high level language (C, basic, arduino) while-loop, for-loop are common. These loops use specific instructions from the instruction set.
For any type of micro controller these are the fundamental instruction types. Additionally, use of look up tables, handling the temporary data memory and special function registers is possible with specific instructions.
You will wonder, but how are these instructions executed by the controller ? I will explain it in the another blog.