0% found this document useful (0 votes)
10 views3 pages

MAA Assingment 4

The document outlines various instructions related to addressing modes, data transfer, arithmetic, logical, and boolean processor instructions for the 8051 microcontroller. It includes examples of specific instructions, explanations of their functions, and several programming tasks to demonstrate data manipulation in memory. Additionally, it lists different addressing modes used in the 8051 architecture.
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)
10 views3 pages

MAA Assingment 4

The document outlines various instructions related to addressing modes, data transfer, arithmetic, logical, and boolean processor instructions for the 8051 microcontroller. It includes examples of specific instructions, explanations of their functions, and several programming tasks to demonstrate data manipulation in memory. Additionally, it lists different addressing modes used in the 8051 architecture.
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/ 3

Assignment 4

1. List out any two instructions of following addressing modes:


(i) Immediate addressing. (ii) Register addressing.
Ans: (i) Immediate addressing instructions:
1. MOV A, #36H
2. MOV DPTR, #27A2H
(ii) Register addressing.
1. MOV A, R0
2. MOV R7, A
2. Write any eight data transfer Instructions.
3. Write any eight Arithmetic Instructions.
4. Write any eight Logical Instructions.
5. Write any eight Boolean processor Instructions.
6. Explain the following instructions.
SWAP A , ADD C , MUL AB, CJNE A, add, radd,
MOV A, R0 , MOVC A, @ A + DPTR.
Ans :
1. SWAP A
Description: This instruction exchanges bits 0-3 of the Accumulator with bits 4-7 of the
Accumulator. This instruction is identical to executing "RR A" or "RL A four times
Example: MOV A, #59H ; A= 59H
SWAP A ; A= 95H
2. ADD C
Description: This instruction is used to perform addition of two eight-bit numbers along with
carry. The result is stored in accumulator which is the default destination.
Example: ADDC A, R0 : Add contents of accumulator, R0 and carry .
The result is stored in accumulator.

3. MUL AB
Description: the multiplicand and the multiplier must be in A and B registers. After multiplication
if the result is 8 bit it will be in the accumulator and if the result is larger than 8 bit ,lower byte of
result will be in accumulator and higher byte will be in register B.
Example : MOV A,#10H
MOV B,#02 H
MUL AB
After execution A=20H,B=0 H

4. CJNE A, add, radd


Description: Compare the contents of the accumulator with the 8 bit data in memory address
mentioned in the instruction and if they are not equal then jump to the relative address
mentioned in the instruction.
Example: CJNE A, 04H, UP : Compare the contents of the accumulator with the contents
of 04H memory and if they are not equal then jump to the line of instruction where UP label is
mentioned

5. MOV A,R0
Description: this instruction copies the contents of source register R0 into accumulator. The
register R0 remains unaffected.
Example: Before Execution A=43 H, R0=32 H
After execution A=32 H, R0-32H

6. MOVC A, @ A + DPTR
Description: Copy the contents of code memory pointed by the sum of Accumulator and
DPTR to the Accumulator
MOVC is a move instruction, which moves data from the code memory space. The address
operand in this example is formed by adding the content of the DPTR register to the
accumulator value.
Here the DPTR value is referred to as the base address and the accumulator value is referred to
as the index address.

7. Write a program to move data from accumulator to memory location 30h.

ORG 0000H
MOV 30H,A
END

8. Write a program to move data from accumulator to memory location 30h using immediate and
indirect addressing mode.

ORG 0000H
MOV R1, #30H
MOV @R1 ,A
END

9. Write a program to transfer a block of data from internal memory location 20H to internal memory
location 40H.

ORG 0000H
MOV R0, #20H ; Initialize source pointer R0 to 20H
MOV R1, #40H ; Initialize destination pointer R1 to 40H

MOV A, @R0 ; Move the contents of first source location to Accumulator

MOV @R1,A ; Move the contents of Accumulator to first destination location


END

10. Write ALP to find smallest number from the given five bytes stored in internal memory locations
40H onwards and store the result in location 50H.
ORG 0000H
MOV R0,#40H Initialize source pointer R0 to 40H
MOV R1, #05H Initialize byte counter
MOV A, #0FFH

up: MOV B,@R0 read first byte to B register

CJNE A,B, down compare first byte to max value

down: JC next check carry

MOV A,B ; move small value to A

next : INC R0 Increment the contents of R0

DJNZ R1,up Decrement counter by one Is it zero? No ,jump to UP


MOV 50H, A store smallest number to 50H
SJMP $ Halt after the smallest value is zero? No ,jump to UP available
END

11. Develop a program to transfer a byte from memory location 50 H to 60 H.

12. Write a program to multiply two 8 bit numbers which are stored at internal memory location 30H
and 31H.

13. List different addressing modes in 8051.

You might also like