OBJECT:Write a program to convert the string data to its two’s complement form.
INSTRUMENT REQUIRED: 8086 Microprocessor Trainer Kit.
|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|
|020D||E0 FA||LOOP NZ||0209|
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.
RESULT: The string of data has been converted to its complement form and has been stored in the memory locations from 0400H to 0409H.
- 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.
Most Important Question for Exam
Jump sign bit
Both C & D
- 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