Professional Documents
Culture Documents
Lecture2 2 07102020 021152pm
Lecture2 2 07102020 021152pm
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