You are on page 1of 8

PIC18f452

INTRODUCTION
 To program in assembly language, we
must understand the registers and
architecture of a given CPU.
 CPU includes
 Arithmetic Logic unit (ALU)
 Registers
 Control Unit
 Performs logical and arithmetic
functions
 It has following resisters
 WREG – stands for working register (acts
as an accumulator) – 8 bit register used to
perform arithmetic or logical functions
 Status register that stores flags – indicates
the status of the operation done by ALU
 Instruction decoder (ID)– when the
instruction is fetched, it goes into the ID to
be interpreted – tell the processor what to
do
To understand use of WREG register, two instructions are used
 MOVLW instruction
MOVLW K ; move literal value K into WREG
 K is an 8-bit value
 L stands for literal which means, literally, a number must be used
 Example
 MOVLW 25H
 MOVLW 87H
 ADDLW instruction
ADDLW K ; add literal value K to WREG
 It add literal value k to register WREG and put the result back in the WREG
register
MOVLW 25H
ADDLW 34H
 Executing the above lines results in WREG=59H (25H+34H=59H)
 Registers – hold memory address

 Bank Select Register (BSR)


 4-bit register used in direct addressing the data memory

 File Select Registers (FSRs)


 16-bit registers used as memory pointers in indirect
addressing data memory

 Program Counter (PC)


 21-bit register that holds the program memory address
while executing programs
 Provides timing and control signals to
various Read and Write operations

You might also like