




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





























































































(Approved by AICTE, New Delhi. Affiliated to Anna University, Chennai) (An ISO 9001: 2015 Certified Institution) ANGUCHETTYPALAYAM, PANRUTI โ 607 106.
.
Start
Initialize count as zero for carry
Get the two data
Add the datas
Carry
Yes
Increment the count
Store the result & carry
Stop
(i) Start the process (ii) Initialize the count value (iii) Get the two data and subtract it. (iv) If carry exists, get the 2โs complement of the value. (v) Store the result and carry value. (vi) Stop the process.
Labe l Address Mnemonics Hex code Comments
Opcode Operand 1000 MOV CL, 00 C6, C1, 00 ; Initialize the count
1003 MOV AX, [1100] 8B, 06, 00, 11 ; Move
st data to accumulator
1007 MOV BX, [1102] 8B, 1E, 02, 11 ; Move 2
nd data to โBโ register 100B SUB BX, AX 29, C3 ; Subtract the two datas 100D JNC LOOP1 73, 05 ; Jump on no carry 100F INC CL FE, C1 ; Increment the counter 1011 NOT BX F7, D3 ; Get the complement value 1013 INC BX 43 ; Increment the value LOOP1: 1014 MOV [1104], BX 89, 1E, 04, 11 ; Store the result 1018 MOV [1106], CL 88, 0E, 06, 11 ; Store the carry 101C HLT F4 ; Stop the process
OUTPUT
16 โ BIT SUBTRACTION
Address Input Address Out put
1100 76 1104 31 1101 86 1105 65 1102 45 1106 00 1103 81
(i) Start the process (ii) Get the two values (iii) Multiply the two values. (iv) Store the result and overflow (v) Stop the process.
Label Address Mnemonics Hex code Comments
Opcode Operand 1000 MOV SI, 1100 C7, C6,00, 11 ; Move the source index 1004 MOV AX, [SI] 8B, 04 value 1006 MOV BX, [SI + 02] 8B, 54, 02 ; Move the first data 1009 MUL BX F7, E3 ; Get the second data 100B MOV [SI + 04], 89, 44, 04 ; Multiply the data 100E MOV AX 89, 54, 0b ; Store the result 1011 HLT [SI + 06], F4 ; Store the over flow DX ; Stop the process
Address Input
1100 11 1101 11 1102 00 1103 11
Address Output
1104 00 1105 21 1106 22 1107 01
Multiplication:-
Start
Get the two values
Multiply the values
Store the result & overflow
Stop
Label Address Mnemonics Hex code Comments
Opcode Operand 1000 MOV SI, 1100 C7, C6,00, 11 ; Get the source index value 1004 MOV Ax, [SI] 8B, 04 ; Get the first data 1006 MOV DX, [SI + 8B, 54, 02 ; Initialize โDXโ register 1009 MOV 02] 8B, 5C, 04 value 100C DIV BX, [SI + 04] F7, E3 ; Get the dividend value 100E MOV BX 89, 44, 06 ; Divide the value 1011 MOV [SI + 06], 89, 54, 08 ; Move the quotient 1014 HLT AX F4 ; Move the remainder & store [SI + 08], ; Stop the process DX
Address Input
1100 42 (DIVIDEND) 1101 24 1102 00 1103 00
1104 02(DIVISOR) 1105 00
Address Output 1106 21(QUOTIENT) 1107 12 1108 00(REMAINDER) 1109 00
Thus the assembly language program for 16 Bit Arithmetic and Logical operations has been done and verified.
VIVA QUES TIONS AND ANSWERS
1. What is a Microprocessor? Microprocessor is a CPU fabricated on a single chip, program-controlled device, which fetches the instructions from memory, decodes and executes the instructions. 2. What is Instruction Set? It is the set of the instructions that the Microprocessor can execute. 3. What is Clock Speed? Clock speed is measured in the MHz and it determines that how many instructions a processor can processed. The speed of the microprocessor is measured in the MHz or GHz. 4. What are the features of Intel 8086? Features: Released by Intel in 1978 Produced from 1978 to 1990s A 16-bit microprocessor chip. Max. CPU clock rate:5 MHz to 10 MHz Instruction set: x86- 5. What are the flags in 8086? In 8086 carry flag, Parity flag, Auxiliary carry flag, Zero flag, Overflow flag, Trace flag, Interrupt flag, Direction flag, and Sign flag.
Start
Load the address of the array in SI register
Load the count in CL register and decrement by one
2
Load the address of array in SI regist er
Load t he count in CH regist er and decre ment by one 1
Incre ment the array pointer (SI)
1
Get an element of array in AL register
2 Incre ment the array pointer (SI)
Compare next element of array with AL
Is No CF = 1?
Yes
Exchange AL and me mory pointed by SI
Exchange AL and me mory pointed by SI โ 1
Decrement CH count
Yes Decrement CL count
No
Yes Stop
Labe l Address Mnemonics Hex code Comments
Opcode Operand ST ART : 1000 MOV SI, 1100H C7 C6 00 11 ; Set SI register as pointer for array 1004 MOV CL, [SI} 8A 0C ; Set CL as count for N โ 1 repetitions 1006 DEC CL FE C RE P E AT 1008 MOV SI, 1100H C7 C6 00 11 ; Initialize pointer 100C MOV CH, [SI] 8A 2C : Set CH as count for N โ 1 comparisons 100E DEC CH FE CD 1010 INC SI 46 ; Decrement the count RE P CO M 1011 MOV AL, [SI] 8A 04 ; Get an element of array in AL register 1013 INC SI 46 1014 CMP AL, [SI] 3A 04 ; Compare with next element of array ; in memory 1016 JC AHEAD 72 05 ; It AL register is lesser than memory, โthen go to AHEAD 1018 XCHG AL, [SI] 86 04 ; If AL is less than memory then ; exchange 101A XCHG AL, [SI โ 1] 86 44 FF ; the content of memory pointed by ; SI and the previous memory location AHEAD 101D DEC CH FE CD ; Decrement the count for comparisons 101F JNZ REPCOM 75 F0 ; Repeat comparisons until CH count is ; zero 1021 DEC CL FE C9 ; Decrement the count for repetitions 1023 JNZ REPEAT 75 E3 ; Repeat N โ 1 comparisons until CL count is zero 1025 HLT F
Address Input
1100 05 โ c ount 1101 09 1102 49 1103 24 1104 32 1105 64
Address Output 1100 05 โ count 1101 09 1102 24 1103 32 1104 49 1105 64
Thus the assembly language program to sort an array of data in ascending order using 8086
has been done and verify successfully.
Start
Load the address of the array in SI register
Load the count in CL register and decre ment by one
2
Load the address of array in SI regist er
Load t he count in CH regist er and decre ment by one 1
Incre ment the array pointer (SI)
1 Get an elem ent of array in AL regist er
2 Incre ment the array pointer (SI)
Compare next element of array with AL
No
Is CF = 0?
Yes
Exchange AL and me mory pointed by SI
Exchange AL and memory pointed by SI โ 1
Decrement CH count
No
Is ZF = 1?
Yes Decrement CL count
No
Is ZF = 1?
Yes Stop
Labe l Address Mnemonics Hex code Comments
Opcode Operand ST ART : 1000 MOV SI, 1100H C7 C6 00 11 ; Set SI register as pointer for array 1004 MOV CL, [SI} 8A 0C ; Set CL as count for N โ 1 repetitions 1006 DEC CL FE C RE P E AT 1008 MOV SI, 1100H C7 C6 00 11 ; Initialize pointer 100C MOV CH, [SI] 8A 2C : Set CH as count for N โ 1 comparisons 100E DEC CH FE CD 1010 INC SI 46 ; Increment the count RE P CO M 1011 MOV AL, [SI] 8A 04 ; Get an element of array in AL register 1013 INC SI 46 1014 CMP AL, [SI] 3A 04 ; Compare with next element of array ; in memory 1016 JNC AHEAD 73 05 ; It AL is greater than memory, then go ; to AHEAD 1018 XCHG AL, [SI] 86 04 ; If AL is less than memory then 101A XCHG AL, [SI โ 1] 86 44 FF ; exchange the content of memory ; pointed by SI and the previous memory ; location AHEAD 101D DEC CH FE CD ; Decrement the count for comparisons 101F JNZ REPCOM 75 F0 ; Repeat comparisons until CH count is zero 1021 DEC CL FE C9 ; Decrement the count for repetitions 1023 JNZ REPEAT 75 E3 ; Repeat N โ 1 comparisons until CL count is zero 1025 HLT F
Address Input
1100 05 โ c ount 1101 09 1102 49 1103 24 1104 32 1105 64
Address Output 1100 05 โ count 1101 64 1102 49 1103 32 1104 24 1105 09
Thus the assembly language program to sort an array of data in descending order using 8086
has been done and verify successfully.
Start
Load the address of array in SI register
Load the address of result in DI register
Set CL as byte count
Incre ment array pointer (SI)
Get the first byte of array in AL register
Decrement the byte count
B Increm ent array point er (SI)
Get the next byte of array in BL register
Compare AL and BL register
MoveNo BL to AL
Decrement byte count (CL)
B No
Is ZF = 1?
Yes Store AL in me mory
Stop
Label Address Mnemonics Hex code Comments
Opcode Operand ST ART 1000 MOV SI, 1100H C7 C6 00 11 ; Set SI register as pointer for array 1004 MOV DI, 1200H C7 C7 00 12 ; Set DI register as pointer for result 1008 MOV CL, [SI] 8A 0C ; Set CL as count for elements in the array 100A INC SI 46 ; Increment the address pointer 100B MOV AL, [SI] 8A 04 ; Set first data as smallest 100D DEC CL FE C9 ; Decrement the count AGAI N 100F INC SI 46 ; Make SI to point to next data in array 1010 MOV BL, [SI ] 8A 1C ; Get the next data in BL register 1012 CMP AL, BL 38 D8 ; Compare current smallest data in AL ; with BL 1014 JC AHEAD 72 02 ; If carry is set then AL is less than BL ; hence proceed to AHEAD 1016 MOV AL, BL 88 D8 ; If carry is not set then make BL as ; current smallest AHE AD 1018 DEC CL FE C9 ; Decrement the count 101A JNZ AGAIN 75 F3 ; If count is not zero repeat search 101C MOV [DI], AL 88 05 ; Store the smallest data in memory 101E HLT F
Smallest no in the array Address Input 1100 ( 05) count (^1101) 22 (^1102) AA (^1103) FF 1104 45 (^1105) 50 Address Output 200 22
Thus the assembly language program for smallest data in an array using 8086 has been done
and verify successfully.