Programs Using 8051

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

Write a program to transfer 09 bytes of data from external

RAM address location 9000H to internal RAM address


location 50H.
MOV DPTR, #9000H
MOV R0, #50H
MOV R2, #09H
MOVX A, @DPTR
MOV @R0, A
INC DPTR
INC R0
DJNZ R2, L1
HERE: SJMP HERE
Write a program to add list of 10 no.s stored from the
internal RAM address location 60H. Store the result in the
memory location 80H.
MOV R0, #60H
MOV R1, #80H
MOV R2, #0AH
MOVX A, #00H
MOV R3,#00H
L2: ADD A, @R0
JNC L1
INC R3
L1: INC R0
DJNZ R2, L2
MOV @R1, A
INC R1
MOV A, @R3
MOV @R1, A
HERE: SJMP HERE
Write a program to exchange 10 bytes from 50H to 60H.

MOV R0, #50H


MOV R1, #60H
MOV R2, #0AH
L1: MOV A, @R0
XCH A, @R0
MOV @R0, A
INC R0
INC R1
DJNZ R2, L1
HERE: SJMP HERE
Write a program to move 10 bytes of data from internal
ROM 0500H to Internal RAM 50H.

MOV DPTR, #0500H


MOV R0, # 50H
MOV R2, #0AH
L1: MOVX A, @DPTR
MOV @R0, A
INC DPTR
INC R0
DJNZ R2, L1
HERE: SJMP HERE
Develop an Assembly Language Program to find whether
a given byte is available in the given sequence or not. If
it is available, write FF in R3, otherwise write 00 in R3.
MOV R0, #20H
MOV R3, #00H
MOV R1, #05H
BACK MOV A, @R0
CJNE A, #45H, AHEAD
MOV R3, #0FFH
AHEAD INC R0
DJNZ R1, BACK
HERE SJMP HERE
Develop an assembly language program
to find average of two eight bit numbers

MOV F0 (B), #02H


MOV A,R0
ADD A,R1
DIV AB
MOV R2, A
HERE: SJMP HERE
Develop an assembly language program to count the number of 1s
and 0s in given byte of data.

MOV A, #25H
MOV R0, #80H
MOV R1, #00H
MOV R2, #00H
MOV R3, #08H
CLR C
UP: RRC A
JNC DOWN
INC R1
SJMP NEXT
DOWN: INC R2
NEXT: DJNZ R3, UP
MOV A, R1
MOV @R0, A
INC R0
MOV A, R2
MOV @R0, A
HERE: SJMP HERE
Develop a program by using 8051 instructions to
multiply two 8-bit numbers present at memory locations
9000H and 9001H and store the result at the memory
locations 9050H and 9051H.
MOV DPTR, #9000
MOVX A, @DPTR
MOV 0F0, A
MOV DPTR, #9001
MOVX A, @DPTR
MUL AB
MOV DPTR, #9050
MOVX @DPTR, A
INC DPTR
MOV A, 0F0H
MOVX @DPTR, A
HERE: SJMP HERE
Develop a program by using 8051 instructions to divide an 8-
bit number present at memory location 8000H with number
present at address 8001H and store the quotient at the
memory location 8020 and remainder at memory address
8021H.

MOV DPTR, #8000H


MOVX A, @DPTR
MOV R0, A
INC DPTR
MOVX A, @DPTR
MOV 0F0, A
MOV A, R0
DIV AB
MOV DPTR, #8020H
MOVX @DPTR, A
INC DPTR
MOV A, 0F0H
MOVX @DPTR, A
HERE: SJMP HERE
Develop an assembly language program to find Odd & Even
numbers from the given series of numbers.
MOV R0, #80H
MOV R1, #00H
MOV R2, #00H
MOV R3, #10H
UP: MOV A, @R0
CLR C
RRC A
JNC DOWN
INC R1
SJMP NEXT
DOWN: INC R2
NEXT: INC R0
DJNZ R3, UP
MOV A, R1
MOV @R0, A
INC R0
MOV A, R2
MOV @R0, A
HERE: SJMP HERE
Develop an assembly language program to find Positive & Negative numbers from the
given series of numbers.
MOV R0, #90H
MOV R1, #00H
MOV R2, #00H
MOV R3, #10H
UP: MOV A, @R0
CLR C
RLC A
JNC DOWN
INC R1
SJMP NEXT
DOWN: INC R2
NEXT: INC R0
DJNZ R3, UP
MOV A, R1
MOV @R0, A
INC R0
MOV A, R2
MOV @R0, A
HERE: SJMP HERE

You might also like