Professional Documents
Culture Documents
IMMEDIATE
MOV A,#45H
MOV B,#86H
ADD A,B
MOV 30H,A
END
DIRECT
MOV 20H,#45H
MOV 21H,#80H
MOV A,20H
MOV B,21H
ADD A,B
MOV 30H,A
END
INDIRECT
MOV 20H,#45H
MOV 21H,#86H
MOV A,20H
MOV R0,#21H
ADD A,@R0
MOV 30H,A
END
2.Program for 8-bit Subtraction in Immediate, Direct and Register Indirect addressing mode.
IMMEDIATE
MOV A,#45H
MOV B,#86H
SUB A,B
MOV 30H,A
END
DIRECT
MOV 20H,#45H
MOV 21H,#80H
MOV A,20H
MOV B,21H
SUB A,B
MOV 30H,A
END
INDIRECT
MOV 20H,#45H
MOV 21H,#86H
MOV A,20H
MOV R0,#21H
SUB A,@R0
MOV 30H,A
END
3.Program for 8-bit Multiplication in Immediate, Direct and Register Indirect addressing mode.
IMMEDIATE
MOV A,#45H
MOV B,#86H
MUL AB
MOV 30H,A
END
DIRECT
MOV 20H,#45H
MOV 21H,#80H
MOV A,20H
MOV B,21H
MUL AB
MOV 30H,A
END
INDIRECT
MOV 20H,#45H
MOV 21H,#86H
MOV A,20H
MOV R0,#21H
MUL A@R0
MOV 30H,A
END
4.Program for 8-bit Division in Immediate, Direct and Register Indirect addressing mode.
IMMEDIATE
MOV A,#45H
MOV B,#86H
DIV AB
MOV 30H,A
END
DIRECT
MOV 20H,#45H
MOV 21H,#80H
MOV A,20H
MOV B,21H
DIV AB
MOV 30H,A
END
INDIRECT
MOV 20H,#45H
MOV 21H,#86H
MOV A,20H
MOV R0,#21H
DIV A@R0
MOV 30H,A
END
MOV A,#47H
MOV B,#25H
ADD A,B
DA A
MOV 30H,A
END
ADD
MOV A,#86H
MOV B,#96H
ADD A,B
MOV R0,A
MOV A,#4AH
MOV B,#38H
ADDC A,B
MOV R1,A
END
7.Program to convert ASCII to packed BCD
MOV A,#'8'
MOV B,#'6'
ANL A,#0FH
ANL B,#0FH
SWAP A
ORL A,B
MOV 30H,A
END
MOV DPTR,#8000H
MOV A,#45
MOVX @DPTR,A
MOV 30H,A
END
ORG 0000H
MOV R0,#50H
MOV R1,#10H
MOV B, #00H
CJNE A,B,LOOP
LOOP: JC LOOP1
MOV B,A
INC R0
DJNZ R1,BACK
LOOP1: INC R0
DJNZ R1,BACK
END
10.Program to transfer 10 bytes memory block from a location 12H to memory location starting
from address 32H.
MOV R7,#0AH
MOV R0,#12H
MOV R1,#32H
BACK:MOV A,@R0
MOV @R1,A
INC R0
INC R1
DJNZ R7,BACK
END
ORG 0000H
MOV R7,#4
LOOP1:MOV R0,#40H
MOV R6,#04H
INC R0
MOV 50H,@R0
CJNE A,50H,NEXT
SJMP DOWN
NEXT: JC DOWN
MOV @R0,A
DEC R0
MOV @R0,50H
DJNZ R7,LOOP1
END
12.Program to count number of zero’s and one’s in 8-bit number
MOV R1,#00H
MOV R2,#00H
MOV R7,#08H
MOV A,#97H
AGAIN: RLC A
JC NEXT
SJMP HERE
NEXT: INC R2
END
13.Program to find whether given 8-bit number is odd or even; if odd, store 00H in accumulator and
if even, store FFH in accumulator
MOV A,#67H
RRC A
JC ODD
SJMP EVEN
END
14.Program to do logical AND, OR and XOR on two 8-bit numbers stored in internal RAM locations
21H, 22H and store result at 31H, 31H and 32H
mov a,#0feh
mov b,#0ah
div ab
mov r0,b
mov b,#0ah
div ab
mov 30h,a
mov a,b
swap a
orl a,r0
mov 31h,a
end
mov a,#95h
mov b,#10h
div ab
mov r1,b
mov b,#0ah
mul ab
add a,r1
mov 30h,a
end
17.Timer Program
MAIN:MOV P0,#0FFH
ACALL DELAY
MOV P0,#00H
ACALL DELAY
SJMP MAIN
DELAY:MOV TMOD,#01H
MOV TH0,#0DCH
MOV TL0,#00H
SETB TR0
L:JNB TF0,L
CLR TR0
CLR TF0
RET
END
MOV TMOD,#60H
MOV TH1,#00H
SETB P3.5
AGAIN:SETB TR1
BACK:MOV A,TL1
MOV P2,A
JNB TF1,BACK
CLR TR1
CLR TF1
SJMP AGAIN
END
mov tmod,#06h
mov tl0,#00h
back:setb tr0
mov p0,tl0
cjne a,#10,back
clr tr0
end