multiplication and division assembly language. multiplication use of ax and dx is necessary i.byte...
TRANSCRIPT
Multiplication and Division
Assembly Language
Multiplication
• Use of AX and DX is necessaryi. Byte × Byteii. Word × Wordiii. Word × Byte
Byte × Byte
• One of the operand must be in AL• Second can be register/memory• Result in AX• Example-1
MOV AL, 25HMOV BL, 65HMUL BLMOV myresult, AX
• Example-2MOV AL, DATA1MUL DATA2MOV myresult, AX
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 2F79Hresult 1 DW 2DUP(?)MOV AX, DATA3MUL DATA4MOV RESULT1, AX ;store lower resultMOV RESULT1+2, DX ;store higher result
Word × Byte
• Similar to word × word• AL contains the byte operand• AH must be zero
DATA5 DB 6BHDATA6 DW 12C3HResult3 DW 2DUP(?)MOV AL,DATA5SUB AH,AHMUL DATA6MOV [BX], offset result3MOV [BX], AX MOV [BX]+2, DX
Unsigned Multiplication Summary
Multiplication Operand 1 Operand 2 Result
Byte x byte AL Reg/memory AX
Word x word AX Reg/memory DX:AX
Word x byte AL=byte, AH=0 Reg/memory DX:AX
Unsigned Division Summary
Multiplication Numerator Denominator Quotient Remainder
Byte / byte AL=byet, AH=0 Reg/memory AL AH
Word / word AX=word,DX=0 Reg/memory AX DX
Word / byte AX=word Reg/memory AL AH
Double word/word
DXAX= double word Reg/memory AX DX
Byte/Byte
• Denominator can not be immediate• Example-1
MOV AL,DATASUB AH,AHDIV 10MOV AL, DATA1SUB AH,AHDIV DATA2MOV quot, ALMOV remain, AH
Word/Word
MOV AX,10050SUB DX,DXMOV BX,100DIV BXMOV quot, AXMOV remain,DX
Word/Byte
MOV AX, 2055MOV CL, 100DIV CLMOV quot, ALMOV remain, AH