# Introduction to Computer Engineering by Richard E. Haskell Multiplication and Division Instructions Module M16.4 Section 10.4.

## Presentation on theme: "Introduction to Computer Engineering by Richard E. Haskell Multiplication and Division Instructions Module M16.4 Section 10.4."— Presentation transcript:

Introduction to Computer Engineering by Richard E. Haskell Multiplication and Division Instructions Module M16.4 Section 10.4

Introduction to Computer Engineering by Richard E. Haskell Binary Multiplication

Introduction to Computer Engineering by Richard E. Haskell Binary Multiplication 13 x 12 26 13 156 1101 1100 0000 1101 10011100 9 C = 156

Introduction to Computer Engineering by Richard E. Haskell Hex Multiplication

Introduction to Computer Engineering by Richard E. Haskell Hex Multiplication 61 x 90 5490 3D x 5A 262 A x D = 82, A x 3 = 1E + 8 = 26 131 5 x D = 41, 5 x 3 = F + 4 = 13 1572 16 = 5490 10 Dec Hex

Introduction to Computer Engineering by Richard E. Haskell Hex Multiplication 0000 B0 3D MOV AL,3DH ;AL=3DH 0002 B3 5A MOV BL,5AH ;BL=5AH 0004 F6 E3 MUL BL ;AX=ALxBL product = 1572H is in AX

Introduction to Computer Engineering by Richard E. Haskell MUL BL 100 F6 11011 = E3 E3

Introduction to Computer Engineering by Richard E. Haskell 16-Bit Hex Multiplication 31A4 x1B2C 253B0 4 x C = 30 A x C = 78 + 3 = 7B 1 x C = C + 7 = 13 3 x C = 24 + 1 = 25

Introduction to Computer Engineering by Richard E. Haskell 16-Bit Hex Multiplication 31A4 x1B2C 253B0 6348 2 x 4 = 8 2 x A = 14 1 x 2 = 2 + 1 = 3 2 x 3 = 6

Introduction to Computer Engineering by Richard E. Haskell 16-Bit Hex Multiplication 31A4 x1B2C 253B0 6348 2220C 4 x B = 2C A x B = 6E + 2 = 70 1 x B = B + 7 = 12 3 x B = 21 + 1 = 22

Introduction to Computer Engineering by Richard E. Haskell 16-Bit Hex Multiplication 31A4 x1B2C 253B0 6348 2220C 31A4 0544D430 0000 B8 A4 31 MOV AX,31A4H ;AX=31A4H 0003 BB 2C 1B MOV BX,1B2CH ;BX=1B2CH 0006 F7 E3 MUL BX ;DX:AX = AX x BX

Introduction to Computer Engineering by Richard E. Haskell Unsigned MUL Instruction

Introduction to Computer Engineering by Richard E. Haskell Unsigned Multiplication Dec Hex 165 x 36 990 495 5940 A5 x 24 294 14A 1734 5940 10 = 1734 16 But A5 = 10100101 can be a signed number 2’s comp = 01011011 = 5BH = 91 10 Therefore, A5 can represent -91

Introduction to Computer Engineering by Richard E. Haskell Signed Multiplication Dec -91 x 36 546 273 -3276 3276 10 = 0CCC 16 = 0000 1100 1100 1100 2’s comp = 1111 0011 0011 0100 = F334H Therefore, for signed multiplication A5H x 24H = F334H and not 1734H The 8086 IMUL instruction performs SIGNED multiplciation

Introduction to Computer Engineering by Richard E. Haskell Signed Multiplication 0000 B0 A5 MOV AL,A5H ;AL=A5H 0002 B3 24 MOV BL,24H ;BL=24H 0004 F6 EB IMUL BL ;AX=ALxBL product = F334H is in AX

Introduction to Computer Engineering by Richard E. Haskell Signed IMUL Instruction

Introduction to Computer Engineering by Richard E. Haskell Binary Division 100111001100 1 0111 1 1 1100 0011 0 0 0000 01100 1 1100 0000 D C 9C

Introduction to Computer Engineering by Richard E. Haskell Hex Division EE BC2F C C x E = A8 C x E = A8 + A = B2 B28 9AF A

Introduction to Computer Engineering by Richard E. Haskell Hex Division EE BC2F C A x E = 8C A x E = 8C + 8 = 94 B28 9AF A 94C 63 Dividend = BC2F Divisor = EE Quotient = CA Remainder = 63

Introduction to Computer Engineering by Richard E. Haskell Hex Division 0000 B8 2F BC MOV AX,0BC2FH ;AX=BC2FH 0003 B3 EE MOV BL,0EEH ;BL=EEH 0006 F6 F3 DIV BL ;AL=AX/BL quotient = AL = CAH remainder = AH = 63H EE BC2F C B28 9AF A 94C 63

Introduction to Computer Engineering by Richard E. Haskell 8086 Division Instructions

Introduction to Computer Engineering by Richard E. Haskell Divisor may be too small E BC2F D71 rem 1 Quotient does not fit in AL Causes a “divide by zero” interrupt

Introduction to Computer Engineering by Richard E. Haskell Interrupt Vector Table

Introduction to Computer Engineering by Richard E. Haskell IP CS 000 004 008 00C 010 014 012345012345 CS IP Interrupt Vector Table Offset address Type number Division by zero Single Stepping NMI Interrupt 1-Byte INT (opcode = CC) Signed overflow (INTO) Print screen

Download ppt "Introduction to Computer Engineering by Richard E. Haskell Multiplication and Division Instructions Module M16.4 Section 10.4."

Similar presentations