19
µ
PD17062
2.2 FUNCTIONS OF PROGRAM MEMORY
Program memory has two basic functions:
(1) Program storage
(2) Constant data storage
A program is a set of instructions that control the CPU (Central Processing Unit: Device that actually
controls the microcontroller). The CPU executes processing sequentially according to the instructions coded
in the program. The CPU sequentially reads instructions from the program stored in program memory and
executes processing according to each instruction.
Each instruction is one word, or 16 bits in length. A single instruction can thus be stored at a single address
in program memory.
Constant data is predetermined data such as a display pattern. Constant data is read from program memory
into a data buffer (DBF) in data memory (RAM) upon execution of the specialized MOVT instruction. This
reading of constant data from memory is called table referencing.
Program memory is read-only storage that cannot be rewritten by the execution of an instruction. In this
document, program memory and ROM (read-only memory) are synonymous.
2.3 PROGRAM FLOW
A program stored in program memory is usually executed one address at a time starting from address
0000H. If another program is to be executed upon some condition being satisfied, the program flow must
be branched. To achieve this, the branch instruction (BR) is used.
If a single program is executed a number of times, the efficiency of the program memory is reduced. This
problem can be solved by storing that program at a given location and calling it using the specialized CALL
instruction. Such a program is called a subroutine while the usual program is called a main routine.
If a program is executed upon some condition being satisfied, independently of the current program flow,
the interrupt function is used. If a predetermined condition is satisfied, the interrupt function transfers control
to a specified address (vector address) irrespective of the current program flow.
These program flows are controlled by the program counter (PC), which specifies program memory
addresses.