Beruflich Dokumente
Kultur Dokumente
NO: 1
Aim : To perform arithmetic operations using 8086. Apparatus : 1. Microprocessor kit 2. Power chord 3. Keyboard
Algorithm - Two Byte Addition : 1. Initialize carry register CL with 00. Load AH and AL registers with MSB and LSB of first data respectively. Load BH and BL registers with MSB and LSB of second data. 2. Add accumulator register content with base register. 3. Check for carry flag. If carry exists, increment carry register by one, else go to next step. 4. Store accumulator content to 1500 and 1501 respectively. 5. Store carry register content to 1502 and stop program. Program : Address
Opcode
Operand Label
Mnemonics
MOV CL,00 MOV AX,0FFFEH MOV BX,1010H ADD AX, BX JNC L1 INC CL MOV[1500],AX MOV[1502],CL HLT
Comments
L1
Algorithm - Two Byte Subtraction : 1. Move 00 to CL register. Load first and second data to AX and BX. 2. Subtract AX with BX. If carry exists, increase CL count. 3. Store AX register and CL count value to memory location. 4. Stop the program. Program : Address Opcode Operand Mnemonics
MOV CL,00 MOV AX,0FFFFH MOV BX,1010H SUB AX,BX JNC L1 INC CL MOV[1500],AX MOV[1502],CL HLT
Comments
Algorithm - 16 Bit Multiplication: 1. Load AX with 1st data and multiply 2nd data with AX content. 2. Move MSB in DX & LSB in AX to memory and stop the program. Program : Address Opcode Operand Label Mnemonics
MOV AX, 0FFFF MOV BX,1010 MUL BX MOV[2902],DX MOV[2900],AX HLT
Comments
Algorithm - 16 Bit Division : 1. Load AX with LSB of 1st data and DX with MSB first data. 2. Divide DX & accumulator content with 2nd data 3. Store quotient (AX) into memory. 4. Store remainder(DX) into memory. 5. Stop program. Program : Address Opcode Operand Mnemonics
MOV AX,6552 MOV BX,1232 DIV BX MOV[1200],AX MOV[1202],DX HLT
Comments
Result : Thus arithmetic operations using 8086 is done and program is executed and output is verified.
To sort the given array of 16 bit datas into ascending and descending order To find the biggest and smallest number from the given set of 2 byte numbers
Apparatus Required: 1) 8086 Microprocessor kit, 2) power Chord and, 3) keyboard Algorithm - Ascending Order : 1) 2) 3) 4) 5) 6) 7) Load 2 registers with count value Initialize the source index pointer Move the contents of memory to accumulator Increment SI value twice to get next 16 bit data in another register. Compare the word in AX with next word Check for carry. If carry=1, go to step 8 or move to the next step. Present memory content is moved to a reg. Content of accumulator is moved to present memory. Move the reg. content to previous location 8) Decrement BL & check for zero. If no zero go to step 3, else go to next step. 9) Decrement BH & check for zero. If no zero, go to step 2 else stop the program. Program - Ascending Order: Address Opcode Operand Label L1 L2 Mnemonics MOV BH, 05 MOV SI,1500 MOV BL,05 MOV AX,[SI] INC SI INC SI MOV CX,[SI] CMP AX,CX JC L3 MOV DX, [SI] MOV [SI], AX DEC SI DEC SI MOV [SI], DX DEC BL JNZ L2 DEC BH JNZ L1 HLT Comments
L3
Algorithm - Descending Order : 1) 2) 3) 4) 5) 6) 7) Load 2 registers with count value Initialize the source index pointer Move the contents of memory to accumulator Increment SI value twice to get next 16 bit data in another register. Compare the word in AX with next word Check for carry.If carry=0, go to step 8 else go to next step Present memory content is moved to a reg. Content of accumulator is moved to present memory. Move the reg. content to previous location 8) Decrement BL & check for zero. If no zero go to step 3, else go to next step. 9) Decrement BH & check for zero. If no zero, go to step 2 else stop the program.
Program: Descending Order: Address Opcode Operand Label L1 L2 Mnemonics MOV BH, 05 MOV SI,1500 MOV BL,05 MOV AX, [SI] INC SI INC SI MOV CX, [SI] CMP AX, CX JNC L3 MOV DX, [SI] MOV [SI], AX DEC SI DEC SI MOV [SI], DX DEC BL JNZ L2 DEC BH JNZ L1 HLT Comments
L3
Algorithm - Biggest: 1. 2. 3. 4. 5. Load BL register with count value Initialize the source index pointer Move the contents of memory to accumulator & decrement BL value Increment SI value twice to get next 16 bit data in another register. Compare the word in AX with next word
6. Check for carry. In smallest number if carry=1, go to step 8 or move to the next stepIf carry=0, go to step 8 else go to next step 7. Present memory content is moved to accumulator 8. Decrement BL & check for zero. If no zero go to step 3, else go to next step. 9. Stop the program. Program - Biggest number: Address Opcode Operand Label Mnemonics Comments MOV SI,1500 MOV BL, 04 MOV AX,[SI] DEC BL INC SI INC SI CMP AX, [SI] JNC L2 MOV AX, [SI] DEC BL JNZ L1 MOV [1600], AX HLT
L1
L2
Algorithm -Smallest: 1. Load BL register with count value 2. Initialize the source index pointer 3. Move the contents of memory to accumulator & decrement BL value 4. Increment SI value twice to get next 16 bit data in another register. 5. Compare the word in AX with next word 6. Check for carry. If carry=1, go to step 8 or move to the next step. 7. Present memory content is moved to accumulator 8. Decrement BL & check for zero. If no zero go to step 3, else go to next step. 9. Stop the program.
Smallest number: Address Opcode Operand Label Mnemonics Comments MOV SI,1500 MOV BL,04 MOV AX,[SI] DEC BL INC SI INC SI CMP AX,[SI] JC L2 MOV AX,[SI] DEC BL JNZ L1 MOV [1600],AX HLT
L1
L2
Result :
EX. NO 3 Aim:
To transfer a block of 10 data word from one memory location to another in forward & reverse direction. Apparatus Required: 1) 8086 Microprocessor kit, 2) power Chord and, 3) keyboard Algorithm - Block transfer in forward direction: 1) 2) 3) 4) 5) 6) 7) Program: Address Opcode Operand Label Mnemonics MOV SI,1500 MOV DI,1600 MOV CX,0005 MOV AX, [SI] MOV [DI], AX INC SI INC SI INC DI INC DI DEC CX JNZ L1 HLT Comments Move source index register with necessary offset address Move destination index register with necessary offset address Load the count value in CX register. Move string byte from source to destination address thro accumulator. Increment the SI & DI registers. Decrement CX, if it is zero, go to next step else step 4 Stop the program.
L1
Algorithm - Block transfer in reverse direction: 1) 2) 3) 4) 5) 6) 7) 8) Move source index register with necessary offset address Move destination index register with necessary offset address Load the count value in CX register Move content of memory pointed by source index reg to accumulator Move the accumulator content to memory pointed by destination index register Increment DI and decrement SI register. Decrement CX, if zero go to next step, else go to step 4 Stop the program
Program: Address Opcode Operand Label Mnemonics MOV SI,1500 MOV DI,1600 MOV CX,0005 MOV AX, [SI] MOV [DI],AX DEC DI DEC DI INC SI INC SI DEC CX JNZ L1 HLT Comments
L1
Algorithm - Array addition: 1) Load the counter reg CX with the number of data bytes to be added & also clear AX. 2) Load SI reg with the starting address of the data 3) Initialize the carry reg with zero. Add the numbers in the array pointed by SI with content of AX along carry. 4) Check for carry. If carry exists then increment the carry reg by 1, then go to next step 5) Update the SI content to point to the next data & decrement the CX reg count. Check for zero flag. If not equal to zero go to next step. 6) Move the result in AX and carry reg to memory 7) Stop the program Address Opcode Operand Label Mnemonics MOV CX, 0005 MOV AX, 0000 MOV BX, 0000 MOV SI,1700 CLC ADC AX, [SI] JNC L1 INC BX INC SI INC SI DEC CX JNZ L2 MOV[1600],AX MOV[1602],BX HLT Comments
L2
L1
Result:
EX.NO 4
(A)TO RUN A STEPPER MOTOR AT DIFFERENT SPEED AIM: To run the stepper motor at different speeds. ALGORITHM: 1. Initialize the DI register 2. Initialize the count register 3. Send the DI data to port1(C0) 4. Initialize the DX register to generate delay 5. Increment the DI register to send the next data to motor 6. Make the loop until count register attains zero 7. Jump to start PROGRAM: Address Opcode/ Operand 1000 1000 1000 1003 1005 1007 1009 100C 100D 100F 1010 1012 1014 BF 14 10 B1 04 8A 05 E6 C0 BA 1010 4A 75 FD 47 E2 F3 EB EC
; DELAY: LOOP 1: START:
Label
PORT 1
Mnemonics
EQU 0C0H ORG 1000H MOV DI, OFFSET TABLE MOV CL, 04 MOV AL, [DI] OUT PORT1, AL MOV DX, 1010H DEC DX JNZ DELAY INC DI LOOP LOOP1 JMP START
Comments
09 05 06 0A
TABLE:
DB 9, 5, 6, 0AH
RESULT: Thus the program was written and executed successfully to vary the speed of the stepper motor.
(B)TO RUN THE STEPPER MOTOR IN BOTH FORWARD AND REVERSE DIRECTION WITH DELAY AIM: To run the stepper motor in both forward and reverse direction with delay. ALGORITHM: 1) Start the program 2) Move the data 20 to BL register 3) Load the DI register with the address of forward data 4) Call the subroutine 5) Decrement BL by 1 6) Move the data 20 to BL register 7) Load the DI register with the address of reverse data 8) Call the subroutine 9) Decrement BL by 1 10) Stop the program
Address 1000 1000 1000 1002 1005 1008 100A 100C 100F 1011 1014 1017 1019 101B 101E 1020 1022 1024
Label
PORT1 BEGIN: START: FORWD:
Mnemonics
EQU 0C0H ORG 1000H MOV BL, 20H MOV DI, OFFSET FORW CALL ROTATE DEC BL JNZ FORWD CALL DELAY MOV BL, 20H MOV DI, OFFSET REV CALL ROTATE DEC BL JNZ REVER CALL DELAY JMP START
Comments
B3 20 BF 37 10 E8 1800 FE CB 75 F6 E8 21 00 B3 20 BF 3B 10 EB 09 00 FE CB 75 F6 E8 12 00 EB E0 B1 04 8A 05 E6 C0
REVER:
ROTATE: REPT:
1026 1029 102A 102C 102D 102F 1030 1033 1034 1036 1037 103B
BA 1010 4A 75 FD 47 E2 F3 C3 BA FFFF 4A 75 FD C3 09 05 06 0A 0A 06 05 09
LOOP1:
MOV DX, 1010H DEC DX JNZ LOOP1 INC DI LOOP REPT RET MOV DX, 0FFFFH DEC DX JNZ DELAY RET
DELAY:
FORW: REV:
DB 9, 5, 6, 0AH DB 0AH, 6, 5, 9
RESULT:
Thus the program was written and executed successfully to rotate the stepper motor in both directions.
EX.NO 5 INTERFACING & PROGRAMMING WITH ADC AIM: To design an ADC converter using 8086 ALGORITHM: 1.Select the Channel and assert the ALE by sending corresponding data to C8 2. Assert the SOC(Start of Conversion) signal high and provide some delay 3.After the delay make the SOC signal low and wait for the EOC(End of Conversion) 4.Read the Converted digital data and store it in the memory location PROCEDURE: 1.Place jumper J2 in A position 2. Place jumper J5 in A position 3. Enter and execute the program 4. Vary the analog input (using trimpot) and verify the digital data displayed with that data stored in memory location 1100H PROGRAM: Address Opcode/ Operand 1000 1003 1005 1008 100A 100D 100F 1012 1015 1018 101B 101D C6 C0 10 E6 C8 C6 C0 18 E6 C8 E6 C0 01 E6 DO C6 C0 00 C6 C0 00 C6 C0 00 C6 C0 00 E6 D0 E4 D8
LOOP
Label
Mnemonics
MOV AL,10 OUT C8,AL MOV AL,18 OUT C8,AL MOV AL,01 OUT D0,AL MOV AL,00 MOV AL,00 MOV AL,00 MOV AL,00 OUT D0,AL IN AL,D8
Comments
80 E0 01 80 E0 01 75 F6 E4 C0 C7 C3 00 11 88 07 F4
AND AL,01 CMP AL,01 JNZ LOOP IN AL,C0H MOV BX,1100 MOV [BX],AL HLT
EX.NO 6
(i) AIM: To generate the square wave at the output of DAC 2. ALGORITHM: 1. 2. 3. 4. 5. 6. Initialise AL and move 00 to AL. The accumulator content of AL is then sent to C8. After calling 1010 the content of FF is moved to accumulator content AL. Again the content of AL is sent to C8 and 1010 is called. The 05FF is moved to the CX and looped the content to 1013. Return the program.
PROGRAM: Address Opcode /Operand 1000 1002 1004 1007 1009 100B 100E 1010 1013 1015 B0 00 E6 C8 E8 09 00 B0 FF E6 C8 E8 02 00 EB F0 B9 FF 05 E2 FE C3
Label Mnemonics
MOV AL,00 OUT C8,AL CALL 1010 MOV AL,FF OUT C8,AL CALL 1010 JMP 1000 MOV CX,05FF LOOP 1013 RET
Comments
(ii) AIM: To create a sawtooth wave at the output of DAC. ALGORITHM: 1. Initialise AL and move the first data 00 to AL. 2. After moving to AL, the accumulator content of AL is sent to C0. 3. The accumulator content of AL is incremented by 1. 4. after incrementing, if it is non zero, jump to 1002. 5. After checking for non zero, jump to 1000.
PROGRAM: Address Opcode/ Operand 1000 1002 1004 1006 1008 B0 00 E6 C0 FE CO 75 FA EB F6 Label Mnemonics Comments
MOV AL,00 OUT C0,AL INC AL JNZ 1002 JMP 1000
Move 00 to AL Send content of AL to C0 Increment AL by 1 If non zero jump to 1002 Jump to 1000
(iii) Aim: To generate the triangular waveform at DAC 2 output. Algorithm: 1. Initialise BL and move 00 to BL. 2. Move the content of BL to AL as its content. 3. The content moved to accumulator content AL is then sent to C8. 4. The content of BL is incremented by 1. 5. If the data is non zero, then jump to 1002. 6. Move the content of FF to BL. 7. Then the content of BL is further moved to AL. 8. After moving content to AL, it is sent to C8. 9. Decrement BL by 1. 10. If it is non zero, then jump on to 100C. 11. Jump to 1000. Program: Address 1000 1002 1004 1006 1008 100A 100C 100E 1010 1012 1014
Opcode/ Operand
Label
Mnemonics
MOV BL,00 MOV AL,BL OUT C8,AL INC BL JNZ 1002 MOV BL,FF MOV AL,BL OUT C8,AL DEC BL JNZ 100C JMP 1000
Comments Move 00 to BL Move content of BL to AL Send content of AL to C8 Increment 1 to BL If non zero,jump to 1002 Move FF to BL Move content of BL to AL Send content of AL to C8 Decrement BL If non zero jump to 100C Jump to 1000
B3 00 88 D8 E6 C8 FE C3 75 F8 B3 FF 88 D8 E6 C8 FE CB 75 F8 EB EA
EX.NO: 7 AIM:
A. To display a letter in display interfacing with 8279 B. To roll the display in 8279 using 8086 (i) TO DISPLAY A IN THE FIRST DIGIT: PROGRAM: Address Opcode Operand 1000 1002 1004 1006 1008 100A 100C 100E 1010 1012 1015 1017 1019 B0 00 E6 C2 B0 CC E6 C2 B0 90 E6 C2 B0 88 E6 C0 BO FF B9 05 00 E6 C0 E2 FC F4 Label Mnemonics MOV AL,00 OUT C2,AL MOV AL,0CC OUT C2,AL MOV AL,90 OUT C2,AL MOV AL,88 OUT C0,AL MOV AL,0FF MOV CX,OOO5 NEXT OUT CO,AL LOOP NEXT HLT Comments
(ii) ROLLING DISPLAY PROGRAM: Address 1000 1003 1006 1008 100A 100C 100E 1010 1012 1014 1016 1019 101A 101C 1500 1503 1504 1506 1200 Opcode BE 00 12 B9 0F BO 10 E6 C2 B0 CC B0 90 E6 C2 E6 C2 8A 04 E6 C0 E8 E7 04 46 E2 F6 EB E2 BA,FF,A0 4A 74, FD C3 FF,FF,FF,FF FF,FF,FF,FF 98,68,7C,C8 FF,1C,29,FF DELAY LOOP 1 NEXT Label START Mnemonics MOV SI,1200 MOV CX,000F MOV AL,10 OUT C2,AL MOV AL,CC OUT C2,AL MOV AL,90 OUT C2,AL MOV AL,[SI] OUT CO,AL CALL DELAY INC SI LOOP NEXT JMP START MOV DX,A0FF DEC DX JNZ LOOP 1 RET Comments