Program to find 2’s complement of an 8-bit number 8086 Microprocessor


OBJECT:Write a program to convert the string data to its two’s complement form.
INSTRUMENT REQUIRED: 8086 Microprocessor Trainer Kit.

0200 BE 00 03 MOV SI,0300H
0203 BF 00 04 MOV DI,0400H
0206 B9 0A 00 MOV CX,000AH
0209 AC LODSB  
020A F6 D8 NEG AL
020D E0 FA LOOP NZ 0209
020F F4 HLT  


To solve the given objective we have taken TEN hexadecimal numbers in the memory locations of 0300H and 0309H and then individually taken their two’s complement and store the result in the memory location from 0400H to 0409H.

To solve the given objective we have taken the following steps:

  1. Move the source index register (SI) pointer to the location of the first number to be complemented.
  2. Move the destination index (DI) pointer to the location of the first memory location  where the complemented number is to be stored.
  3. Increment the counter register CX to 10 as 10 numbers are to be complemented.
  4. Move the data to be complemented which is being pointed to by SI to the AL register and simultaneously increment the SI pointer to point to the next memory location using the LODSB.
  5. Now carry out the two’s complement operation using NEG AL instruction which two’s complements the data in the AL register and stores the result back into the AL register.
  6. Move the data which has been complemented and is presently stored in the AL register to the memory location being pointed to by DI and simultaneously increment the DI pointer to point to the next memory location using STOSB instruction.
  7. Repeat this operation using a LOOP instruction until each of the 10 numbers has been complemented and then Halt.


0300H 01
0301H 02
0302H 03
0303H 04
0304H 05
0305H 06
0306H 07
0307H 08
0308H 09
0309H 11


0400H FF
0401H FE
0402H FD
0403H FC
0404H FB
0405H FA
0406H F9
0407H F8
0408H F7
0409H EF

RESULT: The string of data has been converted to its complement form and has been stored in the memory locations from 0400H to 0409H.


  1. NEG AL: This instruction obtains the two’s complement of the content of an 8-bit or 16-bit specified register (in this case AL) or memory location(s).
  2. LOOP NZ: The instruction LOOP NZ is used to repeat a sequence of instructions for the specified number of times or until the zero flag ZF becomes 1.
  3. STOSB: This instruction is used for storing 8-bit string data.
  4. LODSB: LODS instruction loads 8-bit or 16-bit data from memory location(s) addressed by SI register into AL or AX register. For byte loading LODSB instruction is used.
  5. HLT: This instruction stops program execution. The processor stops fetching and executing instructions.


Program to find 2’s complement of an 8-bit number 8086 Microprocessor

Most Important Question for Exam

1. The BIU contains FIFO register of size________bytes

Answer is C)

2. The BIU prefetches the instruction for memory and store them in_________

Answer is D)

3. The 1 MB byte of memory can be divide into __________segment

Answer is C)
64 Kbyte

4. The push source copies a word from source to____________

Answer is D)

5. LDs copies to consecutive words from to register and____________

Answer is C)

6. INC destination increments the content of destination by_____________

Answer is D)

7. IMUL source is a signed_____________

Answer is D)

8. __________destination invert each bit of destination

Answer is B)

9. The JS is called as__________

Answer is C)
Jump sign bit

10. Instruction providing both segment base and offset address are called__________

Answer is C)
Far type

11. The conditional branch instruction specify____________for branching

Answer is D)

12. The Microprocessor determines whether specified condition exist or not by testing the_______

Answer is C)
Conditional Flag

13. The LES copies to word from memory to register and_____________

Answer is B)

14. The ___________translate a byte from one code to another code

Answer is B)

15. The __________ contains and offset instead of actual address

Answer is C)

16. The 8086 fetches instruction one after another from_____________of memory

Answer is C)
Code Segment

17. The BIU contains FIFO register of size 6 bytes called___________

Answer is D)

18. The ___________is required to sysnchronize the internal operands in the processor CLK Signal

Answer is D)
UR Signal

19. The pin of minimum mode AD0-AD15 has________address

Answer is C)
20 bit

20. The pin of minimum mode AD0-AD15 has ______ data bus

Answer is D)
20 bit

21. The address bits are sent out on lines through______________

Answer is B)

22. _________is used to write into memory

Answer is C)

23. The functionof pins from 24 to 31 depend of the mode in which_________is operating

Answer is C)

24. The RD, WR, M/IO is the heart of control for a_____________mode

Answer is D)

25. In a minimum mode there is a __________on the system bus

Answer is D)

26. If MN/MX is low the 8086 operates in_________mode

Answer is B)
Both C & D

27. In max mode control bus signal so S1 and S2 are sent out in________________form

Answer is C)

28. The ________bus controller device decodes the signals to produce the control bus signal

Answer is B)

29. A_________instruction at the end of interrupt service program takes the execution back to the interrupt program

Answer is C)

30. The main concerns of the_________are to define a flexible set of commands

Answer is C)
Memory Interface

Related Link