PROGRAM NO.7
OBJECT:Write a program to convert the string data to its two’s complement form.
INSTRUMENT REQUIRED: 8086 Microprocessor Trainer Kit.
PROGRAM:
MEMORY LOCATION | MACHINE CODE | OPCODE | OPERAND |
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 |
020C | AA | STOSB | |
020D | E0 FA | LOOP NZ | 0209 |
020F | F4 | HLT |
DESCRIPTION:
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:
- Move the source index register (SI) pointer to the location of the first number to be complemented.
- Move the destination index (DI) pointer to the location of the first memory location where the complemented number is to be stored.
- Increment the counter register CX to 10 as 10 numbers are to be complemented.
- 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.
- 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.
- 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.
- Repeat this operation using a LOOP instruction until each of the 10 numbers has been complemented and then Halt.
INPUT:
MEMORY LOCATION | VALUE |
0300H | 01 |
0301H | 02 |
0302H | 03 |
0303H | 04 |
0304H | 05 |
0305H | 06 |
0306H | 07 |
0307H | 08 |
0308H | 09 |
0309H | 11 |
OUTPUT:
MEMORY LOCATION | VALUE |
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.
COMMENTS:
- 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).
- 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.
- STOSB: This instruction is used for storing 8-bit string data.
- 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.
- HLT: This instruction stops program execution. The processor stops fetching and executing instructions.
FLOWCHART:

Most Important Question for Exam
6
Queue
64 Kbyte
Stack
DS
1
Multiplication
NOT
Jump sign bit
Far type
Conditions
Conditional Flag
ES
XLAT
IP
Code Segment
Queue
UR Signal
20 bit
20 bit
A16-19
WR
8086
Minimum
Single
Both C & D
Encoded
External
Return
Memory Interface
Related Link
- 8086 Instruction Hex Code
- Write a program to two add 16 bit Hexadecimal numbers without carry.
- Write a program to two add 16 bit Hexadecimal numbers with carry.
- Write a program to find the greatest number from an array of 10 numbers.
- Write a program to calculate the factorial of a number.
- Write a program to multiply two 16-bit numbers result should be greater than 16 bit.
- Write a program to input 5 numbers and arrange them in descending order.
- Write a program to convert the string data it’s Two’s complement form.
- Write a program to read 8 bit data from Port B. Complement this data & send it back to Port A of
- Write a program to move a block of data from one memory location to another. Input Value
- Write a program to find Gray code equivalent of a Binary number using Lookup Table.
- Microprocessor 8086 Video Play List