0% found this document useful (0 votes)
8 views10 pages

11-Programming 8051 Using Assembly-22!01!2025

The document outlines the instruction set of the 8051 microcontroller, focusing on data transfer, arithmetic, logical, boolean, and control transfer instructions. It includes programming examples in assembly language, such as determining if a number is positive or negative, copying values to RAM, and calculating time delays in subroutines. Additionally, it discusses the manipulation of bits and the generation of HEX files for program execution.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views10 pages

11-Programming 8051 Using Assembly-22!01!2025

The document outlines the instruction set of the 8051 microcontroller, focusing on data transfer, arithmetic, logical, boolean, and control transfer instructions. It includes programming examples in assembly language, such as determining if a number is positive or negative, copying values to RAM, and calculating time delays in subroutines. Additionally, it discusses the manipulation of bits and the generation of HEX files for program execution.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

BEEE309L -Microprocessors and Microcontrollers

Module:2 Instruction Set of 8051

1. Data transfer instructions

2. Arithmetic and Logical instructions

3. Boolean instructions & Control transfer instruction

4. Programming 8051 using Assembly and Embedded C

5. Demonstration of HEX file generation and program execution


8051 Microcontroller – Basic programming

Write an assembly language program to find the given number is positive or negative

Steps Involved: Analyze the logic, Identify the suitable instructions and Formulate the algorithm

Step 1: Analyze the logic

* Finding the keyword/keywords

Keywords: Positive and negative numbers

Positive and negative numbers


 They are signed numbers
 Signed numbers fall under signed integer data type
 The size of signed integer is 8-bit for the 8051 microcontroller
8-bit Signed Integer

Decimal value Hexadecimal Value Binary Value


-128 80 H 1000 0000
-127 81 H 1000 0001
-126 82 H 1000 0010
.
.
-2 FE H 1111 1110
-1 FF H 1111 1111
0 00 H 0000 0000
+1 01 H 0000 0001
+2 02 H 0000 0010
.
.
.
+126 7E 0111 1110
+127 7F 0111 1111
Step 2: Identifying the suitable instructions
RLC A and JC/JNC
A - Accumulator (8-bit Register)
C - Carry Bit (single bit)

Example
Given number: A = 84 H; C = 0
C - bit A Register

0 1 0 0 0 0 1 0 0
D7 D6 D5 D4 D3 D2 D1 D0

C - bit A Register

RLC A 0 1 0 0 0 0 1 0 0

After executing C - bit A Register


the instruction
‘RLC A’ 1 0 0 0 0 1 0 0 0
Step 3: Algorithm Formulation Program

(i) Assign the given value to the A register


(Accumulator)
(ii) Clear the Carry bit.
(iii) Use the instruction RLC A to shift MSB
of A register to Carry bit
(iv) Check the carry bit using the
instruction JC. If there is no carry it
indicates the number is positive
otherwise
negative number
Write a program to copy the value 55H into RAM memory locations 40H to 42H using
(a) direct addressing mode, (b) register indirect addressing mode
For a machine cycle of 1.085 s, find the time delay in the following subroutine

MOV R3, #255


HERE:DJNZ R3, HERE
RET
For a machine cycle of 1.085 s, find the time delay in the following subroutine

MOV R1, #200


AGAIN: MOV R3, #250
HERE: NOP
NOP
DJNZ R3, HERE
DJNZ R1, AGAIN
RET
Write a program to complement the bit of P1.3 for every 50ms

You might also like