KEMBAR78
MPMC Experiments | PDF | Pointer (Computer Programming) | Computing
0% found this document useful (0 votes)
20 views30 pages

MPMC Experiments

This lab manual provides instructions for operating 8051 and 8085 microprocessor kits, detailing the steps to execute various assembly language programs. It includes a comprehensive index of programs such as addition, subtraction, multiplication, and sorting of 8-bit numbers, as well as conversions between number systems. The manual serves as a practical guide for electrical engineering students at Indira Gandhi Institute of Technology, Sarang.

Uploaded by

ee2101105321
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)
20 views30 pages

MPMC Experiments

This lab manual provides instructions for operating 8051 and 8085 microprocessor kits, detailing the steps to execute various assembly language programs. It includes a comprehensive index of programs such as addition, subtraction, multiplication, and sorting of 8-bit numbers, as well as conversions between number systems. The manual serves as a practical guide for electrical engineering students at Indira Gandhi Institute of Technology, Sarang.

Uploaded by

ee2101105321
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/ 30

MICROPROCESSOR & MICROCONTROLLER

LAB MANUAL

DEPARTMENT OF ELECTRICAL ENGINEERING

PRIYA PRITAM PANDA


MANOJ KUMAR MOHARANA
INDIRA GANDHI INSTITUTE OF TECHNOLOGY, SARANG PCEE7307
INSTRUCTION TO OPERATE 8051 KIT

(EXCEL MANUFACTURER)

Press ‘A’

Hit ‘Enter’

Type starting address

Hit ‘Enter’

(Write the opcode of the program)

Sjmp to finishing address

Hit ‘Enter’

Press ‘.’

Hit ‘Enter’

Press ‘Go’ and starting address

Hit ‘Enter’

Hit ‘INT’

Hit ‘Enter’

Hit ‘SD’ and location of output

Hit ‘Reset’
1
Page

©PRIYA PRITAM PANDA


INSTRUCTION TO OPERATE 8085 KIT

(Kitec MANUFACTURER)

Hit ‘Reset’
Screen will show various command such as
A Assembly mode (ASM_ORG_ADDRESS, Enter address)
M Pneumonic mode (Enter address directly)
*Start writing program*
Hit Enter twice
Enter break point (command ‘T’)
Enter breakpoint address
Enable breakpoint (command ‘E’)
To execute program
Hit ‘G’ and starting address
Hit enter
To access a particular location
Hit ‘M’ and Enter
To un-assemble
Hit ‘D’ starting to end memory location and enter
To execute program in a single step
After entering program hit ‘N’ then starting address
(N.B. Break point is that address up to which program will
execute
Use ‘Enter’ in Assembly mode
Use ‘space’ in memory mode)
2
Page

©PRIYA PRITAM PANDA


Index
Sl.No. Program Page no.
1. ADDITION OF TWO 8 BIT NUMBERS USING DIRECT ADDRESSING 5

2. SUBTRACTION OF TWO 8 BIT NUMBERS USING DIRECT 6


ADDRESSING

3. MULTIPLICATION OF TWO 8 BIT NUMBERS (INDIRECT 7


ADDRESSING)

4. DIVISION OF TWO 8 BIT NUMBERS 8

5. FIND THE LARGEST NUMBER IN AN ARRAY OF DATA 9

6. FIND THE SMALLEST NUMBER IN AN ARRAY OF DATA 10

7. SORT THE GIVEN BLOCK OF DATA IN ASCENDING ORDER 11

8. SORT THE GIVEN BLOCK OF DATA IN DESCENDING ORDER 12

9. BCD TO HEXADECIMAL CONVERSION 13

10. HEXADECIMAL TO BCD CONVERSION 14

11. HEXADECIMAL TO ASCII CONVERSION 15

12. ASCII TO HEXADECIMAL CONVERSION 16

132. FIND THE SQUARE OF A GIVEN NUMBER FROM LOOK-UP TABLE 17

14. FIND THE SQUARE ROOT OF A GIVEN NUMBER FROM LOOK-UP 18


TABLE
15. BCD ADDITION AND SUBTRACTION 19

16. SQUARE , RAMP AND TRIANGULAR WAVE GENERATION 20

17. ANALOG TO DIGITAL CONVERSIO 21

18. TRAFFIC CONTROL BY IMMIDIATE ADDRESSING 22

19. TRAFFIC CONTROL BY INDIRECT ADDRESSING 23

20. ADDITION OF 2 8-BIT NO'S USING 8051 24


3
Page

21. SUBTRACTION OF 2 8-BIT NO'S USING 8051 25

©PRIYA PRITAM PANDA


22. SUBTRACTION OF 2 8-BIT NO'S USING 8051 26

23. MULTIPLICATION OF 2 8-BIT NO'S USING 8051 27

24. DIVISION OF 2 8-BIT NO'S USING 8051 28

25. ADDITION OF 2 NO'S (8 bit) 29

4
Page

©PRIYA PRITAM PANDA


1 (A) ADDITION OF TWO 8 BIT NUMBERS USING DIRECT ADDRESSING
ADDRESS LABEL MNEMONIC OPCODE DESCRIPTION
8100 MVI C,00 Intialize the C - reg for carry and clear it
Load the content of address 8200 to
8102 LDA 8200
Accumulator
8105 MOV B,A Move the content of A-reg to B-reg
Load the content of address 8201 to
8106 LDA 8201
Accumulator
Add the content of B-reg with
8109 ADD B Accumulator and store the result in
Accumulator A =A+B
810A JNC LOOP Jump to loop if no carry is set else move to
next step
810D INR C Increment the content of C - reg
810E LOOP: STA 8202 Store the content of Accumulator in the
specified address location (SUM)
8111 MOV A,C Move the content of C-reg to A-reg
8112 STA 8203 Store the content of Accumulator in the
specified address location (CARRY)
8115 HLT Halt the program
INPUT: OUTPUT:
8200 8202
8201 8203

5
Page

©PRIYA PRITAM PANDA


1 (B) SUBTRACTION OF TWO 8 BIT NUMBERS USING DIRECT ADDRESSING

ADDRESS LABEL MNEMONIC OPCODE DESCRIPTION

Intialize the C - reg for carry and clear


8300 MVI C,00
it
Load the content of address 8200 to
8302 LDA 8400
Accumulator
8305 MOV B,A Move the content of A-reg to B-reg
8306 LDA 8401 Load the content of address 8201 to
Accumulator
Subtract the content of B-reg from the
8309 SUB B content of A-reg A=A-B and the
result is stored in Accumulator
830A JNC LOOP Jump to loop if no carry is set else
move to next step
Complement the content of
830D CMA
Accumulator\
830E INR A Increment the content of A-reg by 1
830F INR C Increment the content of C-reg by 1
8310 LOOP: STA 8402 Store the content of Accumulator in
the specified address location
8313 MOV A,C Move the content of C-reg to A-reg
8314 STA 8403 Store the content of Accumulator in
the specified address location
8317 HLT Halt the program
INPUT: OUTPUT:
8400 8402
8401 8403

6
Page

©PRIYA PRITAM PANDA


1© MULTIPLICATION OF TWO 8 BIT NUMBERS (INDIRECT ADDRESSING)

ADDRESS LABEL MNEMONIC OPCODE DESCRIPTION

8500 MVI D,00 Intialize the D - reg and clear it


8502 MVI A,00 Clear A-reg for arthimatic operation
Intialize the HL reg as memory
8504 LXI H 8600
pointer
8507 MOV B,M Move the content of memory to B-reg
Increment the memory pointer by 1
8508 INX H
HL=8301
8509 MOV C,M Move the content of memory to C-reg
Add the content of B-reg with the
850A LOOP: ADD B Accumulator and save the result in
Accumulator
If carry flag is not set move to NEXT
850B JNC NEXT loop otherwise move to next
instruction
850E INR D Increment the content of D-reg
850F NEXT: DCR C Decrement the content of C-reg
8510 JNZ LOOP Jump to LOOP loop if zero flag not
set else move th next instruction
8513 STA 8602 Store the content of Accumulator in
the specified address location (LSB)
8516 MOV A,D Move the content of D-reg to A-reg
8517 STA 8603 Store the content of Accumulator in
the specified address location (MSB)
851A HLT Halt the program
INPUT: OUTPUT:
8600 8602
8601 8603

7
Page

©PRIYA PRITAM PANDA


1 (D) DIVISION OF TWO 8 BIT NUMBERS

ADDRESS LABEL MNEMONIC OPCODE DESCRIPTION

8700 LXI H 8800


Intialize the HL reg as memory pointer
8703 MOV B,M
Move the content of memory to B-reg
8704 MVI C,00
Intialize the C - reg for QUOCIENT and clear it
8706 INX H
Increment the memory pointer by 1 HL=8401
8707 MOV A,M
Move the content of memory to A-reg
Compare the content of B-reg with the content
8708 NEXT: CMP B
of A-reg
8709 JC LOOP If carry flag is set move to LOOP else move to
next instruction
870C SUB B
Subtract the content of B-reg from Accumulator
870D INR C
Increment the content of C-reg
870E JMP NEXT
Unconditionally jump to NEXT
8711 LOOP: STA 8802 Store the content of Accumulator in the
specified address location (reminder)
8714 MOV A,C
Move the content of C-reg to A-reg
8715 STA 8803 Store the content of Accumulator in the
specified address location (Quocient)
8718 HLT
Halt the program

INPUT: OUTPUT:
8800 8802
8801 8803 8Page

©PRIYA PRITAM PANDA


2 FIND THE LARGEST NUMBER IN AN ARRAY OF DATA

ADDRESS LABEL MNEMONIC OPCODE DESCRIPTION

8900 LXI H 9000


Intialize the HL reg as memory pointer
8903 MOV B,M
Move the content of memory to B-reg
Increment the memory pointer by 1
8904 INX H
HL=8501
8905 MOV A,M
Move the content of memory to A-reg
8906 DCR B
Decrement the content of B-reg
Increment the memory pointer by 1
8907 LOOP: INX H
HL=8502
8908 CMP M Compare the content of memory with content
of Accumulator
8909 JNC AHEAD If carry flag is not set move to AHEAD if set
move to next instruction
890C MOV A,M
Move the content of memory to A-reg
890D AHEAD: DCR B
Decrement the content of B-reg
890E JNZ LOOP If zero flag is not set move to LOOP if set
move to next instruction
8911 STA 9006 Store the content of Accumulator in the
specified address location
8914 HLT
halt the program

INPUT: OUTPUT:

9000

9001 9006

9002

9003

9004

9005
9
Page

©PRIYA PRITAM PANDA


2 FIND THE SMALLEST NUMBER IN AN ARRAY OF DATA

ADDRESS LABEL MNEMONIC OPCODE DESCRIPTION

LXI H 8500
Intialize the HL reg as memory pointer
MOV B,M
Move the content of memory to B-reg
INX H
Increment the memory pointer by 1 HL=8501
MOV A,M
Move the content of memory to A-reg
DCR B
Decrement the content of B-reg
LOOP: INX H
Increment the memory pointer by 1 HL=8502
CMP M Compare the content of memory with content of
Accumulator
JC AHEAD If carry flag is set move to AHEAD if not set move to
next instruction
MOV A,M
Move the content of memory to A-reg
AHEAD: DCR B
Decrement the content of B-reg
JNZ LOOP If zero flag is not set move to LOOP if set move to next
instruction
STA 8506 Store the content of Accumulator in the specified
address location
HLT
halt the program

10 Page

©PRIYA PRITAM PANDA


3 (A) SORT THE GIVEN BLOCK OF DATA IN ASCENDING ORDER

ADDRESS LABEL MNEMONIC OPCODE DESCRIPTION


9000 LXI H 8700 Intialize the HL reg as memory pointer
9003 MOV C,M Move the content of memory to C-reg (No of Data)
9004 DCR C Decrement the content of C-reg by 1
Move the content of C-reg to D-reg (Counter for one
9005 REPEAT: MOV D,C
Cycle)
9006 LXI H 8701 Intialize the HL reg as memory pointer
9009 LOOP: MOV A,M Move the content of memory to A-reg
900A INX H Increment the memory pointer by 1
900B CMP M Compare the content of memory with content of
Accumulator
If carry flag is set move to SKIP if not set move to
900C JC SKIP
next instruction
900F MOV B,M Move the content of memory to B-reg
9010 MOV M,A
Move the content of A-reg to Memory
9011 DCX H
Decrement the address pointer by 1
9012 MOV M,B
Move the content of B-reg to memory
9013 INX H
Increment the memory pointer by 1
9014 SKIP: DCR D Decrement the content of D-reg
9015 JNZ LOOP If zero flag is not set move to LOOP if set move to
next instruction
9018 DCR C Decrement the content of C-reg by 1
9019 JNZ REPEAT If zero flag is not set move to REPEAT if set move
to next instruction
901C HLT Halt the program

INPUT: OUTPUT:

8700 8700

8701 8701

8702 8702

8703 8703
11

8704 8704
Page

8705 8705

©PRIYA PRITAM PANDA


3 (B) SORT THE GIVEN BLOCK OF DATA IN DESCENDING ORDER

ADDRESS LABEL MNEMONIC OPCODE DESCRIPTION

9100 LXI H 8700


Intialize the HL reg as memory pointer
Move the content of memory to C-reg (No of
9103 MOV C,M
Data)
9104 DCR C Decrement the content of C-reg by 1
9105 REPEAT: MOV D,C Move the content of C-reg to D-reg (Counter
for one Cycle)
9106 LXI H 8701 Intialize the HL reg as memory pointer
9109 LOOP: MOV A,M Move the content of memory to A-reg
910A INX H Increment the memory pointer by 1
910B CMP M Compare the content of memory with content
of Accumulator
910C JNC SKIP If carry flag is not set move to SKIP if set
move to next instruction
910F MOV B,M Move the content of memory to B-reg
9110 MOV M,A Move the content of A-reg to Memory
9111 DCX H Decrement the address pointer by 1
9112 MOV M,B Move the content of B-reg to memory
9113 INX H Increment the memory pointer by 1
9114 SKIP: DCR D Decrement the content of D-reg
9115 JNZ LOOP If zero flag is not set move to LOOP if set
move to next instruction
9118 DCR C Decrement the content of C-reg by 1
9119 JNZ REPEAT If zero flag is not set move to REPEAT if set
move to next instruction
911C HLT Halt the program

INPUT: OUTPUT:

8700 8700

8701 8701

8702 8702

8703 8703
12

8704 8704
Page

8705 8705

©PRIYA PRITAM PANDA


4 (A) BCD TO HEXADECIMAL CONVERSION

ADDRESS LABEL MNEMONIC OPCODE DESCRIPTION

9200 LXI H 9300


Intialize the HL reg as memory pointer
9203 MOV A,M
Move the content of memory to A-reg
9204 ADD A Add the content of Accumulator to
Accumulator (MSB x 2)
9205 MOV B,A
Move the content of A-reg to B.reg
9206 ADD A Add the content of Accumulator to
Accumulator (MSB x 4)
9207 ADD A Add the content of Accumulator to
Accumulator (MSB x 8)
Add the content of B-reg to Accumulator (MSB
9208 ADD B
x 10)
9209 INX H
Increment the address pointer
Add the content of memory to A-reg (LSB is
9210 ADD M
added)
9211 INX H
Increment the address pointer
9212 MOV M,A
Move the content of accumulator to memory
9213 HLT 76
Halt the program

INPUT: OUTPUT:

(MSB) 9300 9302

(LSB) 9301

13Page

©PRIYA PRITAM PANDA


4 (B) HEXADECIMAL TO BCD CONVERSION

ADDRESS LABEL MNEMONIC OPCODE DESCRIPTION

9400 LXI H 9500


Intialize the HL reg as memory pointer
9403 MVI D,00
Clear the content of D-reg
9405 XRA A Ex-or the content of A-reg with itself (clear A-
reg content)
9406 MOV C,M
Move the content of memory to C-reg
9407 LOOP2: ADI 01 Add immidiate the content 1 to A-reg and
store the result in A-reg
9409 DAA
Decimal Adjust Accumulator
940A JNC LOOP1 If carry flag not set move to LOOP1 else move
to next instruction
940D INR D
Increment the content of D-reg
940E LOOP1: DCR C
Decrement the content of C-reg
940F JNZ LOOP2 If carry flag not set move to LOOP2 else move
to next instruction
9412 STA 9501 Store the content of Accumulator in the
specified address location
9415 MOV A,D
Move the content of D-reg to Accumulator
9416 STA 9502 Store the content of Accumulator in the
specified address location
9419 HLT
Halt the program

INPUT: OUTPUT:

9500 (LSB) 9501

(MSB) 9502
14
Page

©PRIYA PRITAM PANDA


4© HEXADECIMAL TO ASCII CONVERSION

ADDRESS LABEL MNEMONIC OPCODE DESCRIPTION


9600 LDA 9700 Load the hexadecimal data to acuumulator
9603 MOV B,A
Move the content of A-reg to B-reg
Add immidiate data 0F with the content of A-
9604 ANI 0F reg and store the result in A-reg (Mask the
lower nibble)
9606 CALL SUB1 CALL subroutine program in SUB1 program
jumps to SUB1 unconditionally
9609 STA 9701 Store the content of Accumulator in the
specified address location
960C MOV A,B
Move the content of B-reg to A-reg
Add immidiate data FO with the content of A-
960D ANI F0 reg and store the result in A-reg (Mask the
Upper nibble)
960F RLC Rotate Left with carry
9610 RLC Rotate Left with carry
9611 RLC Rotate Left with carry
9612 RLC Rotate Left with carry
9613 CALL SUB1 CALL subroutine program in SUB1 program
jumps to SUB1 unconditionally
9616 STA 9702 Store the content of Accumulator in the
specified address location
9619 HLT Halt the program
Compare immidiate the data 0A with the
961A SUB1: CPI 0A
content of A-reg
if A-reg content < 0A move to SKIP else next
961C JC SKIP
instruction
961F ADI 07 Add immodiate the content 07 to A-reg and
store the result in A-reg
9621 SKIP: ADI 30 Add immodiate the content 30 to A-reg and
store the result in A-reg
Return to main program next to CALL
9623 RET
instruction

INPUT: OUTPUT:
15

9700 9701
Page

9702

©PRIYA PRITAM PANDA


4 (D) ASCII TO HEXADECIMAL CONVERSION

ADDRESS LABEL MNEMONIC OPCODE DESCRIPTION

9800 LDA 9900


Load the ASCII value to the Accumulator
Subtract immidiate the value 30 from
9803 SUI 30 Accumulator and store the resulr in
Accumulator
Compare immidiate the data 0A with the
9805 CPI 0A
content of A-reg
9807 JC SKIP if A-reg content < 0A move to SKIP else next
instruction
Subtract immidiate the value 07 from
980A SUI 07 Accumulator and store the resulr in
Accumulator
980C SKIP: STA 9901 Store the content of Accumulator in the
specified address location
980F HLT
Halt the program

INPUT: OUTPUT:

9900 9901

16
Page

©PRIYA PRITAM PANDA


5 (A) FIND THE SQUARE OF A GIVEN NUMBER FROM LOOK-UP TABLE

ADDRESS LABEL MNEMONIC OPCODE DESCRIPTION

8200 LXI H 9001


Intialize the HL reg as memory pointer
8203 LDA 9100
Load the Data to be squared to Accumulator
8206 CPI 0A Compare immidiate the data 0A with the
content of A-reg
8208 JC AFTER if A-reg content < 0A move to AFTER else
next instruction
820B MVI A,FF
Move the data FF to Accumulator
820D STA 9101 Store the content of Accumulator in the
specified address location
8210 HLT
Halt the program
8211 AFTER: MOV L,A
Move the content of Accumulator to L-reg
8212 MOV A,M
Move the content of Memory to Accumulator
8213 STA 9101 Store the content of Accumulator in the
specified address location
8216 HLT
Halt the program

LOOK UP TABLE INPUT: OUTPUT:

9001 01 9100 9101

9002 04

9003 09

9004 16

9005 25

9006 36

9007 49
17

9008 64
Page

9009 81

©PRIYA PRITAM PANDA


5(B) FIND THE SQUARE ROOT OF A GIVEN NUMBER FROM LOOK-UP TABLE

ADDRESS LABEL MNEMONIC OPCODE DESCRIPTION

8300 LXI H 9001


Intialize the HL reg as memory pointer
8303 MOV B,M
Load the block size of table
8304 LDA 9101
Load the input data to Accumulatr
8307 REPEAT: INX H
Increment the address pointer
8308 CMP M Compare the content of memoery with
content of A-reg
8309 JZ OK If zero flag is set move to OK else move to
next instruction
830C DCR C
Decrement the content of C-reg
830D JNZ REPEAT If zero flaf is not set move to REPEAT else
move th next instruction
8310 MVI A,FF
Move the data FF to Accumulator
8312 JMP ERROR
Unconditionally jump to ERROR
8315 OK: MOV A,L Move the content of L-reg to Accumulator
8316 ERROR: STA 9102 Store the content of Accumulator in the
specified address location
8319 HLT Halt the program

LOOK UP TABLE: INPUT: OUTPUT:

9001 01 9101 9102

9002 04

9003 09

9004 16

9005 25

9006 36

9007 49
18

9008 64
Page

9009 81

©PRIYA PRITAM PANDA


6 BCD ADDITION AND SUBTRACTION

ADDRESS LABEL MNEMONIC OPCODE DESCRIPTION

9900 LXI H 9950 Intialize the HL reg as memory pointer


9903 MOV D,M Move the first data to D-reg
9904 INX H Increment the address pointer
9905 MOV E,M Move the second data to E-reg
9906 XRA A Clear the content of A-reg
9907 MOV B,A Clear the content of B-reg
9908 MOV C,A Clear the content of C-reg
9909 MOV A,D Move the first data to A-reg
990A ADD E Add the content of E-reg to A-reg
990B DAA Decimal Adjust Accumulator
990C JNC NEXT Jump on No Carry NEXT

990F INC B Increment the content of B-reg by 1

Store the content of Accumulator in the


9910 NEXT STA 9952
specified address location (Addition Result)

9913 MOV A,B Move the content of B-reg to Accumulator

Store the content of Accumulator in the


9914 STA 9953
specified address location (Carry)
9917 MOV A,D Move the first data to A-reg
9918 SUB E Subtract the content of E-reg from Accumulator
9919 JNC GO Jump on No Carry GO
991C CMA Complement the content of Accumulator
991D INR A Increment the content of A-reg by 1
991E INR C Increment the content of C-reg by 1
Store the content of Accumulator in the
991F GO STA 9954
specified address location (Subtraction Result)
9922 MOV A,C Move the content of C-reg to A-reg
Store the content of Accumulator in the
9923 STA 9955
specified address location (Borrow)
9926 HLT Halt the program

INPUT: OUTPUT:
19

9950 9952 9954


Page

9951 9953 9955

©PRIYA PRITAM PANDA


7 SQUARE , RAMP AND TRIANGULAR WAVE GENERATION
ADDRESS LABEL MNEMONIC OPCODE DESCRIPTION
SQUARE WAVE GENERATION
A000 MVI A, 80 Move the control word to Accumulator
A002 OUT 43 Move the control word fro Acc to control reg
A004 AGAIN MVI A, 00 Move the content 00 to A-reg
A006 OUT PORTA Move the data in Acc to Port-A
A008 CALL DELAY Call the delay subroutine
A00B MVI A, FF Move the data FF to A-reg
A00D OUT PORTA Move the data in Acc to Port-A
A00F CALL DELAY Call the delay subroutine
A012 JMP AGAIN Jump unconditionally to the address specified
DELAY SUBROUTINE
A020 DELAY MVI D, CC Move the content CC to D-reg
A022 LOOP DCR D Decrement the content of D-reg by one
A023 NOP No Operation
A024 JNZ LOOP Jump on no zero to loop
A027 RET Return to main program
RAMP WAVE GENERATION
A030 MVI A, 80 Move the control word to Accumulator
A032 OUT 43 Move the control word fro Acc to control reg
A034 AGAIN MVI A, 00 Move the content 00 to A-reg
A036 OUT PORTA Move the data in Acc to Port-A
A038 MVI A, FF Move the content FF to A-reg
A03A LOOP DCR A Decrement the content of A-reg by one
A03B OUT PORTA Move the data in Acc to Port-A
A03D JNZ LOOP Jump on no zero to LOOP
A040 JMP AGAIN Jump unconditionally to address specified
TRIANGULAR WAVE GENERATION
A050 MVI A, 80 Move the control word to Accumulator
A052 OUT 43 Move the control word fro Acc to control reg
A054 AGAIN MVI A, 00 Move the content 00 to A-reg
A056 OUT PORTA Move the data in Acc to Port-A
A058 MVI B, FF Move immidiate the data FF to B-reg
A05A LOOP INR A Increment the content of A-reg by one
A05B OUT PORTA Move the data in Acc to Port-A
A05D CMP B Compare the content of B-reg with Acc
A05E JNZ LOOP Jump on no zero to LOOP
A061 MVI A, FF Move the content FF to A-reg
A063 NEXT DCR A Decrement the content of A-reg by one
A064 OUT PORTA Move the data in Acc to Port-A
A066 JNZ NEXT Jump on no zero to NEXT
A069 JMP AGAIN Jump unconditionally to address specified
20

INPUT: OUTPUT:
9950 9952 9954
Page

9951 9953 9955

©PRIYA PRITAM PANDA


8 ANALOG TO DIGITAL CONVERSION

ADDRESS LABEL MNEMONIC OPCODE DESCRIPTION

8A00 AGAIN MVI A, 82 Move the control word to Accumulator

8A02 OUT 43 Move the control word from Acc to control reg

8A04 MVI A, 02 Move the content 02 to A-reg

8A06 OUT 40 Move the data in Acc to Port-A

8A08 NOP No Operation


8A09 NOP No Operation
8A0A NOP No Operation
8A0B MVI B, FF Move immidiate the data FF to B-reg
8A0D MVI A, 01 Move the content 01 to A-reg
8A0F OUT 40 Move the data in Acc to Port-A
8A11 L1 DCR B Decrement the content of B-reg by one
8A12 NOP No Operation
8A13 NOP No Operation
8A14 NOP No Operation
8A15 NOP No Operation
8A16 NOP No Operation
8A17 JNZ L1 Jump on no zero to L1
8A1A MVI A, 04 Move the content 04 to A-reg
8A1C OUT 40 Move the data in Acc to Port-A
8A1E DCR B Decrement the content of B-reg by one
8A1F L2 INR B Increment the content of B-reg by one
8A20 IN 41 Input the data from port B
8A22 ANI 01 AND immidiate the data 01 with A-reg
8A24 JNZ L2 Jump on no zero to L2
8A25 MOV A, B Move the content of B-reg to A-reg
8A26 STA 8FF1 Store the content of A-reg in specified register
8A29 CALL UPDT Call the subroutine
8A2C JMP AGAIN Jump unconditionally to address specified

INPUT: OUTPUT:
9950 9952 9954
9951 9953 9955
21
Page

©PRIYA PRITAM PANDA


9 TRAFFIC CONTROL BY IMMIDIATE ADDRESSING
ADDRESS LABEL MNEMONIC OPCODE DESCRIPTION
8C00 AGAIN MVI A, 80 Move the control word to Accumulator
8C02 OUT CR Move the control word fro Acc to control reg
8C04 MVI A, SA1 Move the traffic sequence of port-A to A-reg
8C06 OUT PORTA Move the data in Acc to Port-A
8C08 MVI A, SB1 Move the traffic sequence of port-B to A-reg
8C0A OUT PORTB Move the data in Acc to Port-B
8C0C MVI A, SC1 Move the traffic sequence of port-C to A-reg
8C0E OUT PORTC Move the data in Acc to Port-C
8C10 CALL DELAY Call delay routine
8C13 MVI A, SA2 Move the traffic sequence of port-A to A-reg
8C15 L1 OUT PORTA Move the data in Acc to Port-A
8C17 MVI A, SB2 Move the traffic sequence of port-B to A-reg
8C19 OUT PORTB Move the data in Acc to Port-B
8C1A MVI A, SC2 Move the traffic sequence of port-C to A-reg
8C1C OUT PORTC Move the data in Acc to Port-C
8C1E CALL DELAY Call delay routine
8C21 MVI A, SA3 Move the traffic sequence of port-A to A-reg
8C23 OUT PORTA Move the data in Acc to Port-A
8C25 MVI A, SB3 Move the traffic sequence of port-B to A-reg
8C27 OUT PORTB Move the data in Acc to Port-B
8C29 L2 MVI A, SC3 Move the traffic sequence of port-C to A-reg
8C2B OUT PORTC Move the data in Acc to Port-C
8C2E CALL DELAY Call delay routine
8C31 MVI A, SA4 Move the traffic sequence of port-A to A-reg
8C33 OUT PORTA Move the data in Acc to Port-A
8C35 MVI A, SB4 Move the traffic sequence of port-B to A-reg
8C37 OUT PORTB Move the data in Acc to Port-B
8C39 MVI A, SC4 Move the traffic sequence of port-C to A-reg
8C3B OUT PORTC Move the data in Acc to Port-C
8C3D CALL DELAY Call delay routine
8C40 JMP AGAIN Unconditionally jump to specified address
Delay Routine
8C45 MVI B, FF Move content FF to B-reg
8C47 L3 MVI C, FF Move content FF to C-reg
8C49 L2 MVI D, FF Move content FF to D-reg
8C4B L1 DCR D Decrement the content of specified register by 1
Jump on no zero to specified address else move
8C4C JNZ L1
the next instruction
8C4F DCR C Decrement the content of specified register by 1
Jump on no zero to specified address else move
8050 JNZ L2
the next instruction
8053 DCR B Decrement the content of specified register by 1
22

Jump on no zero to specified address else move


8054 JNZ L3
the next instruction
Page

8057 RET Return to the main program

©PRIYA PRITAM PANDA


9 (B) TRAFFIC CONTROL BY INDIRECT ADDRESSING

ADDRESS LABEL MNEMONIC OPCODE DESCRIPTION


8C00 LXI H 9000 Initialize the HL memory pointer
8C03 MOV A,M Move the control word from memory to A-reg
8C04 OUT 43 Move the control word to control register
8C06 AGAIN LXI H 9001 Initialize the HL memory pointer
8C09 MOV E,M Move the content of memory to E-reg
8C0A LOOP INX H Increment the memory pointer by 1
8C0B MOV A,M Move the traffic sequence from memory to A-reg
8C0C OUT 40 Move the data in Acc to Port-A
8C0E INX H Increment the memory pointer by 1

8C0F MOV A,M Move the traffic sequence from memory to A-reg

8C10 OUT 41 Move the data in Acc to Port-B

8C12 INX H Increment the memory pointer by 1

8C13 MOV A,M Move the traffic sequence from memory to A-reg

8C14 OUT 42 Move the data in Acc to Port-C


8C16 CALL DELAY Call delay routine
8C19 DCR E Decrement the content of specified register by 1
8C1A DCR E Decrement the content of specified register by 1
8C1B DCR E Decrement the content of specified register by 1
8C1C JNZ LOOP Call delay routine
8C1F JMP AGAIN Unconditionally jump to specified address
Delay Routine
8C45 MVI B, FF Move content FF to B-reg
8C47 L3 MVI C, FF Move content FF to C-reg
8C49 L2 MVI D, FF Move content FF to D-reg
8C4B L1 DCR D Decrement the content of specified register by 1
Jump on no zero to specified address else move the
8C4C JNZ L1
next instruction
8C4F DCR C Decrement the content of specified register by 1
Jump on no zero to specified address else move the
8050 JNZ L2
next instruction
8053 DCR B Decrement the content of specified register by 1
Jump on no zero to specified address else move the
8054 JNZ L3
next instruction
23

8057 RET Return to the main program


Page

©PRIYA PRITAM PANDA


10 (A) ADDITION OF 2 8-BIT NO'S USING 8051

ADDRESS LABEL MNEMONIC OPCODE DESCRIPTION

8000 MOV A,#00 Move the content 0 to A-reg

8002 MOV DPTR, #9000 Initialize the Data pointer

8005 MOV R1, A Clear R1 register content


Move the data pointed by data pointer to A-
8006 MOVC A @A+DPTR
reg
8007 MOV R0, A Copy the content of A-reg to R0-reg

8008 INC DPTR Increment the Data pointer by one

8009 MOV A, R1 Move the content of R1-reg to A-reg


Move the data pointed by data pointer to A-
800A MOVC A @A+DPTR
reg
800B ADD A, R0 Add the content of A-reg and R0-reg

800C JNC NEXT Check for the condition and jump accordingly

800E INC R1 Increment the content of R1-reg by one

800F NEXT INC DPTR Increment the Data pointer by one

8010 MOVX @DPTR, A Move the content of A-reg to memory

8011 INC DPTR Increment the Data pointer by one

8012 MOV A, R1 Move the content of R1-reg to A-reg

8013 MOVX @DPTR, A Move the content of A-reg to memory

8014 HERE SJMP HERE Jump uncondiionally


24
Page

©PRIYA PRITAM PANDA


10 (B) SUBTRACTION OF 2 8-BIT NO'S USING 8051

ADDRESS LABEL MNEMONIC OPCODE DESCRIPTION

8100 MOV A,#09 Move the data 09 to A-reg

8102 MOV R1, #05 Mov the data 05 to R1-reg

8104 MOV DPTR, #9100 Initialize the Data pointer

8107 SUBB A, R0 Subtract the content of R0 from A-reg

8108 MOVX @DPTR, A Move the content of A-reg to memory

8109 INC DPTR Increment the Data pointer by one

810A MOV #A, 00 Move the content 00 to A-reg

810C JNC NEXT Check for the condition and jump accordingly

810E MOV A, #01 Move the content 01 to A-reg

8110 NEXT MOVX @DPTR, A Move the content of A-reg to memory

8111 HERE SJMP HERE Jump uncondiionally

25
Page

©PRIYA PRITAM PANDA


10 (B) SUBTRACTION OF 2 8-BIT NO'S USING 8051

ADDRESS LABEL MNEMONIC OPCODE DESCRIPTION

8100 MOV A,#18 Move the data 09 to A-reg

8102 MOV 0D, A Mov the data 05 to R1-reg

8104 MOV DPTR, #9100 Initialize the Data pointer


Move the data pointed by data pointer to A-
8105 MOV A, @DPTR
reg
8106 MOV R0, A Copy the content of A-reg to R0-reg
Move the data pointed by data pointer to A-
8107 MOV A, @DPTR
reg
8108 SUBB A, R0 Subtract the content of R0 from A-reg

8109 MOVX @DPTR, A Move the content of A-reg to memory

810A INC DPTR Increment the Data pointer by one

810B CLR A Move the content 00 to A-reg

810C JNC NEXT Check for the condition and jump accordingly

810E MOV A, #01 Move the content 01 to A-reg

8110 NEXT MOVX @DPTR, A Move the content of A-reg to memory

8111 HERE SJMP HERE Jump uncondiionally

26
Page

©PRIYA PRITAM PANDA


10 (C) MULTIPLICATION OF 2 8-BIT NO'S USING 8051

ADDRESS LABEL MNEMONIC OPCODE DESCRIPTION

8401 CLR A Clear the content of A-reg

8402 MOV DPTR, #9000 Initialize the Data pointer

8405 MOVX A, @DPTR Move the data pointed by data pointer to A-reg

8406 MOV F0, A Move the content of A-reg to B-reg

8409 INC DPTR Increment the Data pointer by one

840A MOVX A, @DPTR Move the data pointed by data pointer to A-reg

840B MUL AB Multiply of content of A-reg and B-reg

840C INC DPTR Increment the Data pointer by one

840D MOVX @DPTR, A Move the content of A-reg to memory (LSB)

840E INC DPTR Increment the Data pointer by one

840F MOV A, F0 Move the content of B-reg to A-reg

8412 MOVX @DPTR, A Move the content of A-reg to memory (MSB)

8413 LCALL 00BB Jump uncondiionally

27 Page

©PRIYA PRITAM PANDA


10 (D) DIVISION OF 2 8-BIT NO'S USING 8051

ADDRESS LABEL MNEMONIC OPCODE DESCRIPTION

8401 CLR A Clear the content of A-reg

8402 MOV DPTR, #9000 Initialize the Data pointer

8405 MOVX A, @DPTR Move the data pointed by data pointer to A-reg

8406 MOV F0, A Move the content of A-reg to B-reg

8409 INC DPTR Increment the Data pointer by one

840A MOVX A, @DPTR Move the data pointed by data pointer to A-reg

840B DIV AB Divide of content of A-reg by B-reg

840C INC DPTR Increment the Data pointer by one


Move the content of A-reg to
840D MOVX @DPTR, A
memory(quotient)
840E INC DPTR Increment the Data pointer by one

840F MOV A, F0 Move the content of B-reg to A-reg(remainder)

8412 MOVX @DPTR, A Move the content of A-reg to memory

8413 LCALL 00BB Jump uncondiionally

28
Page

©PRIYA PRITAM PANDA


11 ADDITION OF 2 NO'S (8 bit)

ADDRESS LABEL MNEMONIC OPCODE DESCRIPTION


9900 MOV A, #0 Intialize the HL reg as memory pointer
9903 MOV DPTR #8200 Move the first data to D-reg

9904 MOV A, #8 Increment the address pointer


9905 MOV R0, #5 Move the second data to E-reg
MOV R1,#0
9906 ADD A,R0 Clear the content of A-reg
9907 MOVX @DPTR, A Clear the content of B-reg
9908 INC DPTR Clear the content of C-reg
9909 JNC NEXT Move the first data to A-reg
990A INR R1 Add the content of E-reg to A-reg
NEXT MOV A,R1
990B MOVX @DPTR, A Decimal Adjust Accumulator
990C MOV A,#0 Jump on No Carry NEXT
990F INC B Increment the content of B-reg by 1
Store the content of Accumulator in the
9910 STA 9952 specified address location (Addition
Result)
9913 MOV A,B Move the content of B-reg to Accumulator
Store the content of Accumulator in the
9914 STA 9953
specified address location (Carry)
9917 MOV A,D Move the first data to A-reg
Subtract the content of E-reg from
9918 SUB E
Accumulator
9919 JNC GO Jump on No Carry GO
991C CMA Complement the content of Accumulator
991D INR A Increment the content of A-reg by 1
991E INR C Increment the content of C-reg by 1
Store the content of Accumulator in the
991F GO STA 9954 specified address location (Subtraction
Result)
9922 MOV A,C Move the content of C-reg to A-reg
Store the content of Accumulator in the
9923 STA 9955
specified address location (Borrow)
9926 HLT Halt the program

INPUT: OUTPUT:
29

9950 9952 9954


Page

9951 9953 9955

©PRIYA PRITAM PANDA

You might also like