Explain CWD, LOOP, IMUL, SAR - Intel Microprocessor
Briefly explain following instructions in 8086 family:
a) CWD
b) LOOP
c) IMUL
d) SAR
- CWD also known as the Convert signed Word to signed Double word instruction, it is used to extend the sign bit of a word in AX register to all the bits of the DX register. Generally used before a signed word in AX. Then it is divided by another signed word using IDIV instruction. It does not affect any flag.
- LOOP: (Jump to specified label until CX = 0): As the name suggests the loop instruction is used to repeat a sequence of instructions for a specified number of time. It does not affect any flag and the number of times the loop is to be repeated is stored in the CX register.
- IMUL: This instruction is used for the multiplication of two signed numbers.The result of imul between two signed numbers is signed as well. The OF (Over flow) and CF (Carry flag) flags get affected by this instruction.
- SAR: Also known as Shift each bit of operand right, this instruction shifts each bit of the operand in a register or memory location, right by the number of bits specified. The carry flag is affected by this operation.