Você está na página 1de 71

MULTI BYTE ADDITION

EXPT. NO : 1 DATE :

1. AIM :Write 8086 program to implement Multi byte addition. 2. COMPONENTS & TOOLS REQUIRED : 2.1 Microprocessor 8086 Trainer Kit, 2.2 Power supply (5V, 3A) 3. THEORY: Generally 8-bits are called a byte, 16-bits are called a word, 32-bits are called a double word. The data more than 4 bytes is called a multi byte. Here, we are adding two multi bytes which are stored at locations 3000H and 3006H. By using the instruction ADC, we can add byte by byte. 4. ALGORITHM: Following steps were required to implement Multi byte addition. 1. SI 3000H 2. DI 3006H 3. BX 2050H 4. Clear AX register 5. Clear CX register 6. Move the no.of element to CX register 7. AL [SI] 8. AL AL + [DI] with carry

9. Store the partial result in [BX] 10. Increment SI, DI and BX 11. Decrement counter 12. If counter is not equal to zero, then jump to step 7

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230

13.

If carry flag is not set, then jump to step 15

14. Increment AH register to store the carry 15. Terminate the program.

5.PROGRAM: ADDR 2000 2003 2006 2009 200B 200D 200F 2011 2013 2015 2016 2017 2018 201A 201C 201E 2020 2022 OPCODE LABEL MNEMONICS BE 00 30 MOV BF 06 30 MOV BB 50 20 MOV 31 C0 XOR 89 C1 MOV B1 06 MOV 8A 04 L1: MOV 12 05 ADC 88 07 MOV 46 INC 47 INC 43 INC FE C9 DEC 75 F3 JNZ 73 02 JNC FE C4 INC 88 27 CC L2: MOV INT OPERANDS COMMENTS SI, 3000H ; Initialize SI to 3000H DI, 3006H ; Initialize DI to 3006H BX, 2050H ; Initialize BX to 2050H AX, AX ; Clear the register AX CX, AX ; Move Accumulator contents to CX CL, 06H ; Load the count register AL, [SI] ; Moving SI contents to Accumulator AL, [DI] ; Add contents of DI to AL and store in AL [BX], AL ; Move Accumulator contents to BX SI ; Increment Source Index DI ; Increment Destination Index BX ; Increment BX register CL ; Decrement CL register L1 ; If not zero jump L1 L2 ; If no carry jump L2 AH ; If carry increment AH register ; Move contents of AH to address location [BX], AH 3 in BX ; Breaking program

6. EXPECTED RESULTS: Example : INPUT [3000] = 56 [3001] = 78 [3002] = 9A [3003] = 0BC [3004] = 0DE OUTPUT [2050] = 12 [2051] = 0F1 [2052] = 0F0 [2053] = 9A [2054] = 0CF

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230

[3005] = 0F0 [3006] = 0BC [3007] = 78 [3008] = 56 [3009] = 0DE [300A] = 0F0 [300B] = 9A

[2055] = 8B [2056] = 01 (CARRY)

7. CONCLUSION: The Multi Byte Addition is performed by using 8086 instructions. 8. PRECAUTIONS: 1. Give connections carefully such as Keyboard, Flat Ribbon cable if any and power supply etc. 2. Switch on the power supply only after giving all the connections. 3. Handle the Trainer kits carefully. 9. VIVA -VOCE QUESTIONS: 1. What is a multi byte? 2. Which registers are used as pointers? 3. On what condition the carry flag is set? 4. What are the commands to perform this program on the kit? 5. What is the difference between conditional and unconditional jump instructions? 6. What are the flags available in 8086?

MULTI BYTE SUBTRACTION

EXPT. NO : 2 DATE :

1. AIM :Write 8086 program to implement Multi byte Subtraction. 2. COMPONENTS & TOOLS REQUIRED: 2.1 Microprocessor 8086 Trainer Kit, 2.2 Power supply (5V, 3A) 3. THEORY: Generally 8-bits are called a byte, 16-bits are called a word and 32-bits are called a double word. The data more than 4 bytes is called a multi byte. Here, we are subtracting two multi

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230

bytes which are stored at locations 3000H and 3006H. By using the instruction SBB, we can subtract byte by byte. 4. ALGORITHM: Following steps were required to implement Multi byte addition. 1. SI 3000H 2. DI 3006H 3. BX 2050H 4. Clear AX register 5. Clear CX register 6. Move the no.of element to CX register 7. AL [SI] 8. AL AL - [DI] with borrow

9. Store the partial result in [BX] 10. Increment SI, DI and BX 11. Decrement counter 12. If counter is not equal to zero, then jump to step 7

13.

If carry flag is not set, then jump to step 15

14. Increment AH register to store the carry 15. Terminate the program.

5.PROGRAM: ADDR OPCODE LABEL MNEMONICS OPERANDS COMMENTS 2000 BE 00 30 MOV SI, 3000H ; Initialize SI to 3000H Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 4

2003 2006 2009 200B 200D 200F 2011 2013 2015 2016 2017 2018 201A 201C 201E

BF 06 30 BB 50 20 31 C0 89 C1 B1 06 8A 04 1A 05 88 07 46 47 43 FE C9 75 F3 73 02 FE C4

L1:

MOV MOV XOR MOV MOV MOV SBB MOV INC INC INC DEC JNZ JNC INC

DI, 3006H BX, 2050H AX, AX CX, AX CL, 06H AL, [SI] AL, [DI] [BX], AL SI DI BX CL L1 L2 AH [BX], AH 3

; Initialize DI to 3006H ; Initialize BX to 2050H ; Clear the register AX ; Move Accumulator contents to CX ; Load the count register ; Moving SI contents to Accumulator ; Subtract contents of DI to AL and store in AL ; Move Accumulator contents to BX ; Increment Source Index ; Increment Destination Index ; Increment BX register ; Decrement CL register ; If not zero jump L1 ; If no carry jump L2 ; if carry increment AH register ; Move contents of AH to address location in BX ; Breaking program

2020 88 27 2022 CC

L2:

MOV INT

6. EXPECTED RESULTS: Example : INPUT [3000] = 56 [3001] = 78 [3002] = 9A [3003] = 0BC [3004] = 0DE [3005] = 0F [3006] = 0BC [3007] = 78 [3008] = 56 [3009] = 0DE [300A] = 0F0 [300B] = 9A OUTPUT [2050] = 9A [2051] = 0FF [2052] = 43 [2053] = 0DE [2054] = 0ED [2055] = 74 [2056] = 01 (borrow)

7. CONCLUSION: The Multi Byte Subtraction is performed by using 8086 instructions. 8. PRECAUTIONS: 1. Give connections carefully such as Keyboard, Flat Ribbon cable if any and power supply etc.

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230

2. Switch on the power supply only after giving all the connections. 2. Handle the Trainer kits carefully. 9. VIVA -VOCE QUESTIONS:
1. What

are the commands to perform this program on the kit?

2. Which registers are used as pointers? 3. On what condition the carry flag is set? 4. What are the commands to perform this program on the kit? 5. What is the difference between conditional and unconditional jump instructions? 6. What are the flags available in 8086? MULTI PLICATION

EXPT. NO : 3 DATE :

1. AIM :Write 8086 program to implement Multiplication (unsigned & signed). 2. COMPONENTS & TOOLS REQUIRED: 2.1 Microprocessor 8086 Trainer Kit, 2.2 Power supply (5V, 3A) 3. THEORY: In 8086, Direct instruction is available to multiply two 8 bit or two 16 bit numbers. But where as in 8085 the direct instruction is not available to multiply two 8 bit or two 16 bit numbers. After multiplication, if it is 16 bit multiplication, the result will be stored in AX and DX registers and if it is 8 bit multiplication, the result will be stored in AX register. For signed numbers we have to use IMUL instruction. 4. ALGORITHM: 1. AX [2500H] 2. BX [2502H] 3. Multiply contents of Accumulator with contents of BX register 4. Store the result ; [2050] AX 5. and [2052] DX 5. Terminate program 5.PROGRAM: MULTIPLICATION (UNSIGNED) ADDR OPCODE LABEL MNEMONICS OPERANDS COMMENTS 6

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230

2000 A1 00 25 2003 8B 1E 02 25 2007 F7 E3 2009 A3 50 20 200C 89 16 52 20 2010 CC 6.1 EXPECTED RESULTS: Example : INPUT [2500] = 0FF [2501] = 0FF [2502] = 0FF [2503] = 0FF

MOV MOV MUL MOV MOV INT

AX, [2500H] ; Moving contents of 2500h to acc. BX, [2502H] ; Moving contents 2502H to BX BX ; Multiply AX with contents of BX & result in AX,DX [2050H], AX ; Move contents of AX is to store in 2050 location [2052H], DX ; Move contents of DX is store in 2052 3 location ; Breaking Interrupt

OUTPUT [2050] = 01 [2051] = 00 [2052] = 0FE [2053] = 0FF

MULTIPLICATION (SIGNED) ADDR OPCODE 2000 A1 00 25 2003 8B 1E 02 25 2007 F7 EB 2009 A3 50 20 200C 89 16 52 20 2010 CC 6.2 EXPECTED RESULTS: Example : INPUT [2500] = 0FE [2501] = 0FF [2502] = 07 OUTPUT [2050] = 0F2 [2051] = 0FF [2052] = 0FF [2053] = 0FF LABEL MNEMONICS OPERANDS COMMENTS MOV AX, [2500H] ; Moving contents of 2500h to MOV IMUL MOV MOV INT accumulator BX, [2502H] ; Moving contents 2502H to BX BX ; Signed multiplication of contents AX & BX [2050H], AX ; Move contents of AX is to store in 2050 location [2052H], DX ; Move contents of DX is store in 2052 3 location ; Breaking Interrupt

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230

[2503] = 00 7. CONCLUSION: The unsigned and signed numbers multiplication is performed by using 8086 instructions. 8. PRECAUTIONS: 1. Give connections carefully such as Keyboard, Flat Ribbon cable if any and power supply etc. 2. Switch on the power supply only after giving all the connections. 3. Handle the Trainer kits carefully. 9. VIVA -VOCE QUESTIONS: 1. What are the commands to perform this program on the kit? 2. What is the range of 8 bit signed numbers? 3. What is the range of 16 bit signed numbers? 4. In which registers the 32 bit result will be stored after multiplicdation? 5. What is the name of the instruction for signed multiplication? 6. What type of segments are used in 8086? 7. How many units the 8086 architecture consists of?

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230

DIVISION

EXPT. NO : 4 DATE :

1. AIM :Write 8086 program to implement division (unsigned & signed). 2. COMPONENTS & TOOLS REQUIRED: 2.1 Microprocessor 8086 Trainer Kit, 2.2 Power supply (5V, 3A) 3. THEORY: In 8086, Direct instruction is available to divide two 8 bit or two 16 bit numbers. But where as in 8085 the direct instruction is not available to divide two 8 bit or two 16 bit numbers. After division, if it is 16 bit / 8 bit, the quotient will be stored in AL and reminder will be stored in AH register and if it is 32 bit / 16 bit division, the quotient is stored in AX register and the reminder is stored in DX register. For signed numbers we have to use IDIV instruction. 4. ALGORITHM: 1. AX [2500H] 2. BX [2502H] 3. DX [2504H] 4. Divide contents of Accumulator with contents of BX register 5. [2050] AX ; QUOTIENT 6. [2052] DX; REMINDER 6. Terminate program 5.PROGRAM: DIVISION [32-BIT / 16-BIT] (UNSIGNED) ADDR 2000 2003 2007 200B OPCODE LABEL MNEMONICS A1 00 25 MOV 8B 16 02 25 MOV 8B 1E 04 25 MOV F7 F3 DIV MOV MOV INT OPERANDS COMMENTS AX, [2500H] ; Moving contents of 2500h to acc. DX, [2502H] ; Moving contents of 2502h to DX BX, [2504H] ; Moving contents 2504H to BX BX ; Divide DX: AX / BX & store result in AX,DX [2050H], AX ; Move contents of AX is to store in 2050 location [2052H], DX ; Contents of DX is store in 2052 loc. 3 ; Breaking Interrupt

200D A3 50 20 2010 89 16 52 20 2014 CC 6.1 EXPECTED RESULTS:

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230

Example : INPUT [2500] = 01 [2501] = 00 [2502] = 0FE [2503] = 0FF [2504] = 0FF [2505] = 0FF OUTPUT [2050] = 0FF [2051] = 0FF [2052] = 00 [2053] = 00

DIVISION [32-BIT / 16-BIT] (SIGNED) ADDR OPCODE 2000 A1 00 25 2003 8B 16 02 25 2007 8B 1E 04 25 200B F7 FB 200D A3 50 20 2010 89 16 52 20 2014 CC LABEL MNEMONICS OPERANDS COMMENTS MOV AX, [2500H] ; Moving contents of 2500h to MOV MOV IDIV MOV MOV INT accumulator DX, [2502H] ; Moving contents of 2502h to DX BX, [2504H] ; Moving contents 2504H to BX BX ; Signed divide DX: AX / BX & store result in AX,DX [2050H], AX ; Move contents of AX is to store in 2050 location [2052H], DX ; Move contents of DX is store in 2052 3 location ; Breaking Interrupt

6.2 EXPECTED RESULTS: Example : INPUT [2500] = 0F2 [2501] = 0FF [2502] = 0FF OUTPUT [2050] = 0FE [2051] = 0FF [2052] = 00

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 10

[2503] = 0FF [2504] = 07 [2505] = 00

[2053] = 00

7. CONCLUSION: The unsigned & signed numbers division is performed by using 8086 instructions. 8. PRECAUTIONS: 1. Give connections carefully such as Keyboard, Flat Ribbon cable if any and power supply etc. 2. Switch on the power supply only after giving all the connections. 3. Handle the Trainer kits carefully. 9. VIVA -VOCE QUESTIONS: 1. What are the commands to perform this program on the kit? 2. What is the range of 8 bit signed numbers? 3. What is the range of 16 bit signed numbers? 4. In which registers the QUOTIENT AND REMINDER after DIVISION? 5. What is the name of the instruction for signed division? 6. What type of segments are used in 8086?

ADDITION OF TWO ASCII NUMBERS

EXPT. NO : 5 DATE :

1. AIM :Write 8086 program to implement addition of two ASCII numbers. 2. COMPONENTS & TOOLS REQUIRED: 2.1 Microprocessor 8086 Trainer Kit, 2.2 Power supply (5V, 3A)

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 11

3. THEORY: Generally, when you press a key on keyboard the keys will be encoded in the form of ASCII codes. So we need to know the arithmetic operations of ASCII numbers. For ex: The ASCII value of 0 is 30, ASCII value of 1 is 31 and so on. The ASCII value of a is 41, ASCII value of b is 42 and so on. When we deal with ASCII addition, we should through with the ASCII related instructions like AAA. AAA is ASCII Adjust after addition. ALGORITHM: 1. Clear accumulator 2. AL [2500H] 3. BL [2501H] 4. Add AL with BL 5. ASCII adjustment 6. Store the result in 2050H location 7. Terminate the program 5.PROGRAM: ADDR 2000 2002 2005 2009 OPCODE LABEL MNEMONICS B4 00 MOV A0 00 25 MOV 8A 1E 01 25 MOV 00 D8 ADD AAA MOV INT OPERANDS COMMENTS AH, 00H ; Clear accumulator AL, [2500H] ; Load contents of 2500h to AL BL, [2501H] ; Loading contents 2501H to BL AL, BL ; Add contents of BL to AL and store result in AL ; ASCII adjustment after addition [2050H], AX ; Store result in AX in to 2050 location 3 ; Breaking Interrupt

200B 37 200C A3 50 20 200F CC

6. EXPECTED RESULTS: Example : INPUT [2500] = 37 [2501] = 35 7. CONCLUSION: The Addition of two ASCII numbers is performed by using 8086 instructions. 8. PRECAUTIONS: 1. Give connections carefully such as Keyboard, Flat Ribbon cable if any and power supply etc. OUTPUT [2050] = 02 [2051] = 01

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 12

2. Switch on the power supply only after giving all the connections. 3. Handle the Trainer kits carefully. 9. VIVA -VOCE QUESTIONS: 1. What are the commands to perform this program on the kit? 2. What is the ASCII value of C? 3. To which numbers the keyboard keys are encoded? 4. What is the way to convert an ASCII number into Hex number? 5. How we convert from Hex number to ASCII number? 6. Is there any difference in the ASCII numbers of Capital letters and Small letters? 7. What is AAA instruction?

SUBTRACTION OF 2 ASCII NUMBERS

EXPT. NO : 6 DATE :

1. AIM :Write 8086 program to implement Subtraction of two ASCII numbers. 2. COMPONENTS & TOOLS REQUIRED: 2.1 Microprocessor 8086 Trainer Kit, 2.2 Power supply (5V, 3A) 3. THEORY: Generally, when you press a key on keyboard the keys will be encoded in the form of ASCII codes. So we need to know the arithmetic operations of ASCII numbers.

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 13

For ex: The ASCII value of 0 is 30, ASCII value of 1 is 31 and so on. The ASCII value of a is 41, ASCII value of b is 42 and so on. When we deal with ASCII Substration, we should through with the ASCII related instructions like AAS. AAS is ASCII Adjust after subtraction. 4. ALGORITHM: 1. Clear accumulator 2. AL [2500H] 3. BL [2501H] 4. Subtract AL to BL 5. ASCII adjustment 6. Store the result in 2050H location 7. Terminate the program 5.PROGRAM: ADDR OPCODE LABEL MNEMONICS 2000 B4 00 MOV 2002 A0 00 25 MOV 2005 8A 1E 01 25 MOV 2009 28 D8 SUB 200B 3F 200C A3 50 20 200F CC AAS MOV INT OPERANDS COMMENTS AH, 00H ; Clear accumulator AL, [2500H] ; Load contents of 2500h to AL BL, [2501H] ; Loading contents 2501H to BL AL, BL ; Subtract BL to AL and store result in AL ; ASCII adjustment after subtraction [2050H], AX ; Store result in AX in to 2050 location 3 ; Breaking Interrupt

6. EXPECTED RESULTS: Example : INPUT [2500] = 39 [2501] = 35 7. CONCLUSION: The Subtraction of two ASCII numbers is performed by using 8086 instructions. 8. PRECAUTIONS: 1. Give connections carefully such as Keyboard, Flat Ribbon cable if any and power supply etc. 2. Switch on the power supply only after giving all the connections. 3. Handle the Trainer kits carefully. OUTPUT [2050] = 04 [2051] = 00

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 14

9. VIVA -VOCE QUESTIONS: 1. What are the commands to perform this program on the kit? 2. What is the ASCII value of C? 3. To which numbers the keyboard keys are encoded? 4. What is the way to convert an ASCII number into Hex number? 5. How we convert from Hex number to ASCII number? 6. Is there any difference in the ASCII numbers of Capital letters and Small letters? 7. What is AAS instruction?

SHIFT & ROTATE

EXPT. NO : 7 DATE :

1. AIM :Write 8086 program to implement Multi byte Subtraction. 2. COMPONENTS & TOOLS REQUIRED: 2.1 Microprocessor 8086 Trainer Kit, 2.2 Power supply (5V, 3A) 3. THEORY: Shift and rotate operations are the bit wise logical operations. If we want to shift one bit only directly we can write SHL Al,01H. If we want to shift more than one bit we have to use the counter CL. The same case is applicable for rotate operations. We can use these instructions when we want to check the carry flag and when we want to check particular bit in the specified register. There are types of shift operations and rotate operations both with carry and with out carry. For ex RCR means Rotate with carry.

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 15

4. ALGORITHM: 1. AX [2500H] 2. Count will be stored in count register 3. Rotate left to the contents of accumulator 4. Store the result 5. Terminate the program 5.PROGRAM: ADDR OPCODE LABEL MNEMONICS OPERANDS COMMENTS 2000 A1 00 25 MOV AX, [2500H] ; Moving contents of 2500h to 2003 B1 04 2005 D3 C0 2007 A3 50 20 200A CC MOV ROL MOV INT CL, 04 AX, CL accumulator ; Moving contents to Count register ; Rotate left the contents of accumulator

by 4 times [2050H], AX ; Move contents of AX is to store in 2050 3 location ; Breaking Interrupt

6. EXPECTED RESULTS: Example : INPUT [2500] = 12 [2501] = 34 OUTPUT [2050] = 23 [2051] = 41

7. CONCLUSION: The given number is shift and rotate performed by using 8086 instructions. 8. PRECAUTIONS: 1. Give connections carefully such as Keyboard, Flat Ribbon cable if any and power supply etc. 2. Switch on the power supply only after giving all the connections. 3. Handle the Trainer kits carefully. 9. VIVA -VOCE QUESTIONS: 1. What are the commands to perform this program on the kit? 2. Explain RCR instruction?

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 16

3. Explain ROR instruction? 4. Explain ROL instruction? 5. Explain SHL instruction? 6. Explain SHR instruction? 7. If the count is more than one , how we can write the shift or rotate instruction?

PACKED BCD TO UNPACKED BCD

EXPT. NO : 8 DATE :

1. AIM :Write 8086 program to implement Multi byte Subtraction. 2. COMPONENTS & TOOLS REQUIRED: 2.1 Microprocessor 8086 Trainer Kit, 2.2 Power supply (5V, 3A) 3. THEORY: BCD means Binary Code Decimal. Binary Coded Decimal numbers are the numbers which are decimal numbers from 0 to 9, but they are represented in binary form. Generally we deal with decimal numbers rather than Hexa decimal numbers. So it is necessary to know how to convert from Packed BCD to unpacked BCD. When we are converting we use masking operations using AND instructions. 4. ALGORITHM: 1. AL [2050H]

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 17

2. BL AL 3. mask lower nibble 4. Rotate BL 4 times 5. Store the partial result in 2060 location 2. mask upper nibble 3. store the result in 2061 location. 4. terminate the program. 5.PROGRAM: ADDR OPCODE 2000 A0 50 20 2003 88 C3 2005 80 E3 F0 2008 200A 200C 2010 B1 04 D2 CB 88 1E 60 20 24 0F LABEL MNEMONICS MOV MOV AND MOV ROR MOV AND MOV INT OPERANDS COMMENTS AL, [2050H] ; Move 2050h contents to AL BL, AL ; Move AL contents to BL BL, 0F0H ; AND BL contents with 0F0 and store result in BL CL, 04H ; Load count register with 04h BL, CL ; Rotate right BL by 04h times [2060H], BL ; Moving contents of BL to 2060H AL, 0FH ; AND AL with 0FH and store result in AL [2061H], AL ; Moving contents of AL to 2061H 3 ; Breaking interrupt

2012 A2 61 20 2015 CC 6. EXPECTED RESULTS: Example : INPUT [2050] = 59

OUTPUT [2060] = 05 [2061] = 09

7. CONCLUSION: The Packed BCD to unpacked BCD is performed by using 8086 instructions. 8. PRECAUTIONS: 1. Give connections carefully such as Keyboard, Flat Ribbon cable if any and power supply etc. 2. Switch on the power supply only after giving all the connections. 3. Handle the Trainer kits carefully.

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 18

9. VIVA -VOCE QUESTIONS: 1. What are the commands to perform this program on the kit? 2. What numbers the BCD numbers consists of? 3. Give an example for Packed BCD number? 4. Give an example for unpacked BCD number? 5. What is the difference between AND and TEST instruction? 6. What is the procedure to convert from Packed BCD to Unpacked BCD? 7. What is the difference between BCD and Hex number?

DISPLAY STRING ON THE MONITOR

EXPT. NO : 1 DATE :

1. AIM :Write an ALP to implement Display string on the monitor. 2. COMPONENTS & TOOLS REQUIRED : 2.1 Computer system, 2.2 MASM / TASM SOFTWARE 3. PROGRAM: DATA SEGMENT MESSAGE DB ' COLLEGE $ ' DATA ENDS CODE SEGMENT ASSUME CS: CODE, DS: DATA START: MOV AX, DATA MOV DS, AX LEA DX, MESSAGE MOV AH, 09H INT 21H MOV AH, 4CH ;Initialize DS register ;EA of message will move to DX register ;to display a string ;DOS Interrupt service routine ;return to DOS prompt

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 19

INT 21H CODE ENDS END START ; end of code segment

1. EXPECTED RESULTS: GOOD MORNING should be displayed on the screen. 2. CONCLUSION: Sting Good morning is displayed on the screen. 6. PRECAUTIONS: 1. Give connections carefully such as Keyboard, Flat Ribbon cable if any and power supply etc. 2. Switch on the power supply only after giving all the connections. 3. Handle the Trainer kits carefully. 7. VIVA QUESTIONS: a. What the function code 0A indicates? b. What the function code 09 indicates? c. What the function code 01indicates? d. In which register we have to move the function codes? e. What is the interrupt that we have to use for DOS operations? f. Which register we have to use to store the address of the source?

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 20

g. Is there any need to initialize the DS registers? h. How many segments the 8086 memory is divided?

MOVE BLOCK OF DATA

EXPT. NO : 2 DATE :

1. AIM : Write an ALP to implement Move Block of data from one location to another location . 2. COMPONENTS & TOOLS REQUIRED : 2.1 Computer system, 2.2 MASM / TASM SOFTWARE 3. PROGRAM: DATA SEGMENT COUNT DB 05H ARRAY DB 45H, 65H, 4BH, 8EH, 0BCH DEST DB 10 DUP(0) DATA ENDS CODE SEGMENT ASSUME CS: CODE, DS: DATA, ES: DATA START: MOV AX, DATA MOV DS, AX MOV ES, AX MOV CL, COUNT ; Loading count register by 05H

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 21

LEA SI, ARRAY LEA DI, DEST REP MOVSB INT 3 CODE ENDS END START

; Load EA of array to Source Index ; Load EA of destination to Destination Index ; Move Source data to destination ; Breaking Interrupt

4.

EXPECTED RESULTS: 0000: 45H, 65H, 4BH, 8EH, 0BCH 0006: 45H, 65H, 4BH, 8EH, 0BCH

5.

CONCLUSION: The data from 0000 location is moved to the location 0006H.

6. PRECAUTIONS: 1. Give connections carefully such as Keyboard, Flat Ribbon cable if any and power supply etc. 2. Switch on the power supply only after giving all the connections. 3. Handle the Trainer kits carefully. 7. VIVA QUESTIONS: 1. what we store in data segment? 1. What the function code 0A indicates? 2. What the function code 09 indicates? 3. What the function code 01indicates? 4. In which register we have to move the function codes? 5. What is the interrupt that we have to use for DOS operations? 6. Which register we have to use to store the address of the source?

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 22

7. Is there any need to initialize the DS registers? 8. What is the way to move block without using REP MOVSB?

STRING COMPARISION

EXPT. NO : 3 DATE :

1. AIM :Write an ALP to implement String comparison (Pass word checking) . 2. COMPONENTS & TOOLS REQUIRED : 2.1 Computer system, 2.2 MASM / TASM SOFTWARE 3. PROGRAM: DATA SEGMENT PASSWORD DB 'LBRCE' NEWSTR DB 'LBECE' (or) 'LBRCE' CNT DB 05H STR1 DB 'THE GIVEN STRING IS VALID$' STR2 DB 'THE GIVEN STRING IS INVALID$' DATA ENDS CODE SEGMENT ASSUME CS: CODE, DS: DATA, ES: DATA START: MOV AX, DATA

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 23

MOV DS, AX MOV ES, AX MOV CL, CNT LEA SI, PASSWORD LEA DI, NEWSTR REP CMPSB JNZ L1 LEA DX, STR1 JMP L2 L1: L2: LEA DX, STR2 MOV AH, 09H INT 21H INT 3 CODE ENDS END START

4.

EXPECTED RESULTS: INPUT: LBRCE LRBCE OUTPUT: THE GIVEN STRING IS INVALID INPUT: LBRCE LBRCE OUTPUT: THE GIVEN STKRING IS VALID

5.

CONCLUSION: The given two strings are compared and displayed the GIVEN STRING IS EQUAL if they are equal.

6. PRECAUTIONS: 1. Give connections carefully such as Keyboard, Flat Ribbon cable if any and power supply etc. 2. Switch on the power supply only after giving all the connections. 3. Handle the Trainer kits carefully.

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 24

7. VIVA-VOCE QUESTIONS: 1. what we store in data segment? 2. What the function code 0A indicates? 3. What the function code 09 indicates? 4. What the function code 01indicates? 5. In which register we have to move the function codes? 6. What is the interrupt that we have to use for DOS operations? 7. Which register we have to use to store the address of the source? 8. Is there any need to initialize the DS registers? 9. What is the use of SI and DI registers?

READ A CHARACTER FROM KEYBOARD

EXPT. NO : 4 DATE :

1. AIM :Write an ALP to implement read a character from key board with or without echo. 2. COMPONENTS & TOOLS REQUIRED : 2.1 Computer system, 2.2 MASM / TASM SOFTWARE 3. THEORY: 01h is the function code to read the key from keyboard with echo. This function code will be stored in the AH register. The characters (ASCII characters) which we typed will be stored in the AL register and also displays on the screen. If AL=00H, the function call must be invoked again to read an extended ASCII character. This function call automatically Echo and whatever is typed on the video screen. 08H is the function code to read the key from keyboard without echo. The 08H code will be stored in the AH register. The character (ASCII characters) which we typed will be stored in the AL register.

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 25

The standard input device can be assigned as either the keyboard or the com port. This function respond to a control break. A control break causes INT23H to execute. 09H is the function code to display a character string. This 09H will be stored in AH register. The starting address of the string which we type through keyboard will be stored in DS:DX register. The character string must end with an ASCII $. The character string can be of any length and may contains control character such as carriage return 0DH) and line feed (0AH).

4. PROGRAM: READ A CHARACTER FROM KEY BOARD DATA SEGMENT MES DB 0AH, 0DH DATA ENDS CODE SEGMENT ASSUME CS: CODE, DS: DATA START: MOV AX, DATA MOV DS, AX LEA DI, BUFFER MOV AL, 01H L3: CMP AL, 0DH JNE L1 JMP L2 L1: MOV AH, 01H (or) 08H INT 21H MOV [DI], AL INC DI ;Initialize the DS register ;destination pointer to buffer ;to read character to AL register ;while AL=carriage return, read character ;when ZF is not set jump to label L1 ;when ZF is set jump to label L2 ;01 is read to char. with echo, 08 is without echo ;DOS interrupt service routine ;move AL to DI register ;Incrementing DI ;for carriage return and line feed BUFFER DB 0FH DUP(?) ;to store the I/p character string

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 26

JMP L3 L2: MOV BYTE PTR[DI], '$' LEA DX, MES MOV AH, 09H INT 21H MOV AH, 4CH INT 21H CODE ENDS END START ;end of code segment ;$ is store end of the character ; display string ;display string function code ;DOS interrupt service routine ; return to dos prompt

5. EXPECTED RESULTS: i) With Echo: INPUT: OUTPUT: ENGINEERING COLLEGE ENGINEERING COLLEGE

ii) With out Echo: INPUT: OUTPUT: ENGINEERING COLLEGE

6. CONCLUSION: The entered keys from keyboard are displayed on the screen with echo and without echo. 7. PRECAUTIONS: 1. Give connections carefully such as Keyboard, Flat Ribbon cable if any and power supply etc. 2. Switch on the power supply only after giving all the connections. 3. Handle the Trainer kits carefully. 8. VIVA -VOCE QUESTIONS: 1. 2. 3. 4. 5. What is meant by the function code 01H? What is meant by the function code 0aH? What is meant by the function code 08H? What is meant by the function code 09H? What the $ indicates at the end of string?

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 27

6. 7. 8. 9.

What is with echo? What is without echo? What are the commands to execute this program? What is INT 21H?

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 28

REVERSE THE STRING

EXPT. NO : 5 DATE :

1. AIM :Write an ALP to implement Reverse the string. 2. COMPONENTS & TOOLS REQUIRED : 2.1 Computer system, 2.2 MASM / TASM SOFTWARE 3. PROGRAM: REVERSE THE STRING DATA SEGMENT MAX EQU 0050H STR DB MAX DUP(?) REV DB MAX DUP(?) DATA ENDS CODE SEGMENT ASSUME CS: CODE, DS: DATA START: MOV AX, DATA MOV DS, AX MOV AH, 3FH MOV BX, 0 MOV CX, MAX MOV DX, OFFSET STR INT 21H AND AX, AX JZ DONE MOV CX, AX PUSH CX MOV BX, OFFSET STR MOV SI, OFFSET REV ADD SI, CX DEC SI ; Reverse string ; Point to the end of the reverse string buffer ; Initialize DS register ; DOS read from handle function ; Standard input handle ; Read up to max. number of char. to reverse ; Store the string here ; Get the string ; Were any characters read ; No so done ; Put string length in CX ; Save the string length

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 29

RS:

MOV AL, [BX] MOV [SI], AL INC BX DEC SI LOOP RS POP CX MOV AH, 40H MOV BX, 1 MOV DX, OFFSET REV INT 21H

; Get the next character ; Store the next character in reverse order ; Point to next character ; Point to previous location in reverse buffer ; move next character, if any ; get back the string length ; DOS write, from handle function ; Standard output handle ; Print the reverse string ; DOS terminate program function ; Terminate the program

DONE: CODE ENDS END START

MOV AH, 4CH INT 21H

4. EXPECTED

RESULTS:

INPUT: OUTPUT:

FAITH HTIAF

5. CONCLUSION: The given string entered from keyboard is reversed and displayed on the screen. 6. PRECAUTIONS: 1. Give connections carefully such as Keyboard, Flat Ribbon cable if any and power supply etc. 2. Switch on the power supply only after giving all the connections. 3. Handle the Trainer kits carefully. 7. VIVA-VOCE QUESTIONS: a. b. c. d. e. f. g. h. i. What is the function of SI and DI regesters? meant by the function code 01H? What is meant by the function code 0aH? What is meant by the function code 08H? What is meant by the function code 09H? What the $ indicates at the end of string? Explain what is LOOPE instruction? Explain what is LOOPNE instruction? What is the prefix to repeat loop?

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 30

BCD TO HEX CONVERSION

EXPT. NO : 6 DATE :

1. AIM :Write an ALP to implement BCD to HEX conversion using procedure. 2. COMPONENTS & TOOLS REQUIRED : 2.1 Computer system, 2.2 MASM / TASM SOFTWARE 3. PROGRAM: CONVERT BCD TO HEX USING PROCEDURE (USING STACK) DATA SEGMENT BCD_INPUT DB 37H BIN_VALUE DB ? DATA ENDS STACK_SEG SEGMENT STACK DW 100 DUP (0) DW 100 DUP (0) TOP_STACK LABEL WORD STACK_SEG ENDS CODE SEGMENT ASSUME CS: CODE, DS: DATA, SS: STACK_SEG START: MOV AX, DATA MOV DS, AX MOV AX, STACK_SEG MOV SS, AX MOV SP, OFFSET TOP_STACK MOV AL, BCD_INPUT PUSH AX ; BCD number in AL register ; Initialize DS register

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 31

CALL BCD_BIN POP AX MOV BIN_VALUE, AL INT 3 ; Store the result ; Return to DOS

BCD_BIN PROC NEAR PUSHF PUSH AX PUSH BX PUSH CX PUSH BP MOV BP, SP MOV AX, [BP+12] MOV BL, AL AND BL, 0FH AND AL, 0F0H MOV CL, 04 ROR AL, CL MOV BH, 0AH MUL BH ADD AL, BL MOV [BP+12], AX POP BP POP CX POP BX POP AX POPF RET BCD_BIN ENDP CODE ENDS END START ; Restore registers ; Move upper BCD digit to ; low nibble position for multiply ; Load conversion factor in BH ; Multiply upper BCD digit in AL by 0AH ; Add lower BCD digit to mul ; Keep copy in BL register ; Separate upper nibble ; Save registers

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 32

4. EXPECTED RESULTS: BCD INPUT BIN OUTPUT 37H 25H

5. CONCLUSION: The BCD input is converted into Binary information. 6. PRECAUTIONS: 1. Give connections carefully such as Keyboard, Flat Ribbon cable if any and power supply etc. 2. Switch on the power supply only after giving all the connections. 3. Handle the Trainer kits carefully. 7. VIVA-VOCE QUESTIONS: 1. What is a BCD number and give example? 2. What is the binary information for the BCD number 77H? 3. What is the range of single digit number in BCD? 4. What is the range of single digit number in Hex numbers? 5. Write the instructions to rotate AL 4 times? 6. Write the instructions to shift AL 4 times with carry? 7. How we can mask the lower nibble in AL register? 8. How we can mask the upper nibble in AL register? 9. What are the advantages of procedures? 10. What is the use of saving registers in the procedures?

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 33

HEX TO BCD CONVERSION

EXPT. NO : 7 DATE :

1. AIM :Write an ALP to implement HEX to BCD conversion. 2. COMPONENTS & TOOLS REQUIRED : 2.1 Computer system, 2.2 MASM / TASM SOFTWARE 3. PROGRAM: ;HEX TO BCD CONVERSION DATA SEGMENT HEX DB 25H BCD EQU 00H DATA ENDS CODE SEGMENT ASSUME CS: CODE, DS: DATA START: MOV AX, DATA MOV DS, AX MOV AL, HEX MOV AH, 00H MOV BH, 0AH DIV BH MOV CL, 04H ROL AL, CL ADD AL, AH MOV AH, HEX INT 3 CODE ENDS END START 4. EXPECTED RESULTS: ; Rotate Quotient AL 4 times left ; Add reminder to AL ; Store the BCD result in AL, HEX Value is AH ; divide HEX number with 0AH ; Bring the input HEX value to AL reg ; initialize DS register

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 34

INPUT: HEX NUMBER : 25H OUTPUT: BCD NUMBER: 37 5. CONCLUSION: The input Hex number is converted into BCD number and stored in the memory. 6. PRECAUTIONS: 1. Give connections carefully such as Keyboard, Flat Ribbon cable if any and power supply etc. 2. Switch on the power supply only after giving all the connections. 3. Handle the Trainer kits carefully. 7. VIVA-VOCE QUESTIONS: 1. What is a BCD number and give example? 2. What is the binary information for the BCD number 77H? 3. What is the range of single digit number in BCD? 4. What is the range of single digit number in Hex numbers? 5. Write the instructions to rotate AL 4 times? 6. Write the instructions to shift AL 4 times with carry? 7. How we can mask the lower nibble in AL register? 8. How we can mask the upper nibble in AL register? 9. where the quotient is stored after division instruction? 10. Where the reminder is stored after division instruction?

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 35

SORTING

EXPT. NO : 8 DATE :

1. AIM :Write an ALP to implement sorting . 2. COMPONENTS & TOOLS REQUIRED : 2.1 Computer system, 2.2 MASM / TASM SOFTWARE 3. THEORY: The following instructions are used for the signed and unsigned operations: SIGNED ASCENDING ORDER DESCENDING ORDER JLE JGE UNSIGNED JBE JAE

4. PROGRAM: SORTING DATA SEGMENT ADDR EQU 2500H DATA ENDS CODE SEGMENT ASSUME CS: CODE, DS: DATA START: MOV AX, DATA MOV DS, AX ; Initialize DS register MOV SI, ADDR; Move address 2500H in to Source Index MOV BL, [SI]; BL gives the number of passes DEC BL L3: DEC CL ; Decrement BL ; Decrement count MOV CL, [SI]; CL indicates the number of comparisons

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 36

INC SI L2: MOV AL, [SI] ; Move the element to AL register INC SI JLE NEXT XCHG AL, [SI] DEC SI MOV [SI], AL INC SI NEXT: DEC CL JNZ L2 DEC BL ; If BL <> 0 the more passes are need MOV SI, ADDR JNZ L3 INT 3 CODE ENDS END START 5. EXPECTED RESULTS: UNSIGNED NUMBERS: INPUT: 2500: 05H (NUMBER OF ELEMENTS) 2501: 9A 2502: 08 2503: 93 2504: 34 2505: 01 OUTPUT: 2501: 01 2502: 08 2503: 34 2504: 93 2505: 9A ; Breaking Interrupt ; If AL not smaller, then exchange the elements ; next element CMP AL, [SI] ; Comp. AL with the ele. in array pointed by SI

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 37

SIGNED NUMBERS: INPUT: 2500: 05H (NUMBER OF ELEMENTS) 2501: 9A 2502: E0 2503: FF 2504: 34 2505: 01 OUTPUT: 2501: 9A 2502: E0 2503: FF 2504: 01 2505: 34 6. CONCLUSION: The given numbers are sorted in Ascending order for both signed and unsigned and stored in the same locations. 7. PRECAUTIONS: 1. Give connections carefully such as Keyboard, Flat Ribbon cable if any and power supply etc. 2. Switch on the power supply only after giving all the connections. 3. Handle the Trainer kits carefully. 8. VIVA-VOCE QUESTIONS: 1. what is the instruction to jump instruction in implementing the sorting of signed numbers in ascending order? 2. what is the instruction to jump instruction in implementing the sorting of unsigned numbers in ascending order? 3. Give names of different sorting methods? 4.What is the difference between XCHG and CMP? 5. What is the difference between CMP and TEST?

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 38

FACTORIAL USING RECURSIVE

EXPT. NO : 9 DATE :

1. AIM :Write an ALP to implement Factorial using recursive procedure. 2. COMPONENTS & TOOLS REQUIRED : 2.1 Computer system, 2.2 MASM / TASM SOFTWARE 3. THEORY: A recursive procedure is a procedure, which calls itself. This seems simple enough, but the question you may be thinking is, Why would we want a procedure to call itself? The answer is that certain types of problems, such as choosing the next move in a computer chess program, can best be solved with a recursive procedure. Recursive procedures are often used to work with complex data structures called trees. We usually write recursive procedures in a high-level language such as C or Pascal, except in those cases where we need the speed gained by writing in assembly language. However, the assembly language example in the following sections should help you understand how recursion works and how th stack is used by recursive and other nested procedures 4. ALGORITHM: To find the factorial of a number N, the basic algorithm can be expressed very simply as IF N = 1 THEN factorial = 1, ELSE factorial = N x (factorial of N 1)

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 39

The procedure to compute the factorial of N is PROCEDURE FACTO IF N = 1 FACTORIAL = 1 RET ELSE REPEAT DECRMENT N CALL FACTO UNTIL N = 1 MULTIPLY (N-1)! X PREVIOUS N RET

1.

PROGRAM:

DATA SEGMENT NUMBER EQU 08 DATA ENDS STACK_SEG SEGMENT STACK DW 200 DUP (0) TOP_STACK LABEL WORD STACK_SEG ENDS CODE SEGMENT ASSUME CS: CODE, DS: DATA, SS: STACK_SEG START: MOV AX, STACK_SEG MOV SS, AX MOV SP, OFFSET TOP_STACK SUB SP, 0004H MOV AX, NUMBER ; Make space in stack for factorial ; Put number to AX passed on to stack ; Initialize SS register

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 40

PUSH AX CALL FACTO ADD SP, 2 POP AX POP DX INT3 FACTO PROC NEAR PUSHF PUSH AX PUSH DX PUSH BP MOV BP, SP MOV AX, [BP+10] CMP AX, 0001H GO_ON ; If number <> 1 then proceed ; and compute factorial MOV WORD PTR [BP+12], 0001H MOV WORD PTR [BP+14], 0000H JMP NEXT GO_ON: SUB SP, 0004H DEC AX PUSH AX CALL FACTO MOV BP, SP MOV AX, [BP+12] MUL WORD PTR [BP+16] MOV [BP+18], AX MOV [BP+20], DX ADD SP, 0006H EXIT: POP BP POP DX POP AX POPF ; Point stack pointer to push together ; Copy new factorial to stack ; Compute factorial of number-1 ; Point BP at top of stack ; Last (n-1)! from stack to multiply by previous n ; Move space in stack for preliminary factorial ; Decrement number in AX ; Else load factorial of one in stack ;and return to main line JNE ; Point BP to top of stack ; Save flags and registers ; Compute factorial of a given number

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 41

RET FACTO ENDP CODE ENDS END START 6. EXPECTED RESULTS: INPUT: N =5

OUTPUT: 120 DECIMAL 7. CONCLUSION Using recursive procedure, the factorial of given N number is found. 8. PRECAUTIONS: 1. Give connections carefully such as Keyboard, Flat Ribbon cable if any and power supply etc. 2. Switch on the power supply only after giving all the connections. 3. Handle the Trainer kits carefully. 9. VIVA-VOCE QUESTIONS: 1. What is recursive procedure? 2. What is the advantage of using procedure? 3. What is the difference between procedure and macro? 4. What are the disadvantages of procedures? 5. What is the need of saving all registers at the beginning of a procedure? 6. What is the instruction to save register in to the Stack? 7. What is a NEAR procedure? 8. What is a FAR procedure? 9. What is PUBLIC directive? 10. What is EXTRN directive?

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 42

8255 PPI (DAC)

EXPT. NO : 1 DATE :

1. AIM :Write 8086 program to interface 8255 PPI, generate saw tooth wave, triangular wave and square wave using DAC interfacing. 2. COMPONENTS & TOOLS REQUIRED : 2.1 Microprocessor 8086 Trainer Kit, 2.2 Power supply (5V, 3A) 2.3 DAC interface module 2.4 Power supply (12V) 2.5 Flat ribbon cable 2.6 connector ( 3 or 4 pin) 3. THEORY: The Dual DAC interface can be used to generate different interesting waveforms using microprocessor. There are two eight-bit digital to analog converters provided, based on DAC 0800. The digital inputs to these DACs are provided through the port A and port B of 8255 used as output ports. The analog output from the DACs are given to operational amplifiers which act as current to voltage converters. Two 10 K ohms pots are provided for the offset balancing of opamps. The reference voltage needed for the DACs is obtained from a onboard voltage regulator uA723. The voltage generated by this regulator is about 8V The outputs from the DACs vary between 0 to 5V corresponding to values between 00 to FF. Different waveforms can be observed at the opamp outputs depending upon the digital input patterns. For One Clock = 1 / 8 MHz = 0.125 s To generate 1 ms delay i.e. 1000 s = 1000 / 0.125 = 8000 Clock Cycles (CT) MOV CX, N L1: NOP NOP LOOP L1 CT = C0 + N (CL) 12 N = CT C0 + 12 / CL = (8000 4 + 12) / 23 4 Cycles 3 Cycles 3 Cycles 17 or 5 Cycles CL ( C0 )

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 43

= 349 = 015D CX = 015D 4. PROGRAM: 1. SAW TOOTH WAVE GENERATION: ADDR 2000 2003 2005 2006 2008 200B 200C 200E OPCODE LABEL MNEMONICS BA E7 FF MOV B0 80 MOV EE OUT B0 00 MOV BA E1 FF L1: MOV EE OUT FE C0 INC EB F8 JMP OPERANDS DX, 0FFE7H AL, 80H DX, AL AL, 00H DX, 0FFE1H DX, AL AL L1 COMMENTS ; Set up 8255 for Mode 0 ; Ports A, B ; ; Start with a value of 00h ; ; Out Xout ; Increment AL ; Repeat forever

5. EXPECTED RESULTS: OUTPUT:

Volts

t Amplitude = Time period = Frequency = Resolution = 2. TRIANGULAR WAVE GENERATION: ADDR 2000 2003 2005 OPCODE LABEL MNEMONICS BA E7 FF MOV B0 80 MOV EE OUT OPERANDS DX, 0FFE7H AL, 80H DX, AL COMMENTS

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 44

2006 2008 200B 200C 200E 2010 2012 2013 2015 2017

B0 00 BA E1 FF EE L1: FE C0 3C FF 75 F9 EE L2: FE C8 75 FB EB F2

MOV MOV OUT INC CMP JNZ OUT DEC JNZ JMP

AL, 00H DX, 0FFE1H DX, AL AL AL, 0FFH L1 DX, AL AL L2 L1

OUTPUT:

Volts

Amplitude = Time period = Frequency = Resolution = 3. SQUARE WAVE GENERATION: ADDR 2000 2003 2005 2006 2008 200B 200C 200F 2011 OPCODE LABEL MNEMONICS BA E7 FF MOV B0 80 MOV EE L1: OUT B0 00 MOV BA E1 FF MOV EE OUT E8 08 00 CALL B0 FF MOV EE OUT OPERANDS DX, 0FFE7H AL, 80H DX, AL AL, 00H DX, 0FFE1H DX, AL DLY AL, 0FFH DX, AL COMMENTS

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 45

2012 2015 2017 201A 201B 201C 201E

E8 02 00 EB EE B9 5D 01 90 90 E2 FC C3

DLY: L2:

CALL JMP MOV NOP NOP LOOP RET

DLY L1 CX, 015DH

L2

OUTPUT: Volts

t Amplitude = Time period = Frequency = Resolution =

6. CONCLUSION: The 8255 interfacing is implemented and different waveforms such as square wave, saw tooth and triangular waves are generated. 7. PRECAUTIONS: 1. Give connections carefully such as Keyboard, Flat Ribbon cable if any and power supply etc. 2. Switch on the power supply only after giving all the connections.

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 46

3. Handle the Trainer kits carefully. 8. VIVA-VOCE QUESTIONS:

1. Explain OUT and IN instructions? 2. What is the difference between Fixed Port and Variable Port? 3. What are the commands to execute this program? 4. What is Duty Cycle? 5. How can you generate Ramp Waveform? 6. How can you write 2ms delay program? 7. What is the difference between Macro and Procedure? 8. What is the difference between conditional Jump and Unconditional Jump instructions?

8279 KEY BOARD DISPLAY

EXPT. NO : 2 DATE :

1. AIM :Write 8086 program to interface 8279 key board display. 2. COMPONENTS & TOOLS REQUIRED : 2.1 Microprocessor 8086 Trainer Kit, 2.2 Power supply (5V, 3A) Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 47

2.3 8279 key board display interfacing module 2.4 Flat ribbon cable 3. THEORY: ROLLING DISPLAY Display/Keyboard mode set word and clear word take care of basic initialization of 8279. However, before sending codes to the display RAM, a write display RAM control word should be sent. Then, write the data to be displayed, to the data register. Then, the data is fetched from address and is displayed in the first digit of the display. The next data is displayed in the second digit of the display, since in the command word for write display RAM the Auto increment flag is set. A time delay is given between successive digits for a lively display. N KEY ROLLOVER With N-key rollover each key depression is treated independently from all others. When a key is depressed, the debounce circuit waits 2 keyboard scans and then checks to see if the key is still down. If it is, the key is entered into the FIFO. Any number of keys can be depressed and another can be recognized and entered according to the order the keyboard scan found them Any number of keys can b depressed and all will be entered There is no constraint that all keys should be released before a depressed key is to be recognized.

ROLLING DISPLAY ( " ECE IS GOOD ") a f g e c . dp b

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 48

SEGMENT LETTER 'E' HEX CODE

d 0

c 1 6

b 1

A 0

dp 1

g 0 8

f 0

e 0

4. PROGRAM: ROLLING DISPLAY (DISPLAY MESSAGE IS ECE IS GOOD ADDR OPCODE 1000 BE 00 12 1003 B9 0F 00 1006 B0 10 1008 E6 C2 100A B0 CC 100C E6 C2 100E B0 90 1010 E6 C2 1012 8A 04 1014 E6 C0 1016 E8 E7 04 1019 46 101A E2 F6 101C EB E2 LABEL MNEMONICS OPERANDS COMMENTS ST: MOV SI, 1200 ; Set pointer = 1200H MOV CX, 000F ; Initialize counter MOV AL, 10 OUT C2, AL ; Set mode and display MOV AL, CC ; Clear display OUT C2, AL MOV AL, 90 ; Write display OUT C2, AL NXT: MOV AL, [SI] OUT C0, AL CALL DLY INC SI ; Increment the pointer ; Count if non zero to display the next LOOP NXT character JMP ST ; Repeat MOV DEC JNZ RET DB DB DB DB DX, 0A0FF DX L1: ; Delay sub routine

1500 BA FF A0 DLY: 1503 4A L1: 1504 75 FD 1506 C3 LOOK UP TABLE: 1200 FF FF FF FF 1204 68 6C 68 FF 1208 9F 29 FF 28 120C 0C 0C 1A FF

; Display message ECE IS GOOD

TO INITIALIZE 8279 IN N-KEY ROLLOVER:

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 49

ADDR OPCODE 1000 B9 08 00 1003 B0 02 1005 E6 C2 1007 B0 CC 1009 E6 C2 100B B0 90 100D E6 C2 100F B0 FF 1011 E6 C0 1013 E2 FC 1015 E4 C2 1017 A8 07 1019 74 FA 101B B0 40 101D E6 C2 101F E4 C0 1021 24 0F 1023 88 C3 1025 B7 12 1027 8A 07 1029 E6 C0 102B EB E8 LOOK UP TABLE: 1200 0C 9F 4A 0B 1204 99 29 28 8F 1208 08 09 88 38 120C 6C 1A 68 E8

LABEL MNEMONICS OPERANDS COMMENTS MOV CX, 0008 MOV AL, 02 ;Encoded scan kb 2key lockout OUT C2, AL ; Set mode and display MOV AL, CC ; Clear display OUT C2, AL MOV AL, 90 ; Write display OUT C2, AL MOV AL, FF ; Clear the display RAM REP: OUT C0, AL LOOP REP L1: IN AL, C2 ; L1 for the pressing of a key TEST AL, 07 JZ L1 MOV AL, 40 ; Set to read FIFO RAM OUT C2, AL IN AL, C0 ; Get the corresponding code from AND MOV MOV MOV OUT JMP AL, 0F BL, AL BH, 12 AL, [BX] C0, AL L1 lookup table

5. EXPECTED RESULTS: INPUT: ECE IS GOOD OUTPUT: ECE IS GOOD is roll over on display. 6. CONCLUSION: The interfacing of 8279 keyboard-display is implemented. 7. PRECAUTIONS: 1. Give connections carefully such as Keyboard, Flat Ribbon cable if any and power supply etc.

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 50

2. Switch on the power supply only after giving all the connections. 3. Handle the Trainer kits carefully. 8. VIVA-VOCE QUESTIONS: 1. What is Two-key lock out? 2. What is N-Key Roll over? 3. What are the MASM commands to execute this program? 4. What is the chip number for the BCD to 7 segment display? 5. What is look-up table? And Give an example? 6. What is the chip number of keyboard-display interface?

8253 & 8251 USART

EXPT. NO : 3 DATE :

1. AIM :Write 8086 program to interface 8253 & 8251 USART. 2. COMPONENTS & TOOLS REQUIRED : 2.1 Microprocessor 8086 Trainer Kit, 2.2 Power supply (5V, 3A) 2.3 8253 & 8251 USART interface module 2.4 Flat ribbon cable 3. THEORY: To Initialize 8253 and 8251 and to check the transmission and reception of a character. The program first initializes 8253 to give an output clock frequency of 150 KHz at channel 0 which will give a 9600-baud rate of 8251. Please make sure that the output of channel 0 is connected to transmitter clock and receiver clock of 8251. Connect RTS with CTS and TXD with RXD, by setting the jumpers accordingly. BRF = TXC / Baud Select TXC = 150 KHz; Baud = 9600 Then BRF = 150K / 9600 = 16 = 10H
CONTROL WORD FORMAT OF 8253:

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 51

36

0 0 Channel 0

1 1 Read/Load LSB first then MSB

1 Mode 3

0 Hex / BCD

MODE INSTRUCTION FORMAT ASYNCHRONOUS MODE 8251A: 4E 0 1 0 No. of Stop bits (1 Bit) No even parity 0 No parity 1 1 Character length 8 bits 1 0 Baud rate factor (16X)

8251 COMMAND INSTRUCTION FORMAT: 37 0 Enter hunt mode 0 Internal reset 1 Request To Send 1 Error reset 0 Send break character 1 Receive Enable 1 Data Terminal Ready 1 Transmit enable

4. PROGRAM: ADDR 1000 1002 1004 1006 1008 100A 100C 100E 1010 1012 1014 1016 1018 OPCODE LABEL MNEMONICS B0 36 MOV E6 CE OUT B0 10 MOV E6 C8 OUT B0 00 MOV E6 C8 OUT B0 4E MOV E6 C2 OUT B0 37 MOV E6 C2 OUT B0 41 MOV E6 C0 OUT CD 02 INT IN MOV MOV INT OPERANDS COMMENTS AL, 36 ; Select 8253 CH0, mode 3 0CE, AL ; CE = Address of the mode register AL, 10 ; 10H = 16 = BRF 0C8, AL ; Store in CH0 address AL, 00 0C8, AL ; C8 is the address of CH0 AL, 4E ; 8251 mode word 0C2, AL AL, 37 ; 8251 command word 0C2, AL AL, 41 ; Send 41H to data register 0C0, AL 2 AL, 0C0 BX, 1250H [BX], AL 2 ; Read the data 41Hh from data register ; Store in to 1250 location

1200 E4 C0 1202 BB 50 12 1205 88 07 1207 CD 02 5. EXPECTED RESULTS: INPUT: OUTPUT: [1250] : 41H

41H in AL register

6. CONCLUSION: Interfacing of 8253 and 8251 serial device is implemented and a byte from AL register is transferred to the Data register of 8251. 7. PRECAUTIONS: 1. Give connections carefully such as Keyboard, Flat Ribbon cable if any and power supply etc.

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 52

2. Switch on the power supply only after giving all the connections. 3. Handle the Trainer kits carefully. 8. VIVA-VOCE QUESTIONS: 1. Explain Control word format of 8253? 2. Explain Mode register of 8251? 3. Explain command register of 8251? 4. Explain Status register of 8251? 5. What is the difference between fixed port and variable port? 6. What are the instructions for the I/O functions? 7. What is the difference between I/O mapped I/O and memory mapped I/O? 8259 INTERRUPT CONTROLLER

EXPT. NO : 4 DATE :

1. AIM :Write 8086 program to implement Multi byte addition. 2. COMPONENTS & TOOLS REQUIRED : 2.1 Microprocessor 8086 Trainer Kit, 2.2 Power supply (5V, 3A) 3. THEORY: 8086 INTERRUPT RESPONSE: 1. send out two interrupt acknowledge pulses on its INTA pin to the INTA pin of an 8259. The INTA pulses tell the 8259 to send the desired interrupt type to the 8086 on the data bus. 2. Multiply the interrupt type it receives from the 8259 by 4 to produce an address in the interrupt vector table. 3. Push the flags on the stack. 4. Clear IF and TF 5. Push the return address on the stack. 6. Get the starting address for the interrupt procedure from the interrupt-vector table and load that address in CS and IP 7. Execute the interrupt-service procedure. 8259 INTERRUPT CONTROLLER To initialize the 8259 with the following specification:

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 53

ICW 4 needed (ICW = Initialization Command Word) Single 8259 Interval of 4 Edge triggered mode A7 A6 A5 = 000 Initialize to type 8 interrupt 8086 mode Normal EOI (EOI = End Of Interrupt) Non-buffered mode (Since we are not using buffers) Not special fully-nested mode Mask all interrupts except IRQ 0

4. PROGRAM: ADDR 1000 1002 1004 1006 1008 100A 100C 100E 1010 OPCODE B0 17 E6 C0 B0 08 E6 C2 B0 01 E6 C2 B0 FE E6 C2 F4 LABEL MNEMONICS MOV OUT MOV OUT MOV OUT MOV OUT HLT OPERANDS AL, 17 C0, AL AL, 08 C2, AL AL, 01 C2, AL AL, FE C2, AL COMMENTS

INTERRUPT VECTOR: CS 0000: 0000: 0000: 0000: ADDRESS 0020 0021 0022 0023 OPCODE 00 12 00 00

INTERRUPT SERVICE ROUTINE: ADDR OPCODE 1200 B0 20 1202 E6 C0 1204 CD 02 LABEL MNEMONICS MOV OUT INT OPERANDS AL, 20 C0, AL 2 COMMENTS

PROGRAM DESCRIPTION:

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 54

The main program initializes the 8259 to the above specifications. The program initializes the 8259 to type 8. So the interrupt vector for interrupt IR0 is 0000: 0020. So at 0000: 0020, enter the address 0000: 1200H, If the ISR is at 0000:1200. In the ISR, non-specific EOI command is given. In fully nested mode, the interrupt requests are ordered in priority from 0 through 7 (0 highest). But in some applications there are a number of interrupting devices of equal priority. In this mode, a device after being serviced receives the lowest priority. This is known as Rotating Priority.

5. EXPECTED RESULTS: INPUT: OUTPUT: 20H is put into AL register The binary information is displayed in the form of LEDS in 8259 interface kit.

6. CONCLUSION: 8259 Priority interrupt controller interface is implemented. 7. PRECAUTIONS: 1. Give connections carefully such as Keyboard, Flat Ribbon cable if any and power supply etc. 2. Switch on the power supply only after giving all the connections. 3. Handle the Trainer kits carefully. 8. VIVA-VOCE QUESTIONS:

1. What is 8086 interrupt response? 2. What is the flag that has to be set when we want to use INTR pin? 3. What is the purpose of IE flag? 4. How many interrupts are there in 8086? 5. What is the difference between the software interrupt and hard ware interrupt?

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 55

6. What is the highest priority interrupt in 8086? 7. What is the use of ICW? 8. What is the use of OCW? 9. Explain the format of ICW!? 10. Explain the format of ICW2?

ADDITION OF TWO 32-BIT NUMBERS

EXPT. NO : 1 DATE :

1. AIM :Write 8051 program to implement Multi byte addition. 2. COMPONENTS & TOOLS REQUIRED : 2.1 Microcontroller 8031/51 Trainer Kit, 2.2 Power supply (5V, 3A) 3. THEORY: Generally 8-bits are called a byte, 16-bits are called a word, 32-bits are called a double word. The data more than 4 bytes is called a multi byte. Here, we are adding two multi bytes which are stored in the registers. By using the instruction ADDC, we can add byte by byte. 4. PROGRAM: ADDITION OF TWO 32-BIT NUMBERS; RESULT 32-BIT ADDR 8000 8001 8002 8003 8004 8005 8006 8007 OPCODE LABEL MNEMONICS E8 MOV 2C ADD F8 MOV E9 MOV 3D ADDC F9 MOV EA MOV 3E ADDC OPERANDS A, R0 A, R4 R0, A A, R1 A, R5 R1, A A, R2 A, R6 COMMENTS

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 56

8008 8009 800A 800B 800C

FA EB 3F FB 02 80 0C

MOV MOV ADDC MOV HERE: LJMP

R2, A A, R3 A, R7 R3, A HERE

5. EXPECTED RESULTS: INPUT: R3, R2, R1, R0 = X R7, R6, R5, R4 = Y OUTPUT: INPUT: INPUT [R0] = 45 [R1] = 58 [R2] = 7A [R3] = 2D [R4] = 22 [R5] = AC [R6] = 3C [R7] = 1E 6. CONCLUSION: The Multi Byte Addition is performed by using 8051 instructions. 7. PRECAUTIONS: 1. Give connections carefully such as Keyboard, Flat Ribbon cable if any and power supply etc. 2. Switch on the power supply only after giving all the connections. 3. Handle the Trainer kits carefully. 8. VIVA-VOCE QUESTIONS: 1. What is a multi byte? 2. Which registers are used as pointers? 3. On what condition the carry flag is set? 4. What are the commands to perform this program on the kit? 5. What is the difference between conditional and unconditional jump instructions? OUTPUT [R0] = 67 [R1] = 04 [R2] = B7 [R3] = 4B R3, R2, R1, R0 = Signed Sum S = X + Y

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 57

6. What are the flags available in 8086?

SUBTRACTION OF 2 32-BIT NUMBERS

EXPT. NO : 2 DATE :

1. AIM :Write 8051 program to implement two 32-bit numbers.. 2. COMPONENTS & TOOLS REQUIRED : 2.1 Microcontroller 8031/51 Trainer Kit, 2.2 Power supply (5V, 3A) 3. THEORY: Generally 8-bits are called a byte, 16-bits are called a word and 32-bits are called a double word. The data more than 4 bytes is called a multi byte. Here, we are subtracting two multi bytes which are stored in the registers. By using the instruction SUBB, we can subtract byte by byte. 4. PROGRAM: SUBTRACTION OF TWO 32-BIT NUMBERS; RESULT 32-BIT ADDR OPCODE LABEL MNEMONICS OPERANDS 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 800A 800B 800C 800D C3 E8 9C F8 E9 9D F9 EA 9E FA EB 9F FB 02 80 0D CLR MOV SUBB MOV MOV SUBB MOV MOV SUBB MOV MOV SUBB MOV HERE: LJMP C A, R0 A, R4 R0, A A, R1 A, R5 R1, A A, R2 A, R6 R2, A A, R3 A, R7 R3, A HERE COMMENTS

5. EXPECTED RESULTS: INPUT: R3, R2, R1, R0 = X R7, R6, R5, R4 = Y

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 58

OUTPUT:

R3, R2, R1, R0 = Signed Difference D = X Y

INPUT [R0] = 45 [R1] = 58 [R2] = 7A [R3] = 2D [R4] = 22 [R5] = AC [R6] = 3C [R7] = 1E

OUTPUT [R0] = 23 [R1] = AC [R2] = 3D [R3] = 0F

6. CONCLUSION: The Multi Byte Addition is performed by using 8051 instructions. 7. PRECAUTIONS: 1. Give connections carefully such as Keyboard, Flat Ribbon cable if any and power supply etc. 2. Switch on the power supply only after giving all the connections. 3. Handle the Trainer kits carefully. 8. VIVA-VOCE QUESTIONS: What is a multi byte? Which registers are used as pointers? On what condition the carry flag is set? What are the commands to perform this program on the kit? What is the difference between conditional and unconditional jump instructions? What are the flags available in 8086? MULTIPLICATION

EXPT. NO : 3 DATE :

1. AIM :Write 8051 program to implement Multiplication. 2. COMPONENTS & TOOLS REQUIRED : 2.1 Microcontroller 8031/51 Trainer Kit, 2.2 Power supply (5V, 3A)

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 59

3. THEORY: After multiplication, if it is 16 bit multiplication, the result will be stored in A and B registers and if it is 8 bit multiplication, the result will be stored in A register. 4. PROGRAM: MULTIPLICATION OF TWO 8-BIT NUMBERS ADDR OPCODE LABEL MNEMONICS OPERANDS 8000 8003 8004 8006 8009 800A 800B 800E 800F 8010 8012 8013 90 90 01 E0 F5 F0 90 90 00 E0 A4 90 90 02 F0 A3 E5 F0 F0 02 00 00 MOV MOVX MOV MOV MOVX MUL MOV MOVX INC MOV MOVX LJMP COMMENTS ; Keep data in 9000H & 9001H data

DPTR, #9001 memory location A, @DPTR 0F0, A DPTR, #9000 A, @DPTR AB ; Perform multiplication operation ; Store the result in 9002H & 9003H of DPTR, #9002 data memory @DPTR, A DPTR A, 0F0 @DPTR, A 0

5. EXPECTED RESULTS: INPUT [9000] = FF [9001] = FF 6. CONCLUSION: The Multiplication of two numbers is performed by using 8051 instructions. 7. PRECAUTIONS: 1. Give connections carefully such as Keyboard, Flat Ribbon cable if any and power supply etc. 2. Switch on the power supply only after giving all the connections. OUTPUT [9002] = 01 [9003] = FE

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 60

3. Handle the Trainer kits carefully. 8. VIVA-VOCE QUESTIONS: 1. What are the commands to perform this program on the kit? 2. What is the range of 8 bit signed numbers? 3. What is the range of 16 bit signed numbers? 4. In which registers the 32 bit result will be stored after multiplicdation? 5. Name different registers in 8051 micro controller? 6. What are the three memory areas in 8051 microcontroller?

DIVISION

EXPT. NO : 4 DATE :

1. AIM :Write 8051 program to implement division operation. 2. COMPONENTS & TOOLS REQUIRED : 2.1 Microcontroller 8031/51 Trainer Kit, 2.2 Power supply (5V, 3A) 3. THEORY: After Division, the Quotient be stored in A and the Reminder will be stored in B register. 4. PROGRAM: DIVISION OF TWO 8-BIT NUMBERS

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 61

ADDR OPCODE LABEL MNEMONICS OPERANDS COMMENTS DPTR, ; Keep data in 9000H & 9001H data 8000 8003 8004 8006 8009 800A 800B 800E 800F 8010 8012 8013 8016 90 90 01 E0 F5 F0 15 82 E0 84 A3 A3 F0 A3 E5 F0 F0 02 80 11 MOV MOVX MOV DEC MOVX DIV INC INC MOVX INC MOV MOVX HERE: LJMP #9001 A, @DPTR 0F0, A 82 A, @DPTR AB DPTR DPTR @DPTR, A DPTR A, F0 @DPTR, A HERE memory location

; Perform division operation ; Store the result in 9002H & 9003H of data memory

5. EXPECTED RESULTS:

INPUT [9000] = 19 [9001] = 05

OUTPUT [9002] = 05 [9003] = 00

6. CONCLUSION: The Division of two numbers is performed by using 8051 instructions. 7. PRECAUTIONS: 1. Give connections carefully such as Keyboard, Flat Ribbon cable if any and power supply etc. 2. Switch on the power supply only after giving all the connections. 3. Handle the Trainer kits carefully. 8. VIVA-VOCE QUESTIONS: 1. What are the commands to perform this program on the kit? 2. What is the range of 8 bit signed numbers?

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 62

3. What is the range of 16 bit signed numbers? 4. In which registers the 32 bit result will be stored after Division? 5. Name different registers in 8051 micro controller? 6. What are the three memory areas in 8051 micro controller?

BYTE CHECKING

EXPT. NO : 5 DATE :

1. AIM :Write 8051 program to implement Byte Checking.. 2. COMPONENTS & TOOLS REQUIRED : 2.1 Microcontroller 8031/51 Trainer Kit, 2.2 Power supply (5V, 3A) 3. THEORY: In the given byte checking the 5th bit is '1' or '0'. If the 5th bit is '1' 00 should be stored in 8901H data memory or if it is '0' FF should be stored in 8901H data memory. 4. PROGRAM: ADDR OPCODE LABEL MNEMONICS OPERANDS COMMENTS 8000 90 89 00 MOV DPTR, #8900 ; Store the given byte in 8900H data memory 8003 E0 8004 A3 8005 33 MOVX INC RLC A, @DPTR DPTR A

; Rotate left three times

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 63

8006 8807 8008 880A 800C 800D 8010 8012 8013

33 RLC 33 RLC 40 06 JC 74 FF MOV F0 MOVX 02 00 00 LJMP 74 00 LOOP: MOV F0 MOVX 02 00 00 LJMP

A A LOOP A, #FF @DPTR, A 0 A, #00 @DPTR, A 0

; Check for carry ; Move FF in to accumulator

; Move 00 in to accumulator

5. EXPECTED RESULTS: INPUT [8900] = 35 OUTPUT [8901] = 00

INPUT [8900] = 15

OUTPUT [8901] = FF

6. CONCLUSION: The multi Byte addition is performed by using 8051 instructions. 7. PRECAUTIONS: 1. Give connections carefully such as Keyboard, Flat Ribbon cable if any and power supply etc. 2. Switch on the power supply only after giving all the connections. 3. Handle the Trainer kits carefully. 8. VIVA-VOCE QUESTIONS: 1. What are the commands to perform this program on the kit? 2. What is the difference between data memory and program memory? 3. What is the pin name to access the program memory? 4. What are the alternate ways to check the byte? 5. Name different registers in 8051 micro controller? 6. What are the three memory areas in 8051 micro controller? Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 64

SUM OF THE ELEMENTS IN AN ARRAY

EXPT. NO : 6 DATE :

1. AIM :Write 8051 program to find the sum of the elements in an Array. 2. COMPONENTS & TOOLS REQUIRED : 2.1 Microcontroller 8031/51 Trainer Kit, 2.2 Power supply (5V, 3A) 3. THEORY: To add the numbers of an 8-bit array, the array length being the first element in the array and store the result in memory. The numbers are stored in consecutive locations in memory. Addition has to be performed for the number of times decided by the length of the array. Since the sum may exceed 8-bits, it is necessary to monitor the carry flag status. Indexed addressing employing the 16-bit Base register DPTR is used in this program. EXAMPLE: The array starts at 4201. The address location 4200 contains the number of elements in that array. The result is to be stored at 4500 and 4501. Sample Data: INPUT OUTPUT [4200] = 03 (count) [4500] = 00 (MSB) [4501] = 06 (LSB) [4201] = 01 [4202] = 02 [4203] = 03

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 65

4. ALGORITHM: i. ii. iii. iv. Enter the below op codes and data from 4100 and 4200 respectively Execute the program Check for result at 4500 and 4501 Change data at 4200 and check for results

5. PROGRAM: ADDR OPCODE 4100 90 42 00 4103 E0 4104 F8 4105 75 F0 00 4108 A9 F0 410A C3 410B A3 410C E0 410D 25 F0 410F F5 F0 4111 50 01 4113 09 4114 D8 F4 4116 90 45 00 4119 E9 411A F0 411B A3 411C E5 F0 411E F0 411F 80 FE LABEL MNEMONICS MOV MOVX MOV MOV MOV ADD: CLR INC MOVX ADD MOV JNC INC NC: DJNZ MOV MOV MOVX INC MOV MOVX HLT: SJMP OPERANDS DPTR, #4200 A, @DPTR R0, A B, #00 R1, B C DPTR A, @DPTR A, B B, A NC R1 R0, ADD DPTR, #4500 A, R1 @DPTR, A DPTR A, B @DPTR, A HLT COMMENTS ; DPTR points to base of array ; R0 has the length of array

; Increment the pointer ; Get the element ; Do the partial addition ; Check for carry ; If carry set, then increment MSB ; Repeat it till count = 0 ; Store the MSB first

; Store the LSB at 4501

6. EXPECTED RESULTS:

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 66

INPUT [4200] = 03 (count) [4201] = 01 [4202] = 02 [4203] = 03 7. CONCLUSION:

OUTPUT [4500] = 00 (MSB) [4501] = 06 (LSB)

The Sum of elements in an array is performed by using 8051 instructions. 8. PRECAUTIONS: 1. Give connections carefully such as Keyboard, Flat Ribbon cable if any and power supply etc. 2. Switch on the power supply only after giving all the connections. 3. Handle the Trainer kits carefully. 9. VIVA-VOCE QUESTIONS: 1. What are the commands to perform this program on the kit? 2. What is the difference between data memory and program memory? 1. What is the pin name to access the program memory? 4. What is the difference between MOVX and MOVC? 5. Name different registers in 8051 micro controller? 6.What are the three memory areas in 8051 micro controller?

WRITING & READING TO PARALLEL PORT

EXPT. NO : 7 DATE :

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 67

1. AIM :Write 8051 program to implement writing to parallel port. 2. COMPONENTS & TOOLS REQUIRED : 2.1 Microcontroller 8031/51 Trainer Kit, 2.2 Power supply (5V, 3A) 3. THEORY: Though there are 32 I/O lines available in 8051, only 8 I/O lines (Port 1) are exclusively available for the user. This is because; the output drivers of Ports 0 and 2 and input buffers of port 0 are used in accesses to external memory. Also, all the Port 3 pins are multifunctional. To write any data to Port 1, Port 1 register (P1) should be loaded with that data to be output. As all the 8 I/O lines are bit addressable, they can be programmed either low or high independently. 8051 has four parallel ports. But, only Port 1 is user-free as Port 2 outputs the high byte of the external memory address and Port 0 outputs the low byte of the external memory address, time-multiplexed with the byte being written or read and port 3 pins have alternate functions. 4. PROGRAM:
I.WRITING DATA :

ADDR OPCODE LABEL MNEMONICS 4100 74 45 MOV 4102 F5 90 MOV 4104 80 FE HLT: SJMP

OPERANDS A, #45 P1, A HLT

COMMENTS

II. BLINKING:

ADDR OPCODE LABEL MNEMONICS 4100 74 FF ST: MOV 4102 F5 90 MOV 4104 31 0E ACALL 4106 74 00 MOV

OPERANDS A, #45 P1, A DLY A,#00

COMMENTS

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 68

4108 410A 410C 410E 4110 4112 4114 4116

F5 90 31 0E 80 F2 79 FF 7A FF DA FE D9 FA 22

DLY: L1: L2:

MOV ACALL SJMP MOV MOV DJNZ DJNZ RET

P1, A DLY ST R1, #FF R2, #FF R2, L2 R1, L1

III. READING:

ADDR OPCODE LABEL MNEMONICS 4100 90 45 00 MOV 4103 E0 MOVX 4104 F5 90 MOV 4106 80 FE HLT: SJMP
IV. READING DIP SWITCH:

OPERANDS DPTR, #4500 A, @DPTR P1,A HLT

COMMENTS

ADDR OPCODE LABEL MNEMONICS 4100 90 FF 14 ST: MOV 4103 E0 MOVX 4104 90 FF 13 MOV 4107 E0 MOVX 4108 80 F6 SJMP

OPERANDS DPTR, #FF14 A, @DPTR DPTR, #FF13 A, @DPTR ST

COMMENTS

5. EXPECTED RESULTS: After entering the above program, execute it. Using a Multi meter or an Oscilloscope, check whether correct data is available at Port 1 (P1.0 P1.7) of 8051. (i.e. Pin no.1 is LSB of P1 and Pin no.8 is MSB of P1). 6.CONCLUSION: Using 8051 instructions performs the writing & reading to parallel port. 7. PRECAUTIONS: 1. Give connections carefully such as Keyboard, Flat Ribbon cable if any and power supply etc. Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 69

2. Switch on the power supply only after giving all the connections. 3. Handle the Trainer kits carefully. 8. VIVA-VOCE QUESTIONS: 1. How many ports are there in 8051 microcontroller? 2. What is the alternate function of Port 0? 3. What is the alternate function of Port 1? 4. Name the port which does not having alternate function? 5. What is the alternate function of Port 4? 6. How many address lines are there in 8051? 7. What is the length of Data Bus in 8051?

ADDITION/SUBTRACTION USING INTERNAL MEMORY

EXPT. NO : 8 DATE :

1. AIM :Write 8051 program to implement two 32-bit numbers addition and subtraction using internal memory locations. 2. COMPONENTS & TOOLS REQUIRED : 2.1 Microcontroller 8031/51 Trainer Kit, 2.2 Power supply (5V, 3A)

PROGRAM: MOV R0, #30

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 70

MOV R1, #40 MOV R2, #04 NEXT: MOV A, @R0 ADDC A, @R1 / SUBB A, @R1 MOV @R0, A INC R0 INC R1 DJNZ R2, NEXT HERE: INPUT: First operand [30] = 45 [31] = 58 [32] = 7A [33] = 2D Second operand [40] = 22 [41] = AC [42] = 3C [43] = 1E OUTPUT: (addition) [30] = 67 [31] = 04 [32] = B7 [33] = 4B OUTPUT: (subtraction) [30] = 23 [31] = AC [32] = 3D [33] = 0F LJMP HERE

Lakireddy Bali Reddy College of Engineering, L.B.Reddy Nagar, Mylavaram 521 230 71

Você também pode gostar