2 eee vi sem lab manual.doc

68
1. A) 8-BIT ARITHMETIC OPERATIONS USING 8085 AIM: To write an assembly language program in 8085 to add, subtract, multiply and divide two 8 bit numbers. APPARATUS REQUIRED: 1. 8085 Microprocessor Kit-1 2. Power supply 5V 8-BIT ADDITION ALGORITHM: 1. Start the program 2. Initialize the carry register as 00H. 3. Move the data1 and data2 to accumulator and B register respectively. 4. Add B register to the content of accumulator 5. If there is no carry, go to step 6, else increment C register. 6. Store the content of accumulator to the memory location. 7. Move the content of C register to accumulator. 8. Store the content of accumulator to the next memory location. 9. Stop the program. PROGRAM: ADDRESS OPCODE LABEL MNEMONICS COMMENTS 8100 0E, 00 MVI C,00 H Clear carry register 8102 3E, data1 MVI A,data1 Move data1 to accumulator 8104 06,data2 MVI B,data2 Move data2 to B Register 8106 80 ADD B Add B Reg to accumulator 8107 D2,0B,81 JNC GO Jump on No carry to address 810A 0C INR C Increment C Register 810B 32,00,80 GO STA 8000 Store the result 810E 79 MOV A,C Move carry to acc 810F 32,01,80 STA 8001 Store the carry 8112 76 HLT Stop the program

Upload: adeivaseelan

Post on 13-Sep-2015

259 views

Category:

Documents


10 download

TRANSCRIPT

1. A) 8-BIT ARITHMETIC OPERATIONS USING 8085

AIM:

To write an assembly language program in 8085 to add, subtract, multiply and divide two 8 bit numbers.

APPARATUS REQUIRED:1. 8085 Microprocessor Kit-1

2. Power supply 5V

8-BIT ADDITION

ALGORITHM:

1. Start the program

2. Initialize the carry register as 00H.

3. Move the data1 and data2 to accumulator and B register respectively.

4. Add B register to the content of accumulator

5. If there is no carry, go to step 6, else increment C register.

6. Store the content of accumulator to the memory location.

7. Move the content of C register to accumulator.

8. Store the content of accumulator to the next memory location.

9. Stop the program.PROGRAM:

ADDRESSOPCODELABELMNEMONICSCOMMENTS

81000E, 00MVI C,00 H Clear carry register

81023E, data1MVI A,data1 Move data1 to accumulator

810406,data2MVI B,data2Move data2 to B Register

810680ADD BAdd B Reg to accumulator

8107D2,0B,81JNC GOJump on No carry to address

810A0CINR CIncrement C Register

810B32,00,80GOSTA 8000Store the result

810E79MOV A,CMove carry to acc

810F32,01,80STA 8001Store the carry

811276HLTStop the program

OUTPUT:InputOutput

Memory locationDataMemory locationData

Data 104800006

Data 202800100

FLOW CHART:

NO

YES

8-BIT SUBTRACTIONALGORITHM:

1. Load the subtrahend from memory to A register and move it to B register.

2. Load the minuend to the accumulator.

3. Clear the C register to account for the sign of result.

4. Subtract the contents of B register from the A register.

5. Check for carry. If carry=0 go to 7th step, else go to next step.

6. Increment C register, and find the 2s complement of the content of accumulator.7. Store the content of accumulator and C-register8. Stop the program

PROGRAM:

ADDRESSOPCODELABELMNEMONICSCOMMENTS

81003A, 00, 82LDA 8200HLoad the subtrahend

810347MOV B,AMove the subtrahend in B reg

81043A, 01, 82LDA 8201HLoad the minuend in A reg.

81070E, 00MVI C,00HClear C register.

810990SUB BGet difference on acc.

810AD2, 11, 81JNC AHEADIf CY=0, go to AHEAD

810D0CINR CIf CY=1, increment C reg

810E2FCMATake 2s complement of the result

810FC6,01ADI 01H

811132, 02, 82AHEADSTA 8202HStore the result in memory

811479MOV A,C

811532, 03, 82STA 8203HStore the sign bit in memory

811876HLTStop the program

OUTPUT:InputOutput

Memory locationDataMemory locationData

820006820204

820102820300

FLOW CHART:

NO

YES

8-BIT MULTIPLICATIONALGORITHM:1. Start the program

2. Clear the Accumulator and load multiplicand to B register.

3. Load the multiplier in C register.

4. Clear the D register for carry.

5. Add the content of B to accumulator until the multiplier becomes zero.

6. Increment the carry register if carry exists.

7. Store the product and the carry.

8. Stop the program

PROGRAM:ADDRESSOPCODELABELMNEMONICSCOMMENTS

85003E, 00MVI A,00Move data to accumulator

850206,data1MVI B,data1Move multiplicand to B register

85040E,data2MVI C,data2Move the multiplier to C register

850616,00MVI D,00Clear D reg for carry

850880LOOP2ADD Brepetitive addition

8509D2, 0D, 85JNC LOOP1

850C14INR DIncrement the D register if there is carry

850D0DLOOP1DCR CDecrement multiplier

850EC2, 08,85JNZ LOOP2Repeat the loop2 till C reg. becomes zero

851132,00,80STA 8000Store the product

85147AMOV A,D

851532,01,80STA 8001Store the carry.

851876HLTStop the process.

OUTPUT:InputOutput

Memory locationDataMemory locationData

Data 103800006

Data 202800100

FLOWCHART:

NO

YES

NO

YES

8-BIT DIVISIONALGORITHM:1. Start the program

2. Load the divisor to accumulator

3. Load the dividend to B-register

4. Compare the B-register value with the accumulator

5. Jump on carry to step - 9

6. Subtract B-register value with accumulator

7. Increment the C-register and Jump to step 4

8.Store the quotient and the remainder.9. Stop the programPROGRAM:

ADDRESSOPCODELABELMNEMONICSCOMMENTS

85003E,data1MVI A,data1Move divisor to accumulator

850206,data2MVI B,data2Move dividend to B Register

85040E, 00MVI C,00Clear C register

8506B8LOOP2CMP BCompare B reg and accumulator.

8507DA, 0F, 85JC LOOP1Jump on carry to loop1.

850A90SUB BRepetitive subtraction for division

850B0CINR CIncrement C register

850CC3, 06,85JMP LOOP2Jump to loop2

850F32,01,80LOOP1STA 8001Store the remainder.

851279MOV A,C

851332,00,80STA 8000Store the quotient.

851676HLTStop the process.

OUTPUT:InputOutput

Memory locationDataMemory locationData

Data 104800002

Data 202800100

FLOWCHART:

NO

YES

RESULT: Thus the assembly language program for 8-bit addition, subtraction, multiplication and division was executed using an 8085 microprocessor.1.B)16-BIT ARITHMETIC OPERATIONS USING 8085

16-BIT ADDITION

AIM:

To write an assembly language program in 8085 to add, subtract, multiply and divide two 16-Bit numbers.

ALGORITHM:

1. Start the program.

2. Load the first 16 bit data into HL register pair and move it to DE pair.

3. Load the second 16 bit data in HL register pair.4. Clear the accumulator for carry.5. Add the content of HL register pair with DE register pair.6. Check for carry and if carry exists, store it in carry register.7. Store the sum and carry.8. Stop the program.PROGRAM: ADDRESSOPCODELABELMNEMONICSCOMMENTS

81002A, 00, 82LHLD 8200Load first 16-bit data in HL reg pair

8103EBXCHGExchange content of DE with HL reg pair

81042A, 02, 82LHLD 8202Load second 16-bit data in HL reg pair

8107AFXRA AClear the accumulator.

810819DAD DAdd the two numbers

8109D2, 0D, 81JNC RESULTIf there is no carry store the sum.

810C3CINR AElse increment the carry

810D22, 04, 82RESULTSHLD 8204Store the sum in specified address

811032, 06, 82STA 8206Store the carry in specified address

811376HLTEnd of program

OUTPUT:InputOutput

Memory locationDataMemory locationData

82008204

82018205

82028206

8203

FLOW CHART:

NO

YES

16-BIT SUBTRACTIONALGORITHM:

1. Start the program

2. Load the first 16 bit data in HL register pair and move it to DE reg pair.

3. Load the second 16 bit data in HL register pair.

4. Subtract the lower byte of data first and then higher byte of data.

5. If there is a carry obtain 2S Complement of result.

6. Store the difference and sign bit.

7. Stop the program. PROGRAM:

ADDRESSOPCODELABELMNEMONICSCOMMENTS

82000E, 00MVI C, 00HClear C register

82022A, 00, 84LHLD 8400HLoad the subtrahend in HL reg pair

8205EBXCHGCopy to DE reg pair

82062A, 02, 84LHLD 8402Load the minuend

82097DMOV A, L

820A93SUB ESubtract lower order bytes

820B6FMOV L, AStore lower byte result in L register.

820C7CMOV A, H

820D9ASBB DSubtract higher order bytes.

820E67MOV H, AStore higher byte result in H register.

820FD2, 1A, 82JNC GOIf CY=0 store the result

82120CINR CElse increments carry register.

82137DMOV A, LTake 2s complement of result.

82142FCMA

82156FMOV L, A

82167CMOV A, H

82172FCMA

821867MOV H,A

821923INX H

821A22, 04, 84GOSHLD 8404HStore the result.

821D79MOV A, C.

821E32, 06, 84STA 8406HStore the carry.

842176HLTEnd of the program.

OUTPUT:InputOutput

Memory locationDataMemory locationData

84008404

84018405

84028406

8403

FLOW CHART:

NO

NO

YES

16-BIT MULTIPLICATION

ALGORITHM:

1. Start the program

2. Load the multiplicand in HL pair register and copy in SP.

3. Load the multiplier in DE reg pair and clear HL and BC reg pair.

4. Add content of SP to HL pair register content.

5. Perform repetitive addition of the multiplicand until the multiplier becomes zero.

6. Store the product.

7. Stop the program.PROGRAM:

ADDRESSOPCODELABELMNEMONICSCOMMENTS

80002A,50,80LHLD 8050HLoad the first No. in stack pointer through HL reg. pair

8003F9SPHL

80042A,52,80LHLD 8052Load the second No. in HL reg. pair

& Exchange with DE reg. pair.

8007EBXCHG

800821,00,00LXI H, 0000HClear HL & DE reg. pairs.

800B01,00,00LXI B, 0000H

800E39LOOPDAD SPAdd SP with HL pair.

800FD2,13,80JNC NEXTIf there is no carry, go to the instruction labeled NEXT

801203INX BIncrement BC reg. pair

80131BNEXTDCR DDecrement DE reg. pair.

80147BMOV A,EMove the content of reg. E to Acc

8015B2ORA DOR Acc. with D reg.

8016C2,0E,80JNZ LOOPIf there is no zero, go to instruction labeled LOOP

801922,54,80SHLD 8054Store the content of HL pair in memory locations 8054 & 8055.

801C79MOV A, CMove the content of reg. C to Acc.

801D32,56,80STA 8056Store the content of Acc. in memory location 8056.

802078MOV A, BMove the content of reg. B to Acc.

802132,57,80STA 8057Store the content of Acc. in memory location 8057.

802476HLTStop program execution

OUTPUT:InputOutput

Memory locationDataMemory locationData

80508054

80518055

80528056

80538057

FLOWCHART :

NO

YES

NO

YES

16-BIT DIVISION

ALGORITHM:

1. Start the program

2. Load the dividend in HL pair register.

3. Load the divisor in accumulator and move to C register.

4. Subtract the content of the divisor from the dividend until the carry flag is set.

5. Increment the quotient during every time of subtraction.

6. Store the quotient and the remainder.

7. Stop the program.

PROGRAM:

ADDRESSOPCODELABELMNEMONICSCOMMENTS

81002A,00, 42LHLD 8200HLoad the dividend in HL reg pair

81033A,02,42LDA 8202H

81064FMOV C,ALoad the divisor in C register

810711,00,00LXI D,0000HClear DE reg pair

810A7DLOOP1MOV A,LMove the content of Acc to L.

810B91SUB CSubtract reg. C from that of Acc.

810C6FMOV L,AMove the content of Acc to L.

810DD2,11,81JNC LOOP2If there is no carry, go to the location labeled LOOP 2.

811025DCR HDecrement H reg. pair.

811113LOOP2INX DIncrement the quotient

81127CMOV A,HMove the content of reg. H Acc.

8113FE,00CPI 00H

8115C2,0A,81JNZ LOOP1If there is no zero, go to instruction labeled LOOP1

81187DMOV A,LMove the content of Acc to L.

8119B9CMP CCompare C & A

811AD2,0A,81JNC LOOP1If there is no carry, go to the location labeled LOOP 1.

811D22,02,83SHLD 8302HStore the remainder

8120EBXCHGExchange

812122,00,83SHLD 8300HStore the quotient

812476HLTStop the program execution.

OUTPUT:InputOutput

Memory locationDataMemory locationData

82008300

82018301

82028302

82038303

FLOWCHART:

NO

YES

RESULT:

Thus the assembly language program for 16-bit addition, subtraction, multiplication and division was executed using an 8085 microprocessor.

3.A)ASCENDING ORDER

AIM:

To sort the given number in the ascending order using 8085 microprocessor.ALGORITHM:

1. Get the numbers to be sorted from the memory locations.

2. Compare the first two numbers and if the first number is larger than second then I interchange the number.

3. If the first number is smaller, go to step 4

4. Repeat steps 2 and 3 until the numbers are in required orderPROGRAM:ADDRESSOPCODELABELMNEMONICSCOMMENTS

800006,04MVI B,04Initialize B reg with number of comparisons (n-1)

800221,00,81LOOP 3LXI H,8100Initialize HL reg. to 8100H

80050E,04MVI C,04Initialize C reg with no. of comparisons (n-1)

80077ELOOP2MOV A,MTransfer first data to acc.

800823INX HIncrement HL reg. to point next memory location

8009BECMP MCompare M & A

800ADA,12,80JC LOOP1If A is less than M then go to loop1

800D56MOV D,MTransfer data from M to D reg

800E77MOV M,ATransfer data from acc to M

800F2BDCX HDecrement HL pair

801072MOV M,DTransfer data from D to M

801123INX HIncrement HL pair

80120DLOOP1DCR CDecrement C reg

8013C2,07,80JNZ LOOP2If C is not zero go to loop2

801605DCR BDecrement B reg

8017C2,02,80JNZ LOOP3If B is not Zero go to loop3

801A76HLTStop the program

OUTPUT:

INPUTOUTPUT

MEMORY LOCATIONDATAMEMORY LOCATIONDATA

81008100

81018101

81028102

81038103

81048104

FLOWCHART:

YES

NO

YES

NO

NO

YES

NO

YES

RESULT:

Thus the ascending order program is executed and thus the numbers are arranged in ascending order.3.B) DESCENDING ORDER

AIM:

To sort the given number in the descending order using 8085 microprocessor.

ALGORITHM:

1. Get the numbers to be sorted from the memory locations.

2. Compare the first two numbers and if the first number is smaller than second then I interchange the number.

3. If the first number is larger, go to step 4

4. Repeat steps 2 and 3 until the numbers are in required order

PROGRAM:ADDRESSOPCODELABELMNEMONICSCOMMENTS

800006,04MVI B,04Initialize B reg with number of comparisons (n-1)

800221,00,81LOOP 3LXI H,8100Initialize HL reg. to 8100H

80050E,04MVI C,04Initialize C reg with no. of comparisons (n-1)

80077ELOOP2MOV A,MTransfer first data to acc.

800823INX HIncrement HL reg. to point next memory location

8009BECMP MCompare M & A

800AD2,12,80JNC LOOP1If A is greater than M then go to loop1

800D56MOV D,MTransfer data from M to D reg

800E77MOV M,ATransfer data from acc to M

800F2BDCX HDecrement HL pair

801072MOV M,DTransfer data from D to M

801123INX HIncrement HL pair

80120DLOOP1DCR CDecrement C reg

8013C2,07,80JNZ LOOP2If C is not zero go to loop2

801605DCR BDecrement B reg

8017C2,02,80JNZ LOOP3If B is not Zero go to loop3

801A76HLTStop the program

OUTPUT:

INPUTOUTPUT

MEMORY LOCATIONDATAMEMORY LOCATIONDATA

81008100

81018101

81028102

81038103

81048104

FLOWCHART:

NO

YES

NO

YESYES

RESULT:

Thus the descending order program is executed and thus the numbers are arranged in descending order.3.B) LARGEST ELEMENT IN AN ARRAY

AIM:

To find the largest element in an array.

ALGORITHM:

1. Place all the elements of an array in the consecutive memory locations.

2. Fetch the first element from the memory location and load it in the accumulator.

3. Initialize a counter (register) with the total number of elements in an array.

4. Decrement the counter by 1.

5. Increment the memory pointer to point to the next element.

6. Compare the accumulator content with the memory content (next element).

7. If the accumulator content is smaller, then move the memory content (largest element) to the accumulator. Else continue.

8. Decrement the counter by 1.

9. Repeat steps 5 to 8 until the counter reaches zero

10. Store the result (accumulator content) in the specified memory location.

PROGRAM:ADDRESSOPCODELABELMNEMONICSCOMMENTS

800121,00,81LXI H,8100Initialize HL reg. to 8100H

800406,04MVI B,04Initialize B reg with no. of comparisons(n-1)

80067EMOV A,MTransfer first data to acc.

800723LOOP1INX HIncrement HL reg. to point next memory location

8008BECMP MCompare M & A

8009D2,0D,80JNC LOOPIf A is greater than M then go to loop

800C7EMOV A,MTransfer data from M to A reg

800D05LOOPDCR BDecrement B reg

800EC2,07,08JNZ LOOP1If B is not Zero go to loop1

801132,05,81STA 8105Store the result in a memory location.

801476HLTStop the program

OUTPUT:

INPUTOUTPUT

MEMORY LOCATIONDATAMEMORY LOCATIONDATA

81008105

8101

8102

8103

8104

FLOW CHART:

NO

YES

NO

YES

YES

RESULT:

Thus the largest number in the given array is found out.

SMALLEST ELEMENT IN AN ARRAY

AIM:

To find the smallest element in an array.

ALGORITHM:

1. Place all the elements of an array in the consecutive memory locations.

2. Fetch the first element from the memory location and load it in the accumulator.

3. Initialize a counter (register) with the total number of elements in an array.

4. Decrement the counter by 1.

5. Increment the memory pointer to point to the next element.

6. Compare the accumulator content with the memory content (next element).

7. If the accumulator content is smaller, then move the memory content (largest element) to the accumulator. Else continue.

8. Decrement the counter by 1.

9. Repeat steps 5 to 8 until the counter reaches zero

10. Store the result (accumulator content) in the specified memory location.

PROGRAM:ADDRESSOPCODELABELMNEMONICSCOMMENTS

800121,00,81LXI H,8100Initialize HL reg. to 8100H

800406,04MVI B,04Initialize B reg with no. of comparisons(n-1)

80067EMOV A,MTransfer first data to acc.

800723LOOP1INX HIncrement HL reg. to point next memory location

8008BECMP MCompare M & A

8009DA,0D,80JC LOOPIf A is lesser than M then go to loop

800C7EMOV A,MTransfer data from M to A reg

800D05LOOPDCR BDecrement B reg

800EC2,07,08JNZ LOOP1If B is not Zero go to loop1

801132,05,81STA 8105Store the result in a memory location.

801476HLTStop the program

OUTPUT:

INPUTOUTPUT

MEMORY LOCATIONDATAMEMORY LOCATIONDATA

81008105

8101

8102

8103

8104

FLOW CHART:

YES

NO

NO

NO

YES

RESULT:

Thus the smallest number in the given array is found out.

7.PROGRAMMABLE COMMUNICATION INTERFACE WITH 8085

AIM:

To interface 8251 with 8085 to transmit & receive data using interface card.

APPARATUS REQUIRED:

S.NOAPPARATUSSPECIFICATIONQUANTITY

1Microprocessor8085 system1

2Power supply+5V1

3Interface boardVBMB-0041

4BusVXT1

CIRCUIT DIAGRAM

MODE WORD FORMAT:

D7D6

D5

D4 D3 D2 D1 D0

BAUD RATE FACTOR:

D0D1

00

SYNCMODE.

01

ASYNC * 1

10

ASYNC * 16

11

ASYNC * 64

CHARACTER LENGTH:

D2D3

00

5BITS

01

6BITS

10

7BITS

11

8BITS

PARITY CONTROL:

D4D5

X0

NO PARITY

01

ODD PARITY

11

EVEN PARITY

FRAMING CONTROL:

D6D7

00

NOT VALID

01

1 STOP BIT

10

1 STOP BIT

11

2 STOP BIT

COMMAND WORD FORMAT:

EH IR

RTS

ER SBRK RXE DTRTXEN

EH->Enable hunt mode 1-enable

IR->Internal reset

1-Reset

RTS->Request to send

1-enable RTS.

ER->Error reset

1-Reset error flag.

SBRK->Send break character 1-Force txd low & 0-Normal operation.RE->Receive enables

1-Enable. & 0-Disable.

DTR->Data transmit ready

1-Enable

TXEN->Transmit enable

1-EnableSTATUS WORD FORMAT:

DSTSYNDETFEOEPETXEN

RDYRXRDYTXRRDY

DSR ->It indicates that DSR is Zero.

FE ->Framing Error sets when a valid stop bit is not detected and reset by ER Command.

OE -> Overrun error reads the character before it is available. It is reset by ER bit in Command word.

PE -> Parity error, 1-Enable parity error reset by ER bit of command word.

RS 232 C PROGRAM:

ADDRESSOPCODELABELMNEMONICSCOMMENTS

81003E , 36MVI A , 36Mode set for 8253

8102D3 , CEOUT 0CEH

81043E ,0AMVI A,0A

8106D3 , C8OUT 0C8H

81083E ,00MVI A,00

810AD3 ,C8OUT 0C8H

810C3E ,4EMVI A,4EMode for 8251

810ED3 ,C2OUT 0C2H

81103E ,37MVI A, 37Hcommand instruction

8112D3,C2OUT 0C2H

81143E ,41MVI A, 41HSend the data

8116D3 ,C0OUT 0C0H

8118CFRST 1

8200DB, C0IN 0C0HReceive the data

820232 ,50 , 82STA 8250HStore the data

8205CFRST 1

RESULT:

Thus the 8251 is interfaced with 8085 and 8086 and the data was transmitted & received using interface card.

TIMER AND KEYBOARD/DISPLAY INTERFACE USING 8085

TIMER INTERFACEAIM:

To generate a square waveform using timer interface 8253.PIN CONFIGURATION OF 8253:

CONTROL FORMAT:

SC1SC0RL1RL0M2M1M0BCD

SCO

SC1

RL1

RL2

0

0=Counter 0

0

0=Counter latch

0

1=Counter 1

0

1=LSB

1

0=Counter 2

1

0=MSB

1

1=X

1

1=LSB/MSBM2

M1

M0

MODE

0

0

0

0Interrupt on Terminal Count

0

0

1

1Programmable One shot

0

1

0

2Rate Generator

0

1

1

3Square wave generator

BCD:

0=Binary count (16 bit)

1=BCD (11 decoder)

To generate a square wave the control word is formed for a counter 0, using LSB/MSB, Mode3 and a binary count. The Control word is now 36 H.

00110110

Count value = Required Period / Period

PROGRAM FOR 8085

ADDRESSOPCODELABLEMNEMONICSCOMMENTS

81003E, 36STARTMVI A,36HInitialize timer in channel 0 and in mode3

8102D3, CE OUT CEH

81043E, 0AMVI A,0AHMove LSB to counter

8106D3, C8OUT C8H

81083E, 00MVI A,00HMove MSB to counter

810AD3, C8OUT C8H

810C76HLTStop the program

RESULT:

Thus using the timer interface 8253 square waveform is generated.KEYBOARD AND DISPLAY INTERFACE - 8279

AIM:

To interface a keyboard and a display with 8085 microprocessor and write assembly language program for displaying a character and reading the scan code of a key.

DISPLAYING A CHARACTER:

ADDRESSOPCODELABLEMNEMONICSCOMMENTS

81003E, 00AMVI, 00HKeyboard/display mode setup word

8102D3 ,C2OUT C2HOut to the control word register

81043E,CC,00MVI A, CCHClear display control word

8106D3 , C2OUT C2HOut to the control word register

81083E ,90MVI A, 90HControl word to select the row address of the display RAM and auto increment.

810AD3 , C2OUT C2HOut to the control word register

810C3E , 88MVI A, 88Display A

810ED3, C0OUT C0

81103E , FFMVI A, FFBlank the rest of the display

8112D3, C0OUT C0

8114D3 , C0OUT C0

8116D3 , C0OUT C0

8118D3 , C0OUT C0

811AD3 , C0OUT C0

811C76 HLTEnd of the program

TO READ A KEY AND STORE THE KEYCODE IN MEMORY LOCATIONADDRESSOPCODELABLEMNEMONICSCOMMENTS

8100DB, C2LOOPIN C2HRead the FIFO status word

8102E6, 07ANI 07HCheck for a key press

8104CA,00,81JZ LOOP Close not met

81073E, 40MVI A, 40HCommand word for reading RAM

8109D3 , C2OUT C2HOut put to the command word register

810BDB, C0IN C0HRead the FIFO data from the register with address C0

810D32, 00, 42STA 8200HStore the value in a memory

811076HLT End of the program

RESULT:

Thus a keyboard and a display are interfaced with 8085 microprocessor and the assembly language program for displaying a character and reading the scan code of a key is written.ARITHMETIC OPERATIONS USING 8051

Ex.No: 9Date:

,

AIM:

To perform 16-bit addition, 8-bit subtraction, 8-bit multiplication and division using 8051 micro controller.

16 BIT ADDITION:ALGORITHM:

1.Get the LSB of the first operand and add with the LSB of the second operand.

2.Store the LSB of the result.

3.Get the MSB of the first operand and add with the MSB of the second operand.

4.Store the result.

5.Stop the program.PROGRAM:

ADDRESSOPCODELABLEMNEMONICSCOMMENTS

9100C3CLR CClear the carry flag

910174,32MOV A,#DATA L1Move LSB1 to A

910324,CDADD A,#DATA L2Add LSB2 with A

910590,91,50MOV DPTR,#4150Initialize data pointer

9108F0MOVX @DPTR, AAccumulator content is immediately moved to DPTR

9109A3INC DPTRIncrement DPTR

910A74,54MOV A,#DATA M1Move MSB1 to A

910C34,ABADDC A,# DATA M2Add MSB2 to A with carry

910EF0MOVX @DPTR, AAccumulator content is immediately moved to DPTR

910F80hereSJMP here

9110FEStop the program

8 BIT SUBTRACTIONPROGRAM:ADDRESSOPCODELABLEMNEMONICSCOMMENTS

9100C3CLR CClear the carry flag

910174,C2MOV A,#DATA1Move data1 to A

910394,02SUBB A,#DATA2Data2 is subtracted from accumulator

910590,45,00MOV DPTR,#9500Initialize DPTR

9108F0MOVX @DPTR,A Move accumulator content to DPTR

910980hereSJMP here

910AFEStop

8 BIT MULTIPLICATION

PROGRAM:ADDRESSOPCODELABLEMNEMONICSCOMMENTS

910074,FFMOV A,#DATA1Move data1 to A register

910275,F0,FFMOV B, #DATA2Move data2 to B register

9105A4 MUL A,BMultiply A and B register

910690,95,00MOV DPTR, #9500Initialize the DPTR

9109F0MOVX @DPTR,AMove LSB in A to DPTR

910AA3INC DPTRIncrement DPTR

910BE5,F0MOV A,BMove the content of B to A

910DF0MOVX @DPTR,AMove A to DPTR

910E 80HereSJMP here

910F FEStop the program

8BIT DIVISION

PROGRAM:

ADDRESSHEXCODELABELMNEMONICSCOMMENT

910074,65MOV A,#DATA1Move data1 to register A

910275,F0,08MOV B,#DATA2Move data2 to B by B register

910584DIV A,BDivide A by B

910690,95,00MOV DPTR,#9500Move 9500toDPTR

9109F0MOV @DPTR,AMove content A to DPTR

910AA3INC DPTRIncrement DPTR

910BE5,F0MOV A,BMove the content of B to A

910DF0MOVX @DPTR,AMove content in A to DPTR

910E80hereSJMP hereStop the program

910FFE

RESULT:

Thus 16 bit addition, 8 bit subtraction ,8 bit multiplication and division were executed using 8051 microcontroller.

EX.NO: 10TRANSMISSION AND RECEPTION OF A CHARACTER USING 8085 & 8253

DATE :

AIM:

To write a program for the transmission and reception of a character between 8085 and 8253/8251.APPARATUS REQUIRED:1. 8085 Microprocessor Kit2. 8253/8251 Interface Kit3. Power supply 5V4. Keyboard

ALGORITHM:1. Type the transmission program and execute the program

2. Type the reception of a character and execute3. To check the reception of a character.PROGRAM:FOR TRANSMITTING A CHARACTER:ADDRESSOPCODELABELMNEMONICSCOMMENTS

90003E,36MVI A,36HMove immediate data to Acc

9002D3,CEOUT OCEHOut data to control register

90043E,0AMVI A,0AHMove immediate data to Acc

9006D3,C8OUT OC8HOut data to control register

90083E,00MVI A,00HClear A register

900AD3,C8OUT OC8HOut data to control register

900C3E,4EMVI A,4EHMove immediate data to Acc

900ED3,C2OUT OC2HOut data to control register

90103E,37MVI A,37HMove immediate data to Acc

9012D3,C2OUT OC2HOut data to control register

90143E,50MVI A,50HMove immediate data to Acc

9016D3,C0OUT OC0HOut data to control register

9018CFRSTReset

FOR RECEIVING A CHARACTER:ADDRESSOPCODELABELMNEMONICSCOMMENTS

9100DB,C0IN 0C0HMove input data to control reg

910232,50,41STA 9150HStore the result in Accumulator

9105CFRSTReset

RESULT:

Thus the transmission and reception of a character between 8085 and 8253/8251 was executed and verified successfully. EX.NO: 11KEYBOARD AND DISPLAY INTERFACE WITH 8051

DATE :

AIM:

To perform interfacing of keyboard and seven segment display with 8051.APPARATUS REQUIRED:1. 8081 Microprocessor Kit2. 8279 Interface board3. Power supply 5V4. Keyboard

ALGORITHM:1. Assemble the program

2. Execute it and press any key in keyboard and then view the result in the accumulator

3. Before pressing any key in keyboard execute the program once.

KEYBOARD PROGRAM:

ADDRESSOPCODELABELMNEMONICSCOMMENTS

900090,60,61MOV DPTR,#6061Control & status register

900374,12MOV A,#12HControl word

9005F0MOVX @DPTR,AOut to 8279

900674,3EMOV A,#3EHFor freq division

9008F0MOVX @DPTR,AOut to 8279

900974,A0MOV A,#A0HDisplay/write inhibit

900BF0MOVX @DPTR,AOut to 8279

900C90,60,61LOOP1MOV DPTR,#6061

900FE0MOVX A,@DPTRRead the status 8279

901054,07ANL A,#07H

901260,F8JZ 900C (LOOP1)If zero loop back

901490,60,60MOV DPTR,#6060Read key code data

9017E0MOVX A,@DPTR

901854,3FANL A,#3FHSuppress unwant bits

901A12,00,BBLCALL 00 BBHBreak Point

DISPLAY PROGRAM:

ADDRESSOPCODELABELMNEMONICSCOMMENTS

920079,60MOV R1,#60H7 Segment code for 2

920290,60,61MOV DPTR,#6061HControl & status register

920574,12MOV A,#12HControl word

9207F0MOVX @DPTR,AOut to 8279

920874,3EMOV A,#3EHFor freq division

920AF0MOVX @DPTR,AOut to 8279

920B74,A0MOV A,#A0HDisplay/write inhibit

920DF0MOVX @DPTR,AOut to 8279

920E78,08MOV R0,#08H8 Digit count

921074,00MOV A,#00H

921290,60,60MOV DPTR,#6060HData register address

9215F0LOOP1MOVX @DPTR,A

9216D8,FDDJNZ R0,9215H(L1)Clear all digit

9218E9MOV A,R17 Segment code to be displayed

9219F0LOOP2MOVX @DPTR,AOut to 8279

921A80,FDSJMP 9219H(L2)

921C12,00,BBLCALL 00 BBHBreak Point

OUTPUT:

7 SEGMENT CODES FOR 0 TO F:

FC60BAF266D6DE70FE767ECE9CEA9E1E

7 SEGMENT CODE FORMAT:

CharacterDCBAEFGHHex code

011111100FC

10110000060

a

f b

e c

d .h

RESULT:

Thus the interfacing of keyboard and seven segment display with 8051 were executed and verified successfully.

EX.NO: 12ANALOG TO DIGITAL CONVERSION

DATE :

AIM:

To write an assembly language program to perform analog to digital conversion using 8051.APPARATUS REQUIRED:1. 8051 Microprocessor Kit2. ADC Interface Kit3. Power supply 5V4. Keyboard

PROCEDURE:1. Assemble the program2. Vary the pot in the adc chord

3. Execute it and view the output count in the accumulator, which will be displayed in the LCD display

4. Every time you vary the pot, execute the program and measure the count value in the accumulator.

5. Repeat the above step for different inputs in the pot

6. After enough of readings have been taken reduce the pot to its minimum value

7. Switch off the power supply and remove all the connections.ADC PROGRAM:

ADDRESSOPCODELABELMNEMONICSCOMMENTS

900090,60,03MOV DPTR,#6003HOut it in Control register

900374,90MOV A,#90HCWR for port A as I/P port and port C as O/P

9005F0MOVX @DPTR,A

900690,60,02MOV DPTR,#6002HPort c is enabled for WR

900974,FFMOV A,#FFHStart of conversion

900BF0MOVX @DPTR,A

900C90,60,02MOV DPTR,#6002H

900F74,00LOOP1MOV A,#00H

9011F0MOVX @DPTR,A

901290,60,02MOV DPTR,#6002H

901574,FFMOV A,#FFH

9017F0MOVX @DPTR,A

901812,90,22LCALL 9022HDelay routine

901B90,60,00MOV DPTR,#6000HPort A as I/P

901EE0MOV A, @DPTRRead the ADC value

901F12,00,BBLCALL 00 BBHBreak Point

DELAY SUBROUTINE:

ADDRESSOPCODELABELMNEMONICSCOMMENTS

902279,FFMOV A,#FFHDelay Count

902400LOOP1NOPNo Operation

902500NOPNo Operation

902600NOPNo Operation

902700NOPNo Operation

902800NOPNo Operation

902900NOPNo Operation

902A00NOPNo Operation

902BD9,F7DJNZ 9024(LOOP1)

902D22RETReturn To Main Program

OUTPUT:

S.NOANALOG INPUTDIGITAL OUTPUT

1

2

3

4

5

6

RESULT:

Thus the analog to digital conversion using 8051 was executed and verified successfully.

EX.NO: 13DIGITAL TO ANALOG CONVERSION

DATE :

AIM:

To write an assembly language program to perform digital to analog conversion using 8051.APPARATUS REQUIRED:1. 8051 Microprocessor Kit2. DAC Interface Kit3. Power supply 5V4. Keyboard

PROCEDURE:1. Assemble the program2. Give the digital data in the software program itself.

3. Execute it and view the output through the multi-meter at the connector in the dac cord

4. For different values of the digital data you will get different values in the multi-meter

5. Switch off the power supply and remove all the connectionsDAC PROGRAM:

ADDRESSOPCODELABELMNEMONICSCOMMENTS

900074,80MOV A,#80HCWR for all Port O/P

900290,60,03MOV DPTR,#6003HOut it in Control Register

9005F0MOVX @DPTR,A

900674,80MOV A,#80HGiven I/P data

900890,60,01MOV DPTR,#6001HOut Port B

900BF0MOVX @DPTR,A

900C12,00,BBLCALL 00BBHBreak point

OUTPUT:

S.NODIGITAL INPUTANALOG OUTPUT

1

2

3

4

5

RESULT:

Thus the digital to analog conversion using 8051 was executed and verified successfully.

EX.NO: 14DC MOTOR INTERFACING WITH 8051

DATE :

AIM:

To perform stepper motor control using 8051 microcontroller.APPARATUS REQUIRED:1. 8051 Microprocessor Kit2. DC motor interfacing board3. Power supply 5V4. Keyboard

PROCEDURE:1. Assemble the program2. Give the digital data in the software program itself.

3. Execute it and view the output through control by dc motor

4. For different values of the digital data you will get different speed in the motor

5. Switch off the power supply and remove all the connectionsDC MOTOR PROGRAM:

ADDRESSOPCODELABELMNEMONICSCOMMENTS

900074,80MOV A,#80HCWR for all Port O/P

900290,60,03MOV DPTR,#6003HOut it in Control Register

9005F0MOVX @DPTR,A

900674,80MOV A,#80HGiven I/P data

900890,60,01MOV DPTR,#6001HOut Port B

900BF0MOVX @DPTR,A

900C12,00,BBLCALL 00BBHBreak point

RESULT:

Thus the DC motor was interfaced successfully with 8051 and verified.

EX.NO: 15STEPPER MOTOR INTERFACING WITH 8051

DATE :

AIM:

To perform stepper motor control using 8051 microcontroller.APPARATUS REQUIRED:1. 8051 Microprocessor Kit-1

2. Power supply 5V3. Keyboard-1

4. Serial interface cable

5. Stepper motor

6. Stepper motor interfacing boardALGORITHM:1. Store the switching sequence values at memory location

2. Initialize the counter for number of values

3. Get the value and give it to rotate the motor

4. Provide sometime delay using delay routine

5. Check whether all the sequence are given / not repeat step 3 and 4.

PROGRAM:CLOCK WISE DIRECTION:ADDRESSOPCODELABELMNEMONICSCOMMENTS

900090,60,03MOV DPTR,#6003Control port

900374,80MOV A,#80H

9005F0MOVX @DPTR,AAll bits outputs

900690,60,00MOV DPTR,#6000

900974,05LOOP1MOV A,#05HFirst step sequence

900BF0MOVX @DPTR,A

900C12,90,24LCALL 9024(DELAY)Call Delay

900F74,07MOVX A,@ #07HSecond step sequence

9011F0MOVX @DPTR,A

901212,90,24LCALL 9024(DELAY)Delay

901574,06MOV A,#06HThird step sequence

9017F0MOVX @DPTR,A

901812,90,24LCALL 9024(DELAY)Delay

901B74,04MOV A,#04HFourth sequence

901DF0MOVX @DPTR,A

901E12,90,24LCALL 9024(DELAY)Delay

902102,90,09LJMP 9009(LOOP1)Repeat

ANTI CLOCK WISE DIRECTION:ADDRESSOPCODELABELMNEMONICSCOMMENTS

900090,60,03MOV DPTR,#6003Control port

900374,80MOV A,#80H

9005F0MOVX @DPTR,AAll bits outputs

900690,60,00MOV DPTR,#6000

900974,04LOOP2MOV A,#04HFirst step sequence

900BF0MOVX @DPTR,A

900C12,90,24LCALL 9024(DELAY)Call Delay

900F74,06MOVX A,@ #06HSecond step sequence

9011F0MOVX @DPTR,A

901212,90,24LCALL 9024(DELAY)Delay

901574,07MOV A,#07HThird step sequence

9017F0MOVX @DPTR,A

901812,90,24LCALL 9024(DELAY)Delay

901B74,05MOV A,#05HFourth sequence

901DF0MOVX @DPTR,A

901E12,90,24LCALL 9024(DELAY)Delay

902102,90,09LJMP 9009(LOOP1)Repeat

DELAY SUBROUTINE:ADDRESSOPCODELABELMNEMONICSCOMMENTS

902479,0AMOV R1,#0AHChanging the speed of rotation

902674,40LOOP3MOV A,#40H

902800LOOP4NOP

902900NOP

902A00NOP

902B00NOP

902C14DEC A

902D70,F9JNZ 9028(LOOP4)

902FD9,F5DJNZ R1,9026(LOOP3)

903122RET

RESULT:

Thus the stepper motor was interfaced successfully with 8051 and the full step rotation for both clockwise and anti-clockwise was verified.

START

[HL] 8500H

[A] [M]

[A][A]+[M]

[HL][HL]+1

STOP

[HL][HL]+1

[M] [A]

[C] 00H

[M] [C]

[HL][HL]+1

Is there a carry?

Carry ?

[C][C]+1

START

[HL] 8500H

[A] [M]

Is there a borrow?

Borrow ?

[A][A]-[M]

[HL][HL]+1

[C] 00H

[C][C]+1

STOP

[HL][HL]+1

[M] [A]

[M] [C]

[HL][HL]+1

Complement [A]

Add 01H to [A]

[HL] (8500

START

B ( M

[HL] ( [HL]+1

A ( 00

C ( 00

[A] ( [A] + [M]

Is there any carry?

C ( C+1

B ( B-1

IS B=0?

STOP

[HL][HL]+1

[M] [A]

[M] [C]

[HL][HL]+1

B ( 00

M ( A-M

[B] ( [B] +1

IS A