Presentation is loading. Please wait.

Presentation is loading. Please wait.

Multiplication and Division

Similar presentations


Presentation on theme: "Multiplication and Division"— Presentation transcript:

1 Multiplication and Division
Assembly Language

2 Multiplication Use of AX and DX is necessary Byte × Byte Word × Word
Word × Byte

3 Byte × Byte One of the operand must be in AL
Second can be register/memory Result in AX Example-1 MOV AL, 25H MOV BL, 65H MUL BL MOV myresult, AX

4 Example-2 MOV AL, DATA1 MUL DATA2 MOV myresult, AX

5 Word × Word One of the operand must be in AX
Second can be register/memory Result in DXAX Example-1 DATA3 DW 2387H DATA4 DW 2F79H result 1 DW 2DUP(?) MOV AX, DATA3 MUL DATA4 MOV RESULT1, AX ;store lower result MOV RESULT1+2, DX ;store higher result

6 Word × Byte Similar to word × word AL contains the byte operand
AH must be zero DATA5 DB 6BH DATA6 DW 12C3H Result3 DW 2DUP(?) MOV AL,DATA5 SUB AH,AH MUL DATA6 MOV [BX], offset result3 MOV [BX], AX MOV [BX]+2, DX

7 Unsigned Multiplication Summary
Operand 1 Operand 2 Result Byte x byte AL Reg/memory AX Word x word DX:AX Word x byte AL=byte, AH=0

8 Unsigned Division Summary
Multiplication Numerator Denominator Quotient Remainder Byte / byte AL=byet, AH=0 Reg/memory AL AH Word / word AX=word,DX=0 AX DX Word / byte AX=word Double word/word DXAX= double word

9 Byte/Byte Denominator can not be immediate Example-1 MOV AL,DATA
SUB AH,AH DIV 10 MOV AL, DATA1 DIV DATA2 MOV quot, AL MOV remain, AH

10 Word/Word MOV AX,10050 SUB DX,DX MOV BX,100 DIV BX MOV quot, AX MOV remain,DX

11 Word/Byte MOV AX, 2055 MOV CL, 100 DIV CL MOV quot, AL MOV remain, AH


Download ppt "Multiplication and Division"

Similar presentations


Ads by Google