byte division

15
PRESENTED TO: MAM SANIYA

Upload: amna-izzat

Post on 11-Jan-2017

284 views

Category:

Education


0 download

TRANSCRIPT

Page 1: Byte division

PRESENTED TO:

MAM SANIYA

Page 2: Byte division

COOL GROUP SAIRA ZAHEER 1430314 MAIRA JUNAID 1430297 RABICA AFZAL 1430309

Page 3: Byte division

OUTLINE

• DIVISION

• DIV

• IDIV

• WORD FORM

• BYTE FORM

• DIVIDE OVERFLOW

• EXAMPLES

• SIGN EXTENSION OF DIVIDEND

• WORD DIVISION

• BYTE DIVISION

• EFFECT OF FLAG

• CONCLUSION

Page 4: Byte division

DIVISIONTHERE ARE TWO DIVISON OPERATORS:

• DIV (UNSIGNED DIVIDE)

• IDIV(SIGNED DIVIDE)

• SYNTAX: DIV divisor & IDIV divisor

• BYTE FORM: Divisor is in 8-bit register.The 16-bit dividend is in AX

• RESULT OF BYTE FORM:8-bit Quotient is in AL.8-bit Remainder is in AH

Page 5: Byte division

WORD FORM:

Divisor is a 16-bit register. The 32-bit dividend is in DX:AX

RESULT OF WORD FORM:16-bit Quotient is in AX.16-bit Remainder is in DX

DIVISOR NOT BE A CONSTANT

Page 6: Byte division

DIVIDE OVERFLOW

If the divisor is much smaller than the dividend, the Quotient will be too big to fit in the specified destination that is AL or AX .It gives error “DIVIDE OVERFLOW”

Page 7: Byte division

EXAMPLE OF DIVIDE OVERFLOWSUPPOSE AX CONTAINS 00FBH AND BL CONTAINS FFH

instruction Decimal quotient

Decimal Reminder

AX AL

DIV BL 0 251 FB 00

IDIV BL DIVIDE OVERFLOW

Page 8: Byte division

EXAMPLE OF DIV SUPPOSE DX CONTAINS 0000H,AX CONTAINS 0005H,AND BX CONTAINS 0002H 0002H.

Instruction Decimal quotient

Decimal remainder

AX DX

DIV BX 2 1 0002 0001

Page 9: Byte division

EXAMPLE OF IDIV SUPPOSE DX CONTAINS 0000H,AX CONTAINS 0005H,AND BX CONTAINS FFFEH

instruction Decimal quotient

Decimal remainder

AX DX

IDIV BX -2 1 FFFE 0001

Page 10: Byte division

SIGN EXTENSION OF THE DIVIDEND

• WORD DIVISIONFOR DIV,DX should be cleared.FOR IDIV,DX should sign extension of

AX. The instruction CWD will do the extension.

Page 11: Byte division

EXAMPLE OF WORD DIVISIONDIVIDE-1250 BY 7

• MOV AX,-1250 ;AX gets dividend• CWD ;Extend sign to DX• MOV BX,7 ;BX has divisor• IDIV BX ;AX gets quotient, ;DX has remainder

Page 12: Byte division

BYTE DIVISION

FOR DIV,AH should be cleared.FOR IDIV,AH should the sign extension of

AL. The instruction CBW (Convert byte to word) will do the extension.

Page 13: Byte division

EXAMPLE OF BYTE DIVISIONDIVIDE THE SIGNED VALU OF THE BYTE VARIABLE XBYTE BY -7

• MOV AL,XBYTE ;AL has dividend• CBW ;Extend sign to AH• MOV BL,-7 ;BL has divisor• IDIV BL ;AL has quotient,AH

has remainder

Page 14: Byte division

EFFECT OF FLAGES

THERE IS NO EFFECT OF CBW AND CWD ON THE FLAGS

Page 15: Byte division

THANKS FOR YOUR ATTENTIONSPECIAL THANX TO MOMINA FOR HELPING US IN PREPARATION