PROGRAM:
ADDITION OF TWO 8-BIT NUMBERS
LABEL
ADDRESS
MNEMONICS
OPCODE
C3
COMMENT
8000
CLR C
8001
MOV DPTR,#8500H
8004
MOVX A,@DPTR
E0
Get the first data to ACC
8005
MOV R0,A
F8
Move the content of ACC to R0
8006
INC DPTR
A3
Increment the data pointer
8007
MOVX A,@ DPTR
E0
Get the second data to ACC
8008
ADD A,R0
28
Add the contents of ACC and R0
8009
INC DPTR
A3
Increment the data pointer
800A
MOVX @DPTR,A
F0
Store the result in data pointer
800B
LCALL 00BB
90 85 00
12 00 BB
Clear the carry flag
Move the address to data pointer
Stop
Subtraction Of Two 8-Bit Numbers
LABEL
ADDRESS
MNEMONICS
OPCODE
C3
COMMENT
8000
CLR C
8001
MOV DPTR,#8500H
8004
MOVX A,@DPTR
E0
Get the first data to ACC
8005
MOV R0,A
F8
Move the content of ACC to R0
8006
INC DPTR
A3
Increment the data pointer
8007
MOVX A,@ DPTR
E0
Get the second data to ACC
8008
SUBB A,R0
98
Subtract the contents of ACC & R0
8009
INC DPTR
A3
Increment the data pointer
800A
MOVX @DPTR,A
F0
Store the result in data pointer
800B
LCALL 00BB
90 85 00
12 00 BB
Clear the carry flag
Move the address to data pointer
Stop
PROGRAM:
Addition Of Two 16-Bit Numbers
LABEL
ADDRESS
MNEMONICS
OPCODE
C3
COMMENT
8000
CLR C
8001
MOV DPTR,#8500H
8004
MOVX A,@DPTR
E0
Get the first MSB data to ACC
8005
MOV R0,A
F8
Move the content of ACC to R0
8006
INC DPTR
A3
Increment the data pointer
8007
MOVX A,@DPTR
E0
Get the first LSB data to ACC
8008
MOV R1,A
F9
Move the content of ACC to R1
8009
INC DPTR
A3
Increment the data pointer
800A
MOVX A,@DPTR
E0
Get the second MSB data to ACC
800B
MOV R2,A
FA
Move the content of ACC to R2
800C
INC DPTR
A3
Increment the data pointer
800D
MOVX A,@DPTR
E0
Get the second LSB data to ACC
800E
ADD A,R1
29
Add the contents of ACC & R1
800F
INC DPTR
A3
Increment the data pointer
8010
MOVX @DPTR,A
F0
Store the LSB result in data pointer
8011
MOV A,R0
E8
Move the content of R0 to ACC
8012
ADDC A,R2
3A
Add the contents of ACC & R2 with carry
8013
INC DPTR
A3
Increment the data pointer
8014
MOVX @DPTR,A
F0
Store the MSB result in data pointer
8015
LCALL 00BB
90 85 00
12 00 BB
Clear the carry flag
Move the address to data pointer
Stop
PROGRAM:
Multiplication Of Two 8-Bit Numbers
LABEL
ADDRESS
MNEMONICS
OPCODE
8000
CLR C
8001
MOV DPTR,#8500H
8004
MOVX A,@DPTR
8005
MOV B,A
F5 F0
8007
INC DPTR
A3
Increment the data pointer
8008
MOVX A,@DPTR
E0
Get the second data to ACC
8009
MUL AB
A4
Multiply the contents of ACC & B
800A
INC DPTR
A3
Increment the data pointer
800B
MOVX @DPTR,A
F0
Store the LSB result in data pointer
800C
MOV A,B
E5 F0
Move the content of B reg to ACC
800E
INC DPTR
A3
Increment the data pointer
800F
MOVX @DPTR,A
F0
Store the MSB result in data pointer
8010
LCALL 00BB
PROGRAM:
C3
COMMENTS
90 85 00
E0
12 00 BB
Clear the carry flag
Move the address to data pointer
Get the first data to ACC
Move the content of ACC to B reg
Stop
Ascending Order
LABEL
AGAIN
COUNT
COMP
CHNG
ADDRESS
MNEMONICS
OPCODE
8000
CLR C
8001
MOV DPTR,#8500H
8004
MOVX A,@DPTR
E0
Get the count in ACC
8005
MOV R0,A
F8
Initialize outer loop count in R0
8006
MOV R3,A
FB
Get the count in R3
8007
MOV DPTR,#8501H
800A
MOV A,R3
EB
Move the content of R3 to ACC
800B
MOV R1,A
F9
Initialize inner loop count in R1
800C
DJNZ R1,COMP
D9 05
Decrement R1.If not zero, jump to COMP
800E
DJNZ R0,AGAIN
D8 F7
Decrement R0.If not zero, jump to AGAIN
8010
LCALL 00BB
12 00 BB
8013
MOV R2,DPL
AA 82
8015
MOVX A,@DPTR
8016
MOV B,A
75 F0
8018
INC DPTR
A3
Increment the data pointer
8019
MOVX A,@DPTR
E0
Get the next data in ACC
801A
CJNE A,B,CHNG
B5 F0 02
801D
SJMP COUNT
80 ED
Short-jump to the label COUNT
801F
JNC COUNT
50 EB
If carry flag is not set, jump to label COUNT
8021
MOV DPL,R2
8A 82
Load the lower byte DPTR address from R2
8023
MOVX @DPTR,A
F0
Move the ACC data to DPTR
8024
INC DPTR
A3
Increment the data pointer
8025
MOV A,B
E5 F0
8027
MOVX @DPTR,A
8028
SJMP COUNT
PROGRAM:
C3
COMMENTS
90 85 00
90 85 01
E0
F0
80 E2
Clear the carry flag
Move the address 8500 to data pointer
Move the address 8501 to data pointer
Stop
LSB of DPTR is stored in R2
Get the first data in ACC
Move the ACC content to B reg
Compare ACC & B,if not equal, jump to CHNG
Move the content of B reg to ACC
Move the ACC data to DPTR
Short-jump to the label COUNT
Maximum Value In An Array
LABEL
CONT
LAST
CHNG
ADDRESS
MNEMONICS
OPCODE
C3
COMMENTS
8000
CLR C
8001
MOV DPTR,#8500H
8004
MOVX A,@DPTR
E0
Get the count in ACC
8005
MOV R5,A
FD
Move the ACC content to R5
8006
INC DPTR
A3
Increment the data pointer
8007
MOVX A,@DPTR
E0
Get the first data
8008
DEC R5
1D
Decrement the count
8009
MOV 40H,A
800B
INC DPTR
A3
Increment the data pointer
800C
MOVX A,@DPTR
E0
Get the next data
800D
CJNE A,40H,CHNG
8010
90 85 00
F5 40
Clear the carry flag
Move the address 8500 to data pointer
Move the ACC content to 40H address
B5 40 09
Compare A & 40H,if not equal,jump to CHNG
DJNZ R5,CONT
DD F9
Decrement R5.If not zero, jump to label CONT
8012
MOV A,40H
E5 40
Get the largest value
8014
INC DPTR
A3
Increment the data pointer
8015
MOVX @DPTR,A
F0
Store the largest value
8016
LCALL 00BB
8019
JC LAST
40 F5
If carry flag is set, then jump to label LAST
801B
MOV 40H,A
F5 40
Move the larger value in 40H address
801D
SJMP LAST
80 F1
Short-jump to label LAST
PROGRAM:
12 00 BB
Stop
ASCII to HEX Conversion
LABEL
ADDRESS
MNEMONICS
OPCODE
8000
CLR C
8001
MOV DPTR,#8500H
8004
MOVX A,@DPTR
8005
MOV R0,#30H
8007
SUBB A,R0
8008
CJNE A,#0AH,LOOP1
800B
SUBB A,#07H
94 07
Subtract ACC & the data 07H
800D
SJMP LOOP3
80 02
Short jump to the label LOOP3
LOOP1
800F
JNC LOOP2
50 FA
If carry flag is not set, then jump to LOOP2
LOOP3
8011
INC DPTR
A3
Increment the data pointer
8012
MOVX @DPTR,A
F0
Store the result in DPTR
8013
LCALL 00BB
LOOP2
PROGRAM:
C3
COMMENTS
90 85 00
Clear the carry flag
Move the address 8500 to data pointer
E0
Get the input data in ACC
78 30
Store the data 30H in R0
98
B4 0A 04
12 00 BB
Subtract the content of ACC & R0
Compare ACC & 0AH,if not equal,goto LOOP1
Stop
HEX to ASCII Conversion
LABEL
LOOP2
LOOP1
LOOP3
ADDRESS
MNEMONICS
OPCODE
8000
CLR C
8001
MOV DPTR,#8500H
8004
MOVX A,@DPTR
8005
CJNE A,#0AH,LOOP1
8008
ADD A,#37H
24 37
Add ACC & the data 37H
800A
SJMP LOOP3
80 04
Short jump to the label LOOP3
800C
JNC LOOP2
50 FA
If carry flag is not set, then jump to LOOP2
800E
ADD A,#30H
24 30
Add ACC & the data 37H
8010
INC DPTR
A3
Increment the data pointer
8011
MOVX @DPTR,A
F0
Store the result in DPTR
8012
LCALL 00BB
PROGRAM:
C3
COMMENTS
90 85 00
E0
B4 0A 04
12 00 BB
Clear the carry flag
Move the address 8500 to data pointer
Get the input data in ACC
Compare ACC & 0AH,if not equal,goto LOOP1
Stop
BCD to HEX Conversion
LABEL
ADDRESS
MNEMONICS
OPCODE
8000
CLR C
8001
MOV DPTR,#8500H
8004
MOVX A,@DPTR
8005
MOV B,#64H
8008
MUL AB
A4
Multiply the content of ACC & B-reg
8009
MOV R0,A
F8
Move the content of ACC to R0
800A
INC DPTR
A3
Increment the data pointer
800B
MOVX A,@DPTR
E0
Get the input LSB data in ACC
800C
ANL A,#0FH
800E
MOV R1,A
F9
Move the content of ACC to R1
800F
MOVX A,@DPTR
E0
Get the input LSB data in ACC
8010
ANL A,#F0H
8012
SWAP A
8013
MOV B,#0AH
8016
MUL AB
A4
Multiply the content of ACC & B-reg
8017
ADD A,R1
29
Add the content of ACC & R1
8018
ADDC A,R0
38
Add the content of ACC & R0 with carry
8019
INC DPTR
A3
Increment the data pointer
801A
MOVX @DPTR,A
F0
Store the result in DPTR
801B
LCALL 00BB
PROGRAM:
C3
COMMENTS
90 85 00
E0
75 F0 64
54 0F
54 F0
C4
75 F0 0A
12 00 BB
Clear the carry flag
Move the address 8500 to data pointer
Get the input MSB data in ACC
Store the data 64H in B-reg
AND logic ACC with the data 0FH
AND logic ACC with the data F0H
Exchange the LSB with MSB data of ACC
Store the data 0AH in B-reg
Stop
HEX to BCD Conversion
LABEL
CONV
LOOP1
ADDRESS
MNEMONICS
OPCODE
8000
MOV DPTR,#8500H
90 85 00
8003
MOVX A,@DPTR
E0
Get the input data in ACC
8004
MOV R0,A
F8
Move the content of ACC to R0
8005
MOV R1,#00H
79 00
Initialize R1 to 00H
8007
MOV R2,#00H
7A 00
Initialize R2 to 00H
8009
MOV A,#00H
74 00
Initialize ACC to 00H
800B
CLR C
C3
Clear the carry flag
800C
INC A
04
Increment the content of ACC
800D
DA A
D4
Decimal adjust the content of ACC
800E
MOV R1,A
F9
Move the content of ACC to R1
800F
JNC LOOP1
50 01
8011
INC R2
8012
DJNZ R0,CONV
8014
MOV A,R2
EA
Move the content of R2 to ACC
8015
INC DPTR
A3
Increment the data pointer
8016
MOVX @DPTR,A
F0
Store the MSB result in DPTR
8017
MOV A,R1
E9
Move the content of R1 to ACC
8018
INC DPTR
A3
Increment the data pointer
8019
MOVX @DPTR,A
F0
Store the LSB result in DPTR
801A
LCALL 00BB
PROGRAM:
0A
D8 F7
12 00 BB
COMMENTS
Move the address 8500 to data pointer
If carry flag is not set, jump to LOOP1
Increment the content of R2
Decrement R0, if not zero, jump to CONV
Stop
Square Root
LABEL
LOOP1
NEXT
ADDRESS
MNEMONICS
OPCODE
8000
MOV DPTR,#8500H
90 85 00
8003
MOVX A,@DPTR
E0
Get the input data in ACC
8004
MOV R0,A
F8
Move the content of ACC to R0
8005
MOV R1,#01H
79 01
Initialize R1 to 01H
8007
MOV R2,#00H
7A 00
Initialize R2 to 00H
8009
CLR C
C3
Clear the carry flag
800A
MOV A,R0
E8
Move the content of R0 to ACC
800B
SUBB A,R1
99
Subtract the content of ACC & R1
800C
MOV R0,A
F8
Move the content of ACC to R0
800D
INC R2
0A
Increment the content of R2
800E
JZ NEXT
8010
INC R1
09
Increment the content of R1
8011
INC R1
09
Increment the content of R1
8012
SJMP LOOP1
80 F6
Short jump to label LOOP1
8014
MOV A,R2
EA
Move the content of R2 to ACC
8015
INC DPTR
A3
Increment the data pointer
8016
MOVX @DPTR,A
F0
Store the result in DPTR
8017
LCALL 00BB
PROGRAM:
Least Common Multiplier (LCM)
60 04
12 00 BB
COMMENTS
Move the address 8500 to data pointer
If the content of ACC is zero, jump to NEXT
Stop
LABEL
COMP
NEXT
FIRST
LAST
ADDRESS
MNEMONICS
OPCODE
8000
MOV DPTR,#8500H
90 85 00
8003
MOVX A,@DPTR
E0
Get the first input data in ACC
8004
MOV R0,A
F8
Move the content of ACC to R0
8005
MOV 40H,A
F5 40
Move the content of ACC to 40H
8007
INC DPTR
A3
Increment the data pointer
8008
MOVX A,@DPTR
E0
Get the second input data in ACC
8009
MOV R1,A
F9
Move the content of ACC to R1
800A
CJNE A,40H,NEXT
800D
SJMP LAST
80 0F
Short jump to label LAST
800F
JNC FIRST
50 04
If carry flag is not set, jump to label FIRST
8011
CLR C
C3
Clear the carry flag
8012
ADD A,R1
29
Add the content of ACC & R1
8013
SJMP COMP
8015
MOV R2,A
FA
8016
MOV A,40H
E5 40
8018
ADD A,R0
8019
MOV 40H,A
F5 40
801B
MOV A,R2
EA
801C
SJMP COMP
801E
B5 40 02
80 F5
28
COMMENTS
Move the address 8500 to data pointer
Compare ACC & 40H, if not equal goto NEXT
Short jump to label COMP
Move the content of ACC to R2
Move the content of 40H address to ACC
Add the content of ACC & R0
Move the content of ACC to 40H address
Move the content of R2 to ACC
80 ED
Short jump to label COMP
INC DPTR
A3
Increment the data pointer
801F
MOVX @DPTR,A
F0
Store the result in DPTR
8020
LCALL 00BB
PROGRAM:
Greatest Common Divisor (GCD)
12 00 BB
Stop
LABEL
LOOP1
LOOP2
ADDRESS
MNEMONICS
OPCODE
90 85 00
COMMENTS
8000
MOV DPTR,#8500H
8003
MOVX A,@DPTR
E0
Get the first input data in ACC
8004
MOV R0,A
F8
Move the content of ACC to R0
8005
INC DPTR
A3
Increment the data pointer
8006
MOVX A,@DPTR
E0
Get the second input data in ACC
8007
MOV R1,A
F9
Move the content of ACC to R1
8008
MOV R2,#01H
7A 01
Initialize R2 to 01H
800A
MOV R3,#00H
7B 00
Initialize R3 to 00H
800C
CLR C
C3
Clear the carry flag
800D
MOV A,R2
EA
Move the content of R2 to ACC
800E
SUBB A,R0
98
Subtract the content of ACC & R0
800F
JZ LOOP3
60 1D
8011
MOV A,R2
EA
Move the content of R2 to ACC
8012
SUBB A,R1
99
Subtract the content of ACC & R1
8013
JZ LOOP4
60 29
8015
MOV A,R2
EA
8016
MOV B,A
F5 F0
8018
MOV A,R0
E8
Move the content of R0 to ACC
8019
DIV AB
84
Divide ACC with B-reg
801A
MOV A,B
801C
CJNE A,#00H,LOOP2
801F
MOV A,R2
EA
8020
MOV B,A
F5 F0
8022
MOV A,R1
E9
Move the content of R1 to ACC
8023
DIV AB
84
Divide ACC with B-reg
8024
MOV A,B
8026
CJNE A,#00H,LOOP2
8029
MOV A,R2
EA
Move the content of R2 to ACC
802A
MOV R3,A
FB
Move the content of ACC to R3
802B
INC R2
0A
Increment R2
802C
SJMP LOOP1
E5 F0
B4 00 0C
E5 F0
B4 00 02
80 DE
Move the address 8500 to data pointer
If ACC is zero, jump to label LOOP3
If ACC is zero, jump to label LOOP4
Move the content of R2 to ACC
Move the content of ACC to B-reg
Move the content of B-reg to ACC
Comp ACC with 00H,if not equal goto LOOP2
Move the content of R2 to ACC
Move the content of ACC to B-reg
Move the content of B-reg to ACC
Comp ACC with 00H,if not equal goto LOOP2
Short jump to label LOOP1
LOOP3
LAST
LOOP4
LOOP5
802E
MOV A,R2
EA
802F
MOV B,A
F5 F0
8031
MOV A,R1
E9
Move the content of R1 to ACC
8032
DIV AB
84
Divide ACC with B-reg
8033
MOV A,B
8035
CJNE A,#00H,LOOP5
8038
MOV A,R2
EA
Move the content of R2 to ACC
8039
INC DPTR
A3
Increment the data pointer
803A
MOVX @DPTR,A
F0
Move the content of ACC to DPTR
803B
LCALL 00BB
803E
MOV A,R2
EA
803F
MOV B,A
F5 F0
8041
MOV A,R0
E8
Move the content of R0 to ACC
8042
DIV AB
84
Divide ACC with B-reg
8043
MOV A,B
8045
CJNE A,#00H,LOOP5
8048
MOV A,R2
EA
8049
SJMP LAST
80 EE
804B
MOV A,R3
EB
804C
SJMP LAST
80 EB
PROGRAM:
Parity Bit Generation
E5 F0
B4 00 13
12 00 BB
E5 F0
B4 00 03
Move the content of R2 to ACC
Move the content of ACC to B-reg
Move the content of B-reg to ACC
Comp ACC with 00H,if not equal goto LOOP5
Stop
Move the content of R2 to ACC
Move the content of ACC to B-reg
Move the content of B-reg to ACC
Comp ACC with 00H,if not equal goto LOOP5
Move the content of R2 to ACC
Short jump to label LAST
Move the content of R3 to ACC
Short jump to label LAST
LABEL
ADDRESS
MNEMONICS
OPCODE
8000
CLR C
8001
MOV DPTR,#8500H
8004
MOVX A,@DPTR
E0
Get the first data to ACC
8005
MOV R0,A
F8
Move the content of ACC to R0
8006
INC DPTR
A3
Increment the data pointer
8007
MOVX A,@ DPTR
E0
Get the second data to ACC
8008
ADD A,R0
28
Add the contents of ACC and R0
8009
MOV A,0D0H
E5 D0
Move the content of PSW reg to ACC
800B
ANL A,#01H
54 01
AND logic ACC & the data 01H
800D
INC DPTR
A3
Increment the data pointer
800E
MOVX @DPTR,A
F0
Store the result in data pointer
800F
LCALL 00BB
PROGRAM:
Program Using Interrupt
C3
COMMENTS
90 85 00
12 00 BB
Clear the carry flag
Move the address to data pointer
Stop
LABEL
ADDRESS
LOOP
8200
MNEMONICS
OPCODE
COMMENTS
MOV IE,#81H
75 A8 81
Choose the type of Interrupt
8203
MOV DPTR,#A003H
90 A0 03
Assign A003H address to DPTR
8204
MOV A,#80H
8205
MOVX @DPTR,A
8207
MOV DPTR,#A001H
8208
MOV A,#FFH
8209
MOVX @DPTR,A
820A
SJMP LOOP
74 80
F0
90 A0 01
74 FF
F0
80 EF
Move the data 80H to ACC
Move the content of ACC to DPTR
Assign A001H address to DPTR
Move the data FFH to ACC
Move the content of ACC to DPTR
Short jump to label LOOP
Interrupt
LABEL
ADDRESS
MNEMONICS
OPCODE
8000
MOV DPTR,#A001H
90 A0 01
8003
MOV A,#00H
8004
MOVX @DPTR,A
F0
Move the content of ACC to DPTR
8005
RETI
32
Return to the main program
74 00
COMMENTS
Assign A001H address to DPTR
Move the data 00H to ACC