Addition of two 16 bits numbers with carry using 8086 Microprocessor

PROGRAM NO.2

OBJECT: Write a program to add two 16 bit hexadecimal numbers with carry.
INSTRUMENT REQUIRED: 8086 Microprocessor Trainer Kit.
PROGRAM:

MEMORY LOCATION MACHINE CODE OPCODE OPERAND
0208 B1 00 MOV CL,00H
020A BE 00 02 MOV SI,0200H
020D 8B 04 MOV AX,[SI]
020F 46 INC SI
0210 46 INC SI
0211 8B 1C MOV BX,[SI]
0213 03 C3 ADD AX,BX
0215 73 02 JNC    L1  
0217 FE C1 INC CL
0219 BF 04 02 L1  : MOV DI,0204H
021C 89 05 MOV [DI],AX
021E 47 INC DI
021F 47 INC DI
0220 89 0D MOV [DI],CL
0222 F4 HLT  

DESCRIPTION:

To solve the given objective, we have taken two hexadecimal numbers in the memory locations of 0200H and 0203H and added them and stored the result in the memory location of 0204H, we have also stored the carry in the memory location 0206H
To solve the given objective, we have taken the following steps:

  1. Initialize the counter register CL to 0.
  2. Move the source index register (SI) pointer to the location of the first number.
  3. Store the first number in the AX register using SI.
  4. Double increment the SI pointer to point to the memory location of the second number.
  5. Store the second number in the BX register using SI.
  6. Now apply ADD operation to add the numbers in the registers AX and BX and store the result in AX.
  7. Jump instruction is used that increments the carry counter if there is no carry else increments the carry counter.
  8. Move the destination index (DI) pointer to point to the memory location where the result is to be stored.
  9. Move the result from the AX register to the destination using DI.
  10. Finally increment the DI to point to the location to store the carry bit and move the carry bit to the destination before halting.

INPUT VALUE:

MEMORY LOCATION VALUE
0200H FF
0201H FF
0202H FF
0203H FF
0204H 00
0205H 00
0206H 00
0207H 00

OUTPUT:

MEMORY LOCATIONVALUE
0204HFE
0205HFF
0206H01
0207H00 or Return Garbej Value

RESULT:The addition of the two hexadecimal numbers FFFFh and FFFFh yields FFFEh as the sum and 0001 as the carry.

COMMENTS:

1.  MOV SI,0200H: 16 bit data can be moved using immediate addressing . 0200 is moved to source index.

2.  ADD AX,BX: Contents in the accumulator and the base register are added.

3.  INC SI: The content of a specified 8-bit or 16-bit register or memory location(s) is incremented by one by this instruction.

4.  HLT: This instruction stops program execution. The processor stops fetching and executing instructions.

FLOWCHART:

Addition of two 16 bits numbers with carry using 8086 Microprocessor


Most Important Question for Exam

1. Eight of the register are known as:




Answer is B)
General purpose register


2. The four Index register can be used for:




Answer is C)
Arithmatic operation


3. IP Stand for:




Answer is D)
Instruction Pointer

4. CS Stand for:




Answer is D)
Code Segment

5. DS Stand for:




Answer is B)
Deta Segment

6. Which are the segment:




Answer is C)
ES:Extra Segment

7. 8088 Microprocessor differs with 8086 Microprocessor in




Answer is B)
Data without on the output

8. In 8086 Microprocessor one of the following statements is not true.




Answer is A)
Coprocessor is interfaced in MIN mode

9. In 8086 Microprocessor the following has the highest priority among all type interrupts.




Answer is B)
NMI

10. BHE of 8086 Microprocessor signla is used to interface the




Answer is A)
Odd bank memory

11. The advantage of memory mapped I/O over I/O mapped I/o is.




Answer is C)
All the above

12. In 8086 the overflow flag is set when




Answer is A)
Signed numbers go out of their range

13. Address line for RST3 is ?




Answer is B)
0018H

14. Which Processor structure is pipelined




Answer is A)
All x86 Processor

15. Can ROM bes used asstack?




Answer is B)
No

16. What does Microprocessor speed depends on?




Answer is C)
Clock

17. In 8086, Example for Non maskable interrupts are




Answer is C)
Trapb

18. What is meant by Maskable interrupts?




Answer is B)
An Interrupt that can be turned off by the programmer

19. RIM is used to check whether,________




Answer is B)
The Interrupt is Masked or not

20. What is SIM




Answer is A)
Set Interrupt Mask.

21. Why 8085 Processor is called and 8 bit Processor?




Answer is C)
Because 8085 Processor has 8 bit ALU.

22. Which stack is used in 8085?




Answer is B)
LIFO

23. What are software interrupts?




Answer is D)
RST0-7

24. Which interrupt not level sensetive in 8085?




Answer is C)
RST7.5 is a raising edge-trigging interrupt.

25. What are level Triggering interrupts?




Answer is B)
RST6.5 & RST5.5

26. What is the RST for the TRAP?




Answer is A)
RST4.5

27. Which of the following is hardware interrupts?




Answer is A)
B & C

28. In 8085 name the 16 bit registers?




Answer is A)
B & C

29. The access method used for maganetic tape is ______________




Answer is B)
Sequential

30. By Processing we understand ____________________




Answer is D)
None of the above


Related Link