Divide Overflow and Sign Extension 

The CBW and CWD instructions:

CBW and CWD are two instructions used to facilitate division of 8 and 16 bit signed numbers. Since division requires a double-width dividend, CBW converts an 8-bit signed number (in AL) to a word. The MSB of the AL register is duplicated into AH register.
Similarly, CWD converts a 16-bit signed number to a 32-bit signed number (DX,AX). Here the MSB of the AX register is duplicated into AX register.

Divide Overflow:

Overfow occurs when the result of a division does not fit in a byte if the dividend is a word, and in a word if the dividend is a double word. Such an oberflow terminates the program with "Divide Overflow" message! This needs to be anticipated and hence can be avoided.

Overflow occurs if:
	Byte form: AH>=divisor
	Word form: DX>=divisor
Preparing Dividend

To avoid overflow, the dividend has to be prepared as follows.
To divide a word in AX by a word, AX must be converted to a doubleword in DX:AX.

If signed: 
	CWD  (called sign-extension)
If unsigned: 

To divide a word in AL by a byte, AL must be converted to a word in AX.

If signed: 
	CBW (these do not affect Flags)
If unsigned: