Module-4
PIC Programming
Addressing modes: Immediate and Direct Addressing modes, Register
Indirect Addressing mode, Lookup table and table processing, Bit
Addressability of Data RAM, Macros and Modules, types and Time
delays, I/O Programming and Logical Operations, Data Serialization
,The CPU can access data in various ways. The data could be in a register,
or in memory, or provided as an immediate value. These various ways
of accessing data are called addressing modes.
1. Immediate
2. Direct
3. Register indirect
IMMEDIATE AND DIRECT ADDRESSING MODES
Immediate addressing mode
In this addressing mode, the operand is a literal constant. In
immediate addressing mode, as the name implies, the operand comes
immediately after the opcode when the instruction is assembled.
Notice that immediate data is called a literal in the PIC. This
addressing mode can be used to load information into WREG and
selected registers, but not to any file register. The immediate addressing
mode is also used for arithmetic and logic instructions. Examine the
following examples.
, Direct addressing mode
As mentioned in Chapter 2, the 256-byte access bank file register is
split into two sections: The lower addresses, 00 to 7FH, are assigned to
the general purpose registers, and the upper addresses, F80--FFFH, to
the SFR. The access bank is the default bank when the PIC 18 is
powered up. It is the minimum bank that all PIC18 processors have. The
MOVFF instruction also plays a role in choosing the access bank.
• The entire data RAM file register can be accessed using either
direct or register indirect addressing modes.
• In direct addressing mode, the operand data is in a RAM memory
location whose address is known, and this address is given as a part
of the instruction. Contrast this with immediate addressing mode
in which the operand data itself is provided with the instruction.
While the letter "L" in the instruction means literal (immediate),
the letter "F" in the instruction signifies the address of the file
register location
PIC Programming
Addressing modes: Immediate and Direct Addressing modes, Register
Indirect Addressing mode, Lookup table and table processing, Bit
Addressability of Data RAM, Macros and Modules, types and Time
delays, I/O Programming and Logical Operations, Data Serialization
,The CPU can access data in various ways. The data could be in a register,
or in memory, or provided as an immediate value. These various ways
of accessing data are called addressing modes.
1. Immediate
2. Direct
3. Register indirect
IMMEDIATE AND DIRECT ADDRESSING MODES
Immediate addressing mode
In this addressing mode, the operand is a literal constant. In
immediate addressing mode, as the name implies, the operand comes
immediately after the opcode when the instruction is assembled.
Notice that immediate data is called a literal in the PIC. This
addressing mode can be used to load information into WREG and
selected registers, but not to any file register. The immediate addressing
mode is also used for arithmetic and logic instructions. Examine the
following examples.
, Direct addressing mode
As mentioned in Chapter 2, the 256-byte access bank file register is
split into two sections: The lower addresses, 00 to 7FH, are assigned to
the general purpose registers, and the upper addresses, F80--FFFH, to
the SFR. The access bank is the default bank when the PIC 18 is
powered up. It is the minimum bank that all PIC18 processors have. The
MOVFF instruction also plays a role in choosing the access bank.
• The entire data RAM file register can be accessed using either
direct or register indirect addressing modes.
• In direct addressing mode, the operand data is in a RAM memory
location whose address is known, and this address is given as a part
of the instruction. Contrast this with immediate addressing mode
in which the operand data itself is provided with the instruction.
While the letter "L" in the instruction means literal (immediate),
the letter "F" in the instruction signifies the address of the file
register location