Presentation is loading. Please wait.

Presentation is loading. Please wait.

Assembly Language Integer Arithmetic. Flags  MUL Carry and Overflow: 1, if the upper half of the product is not equal to zero.  IMUL One-Operand Format.

Similar presentations


Presentation on theme: "Assembly Language Integer Arithmetic. Flags  MUL Carry and Overflow: 1, if the upper half of the product is not equal to zero.  IMUL One-Operand Format."— Presentation transcript:

1 Assembly Language Integer Arithmetic

2 Flags  MUL Carry and Overflow: 1, if the upper half of the product is not equal to zero.  IMUL One-Operand Format  Carry and Overflow: 1, if the upper half of the product is not a sign extension of the lower half Two-Operand Formats, Three-Operand Formats  Carry and Overflow: 1, if significant digits are lost

3 IMUL Instruction  One-Operand Formats IMUL r/m8; AX=AL*r/m byte IMUL r/m16; DX:AX=AX*r/m word IMUL r/m32; EDX:EAX=EAX*r/m doubleword  Two-Operand Formats The product is the first operand. The first operand must be a register. IMUL r16, r/m16 IMUL r16, imm8 IMUL r16, imm16

4 IMUL Instruction  Two-Operand Formats IMUL r32, r/m32 IMUL r32, imm8 IMUL r32, imm16  Three-Operand Formats The product is stored at the first operand. The first operand is a register, the second operand can be a register or memory, and the third is an immediate value

5 IMUL Instruction IMUL r16, r/m16, imm8 IMUL r16, r/m16, imm16 IMUL r32, r/m32, imm8 IMUL r32, r/m32, imm32

6 Assembly Language Advanced Procedures

7 Examples  ArryFill.asm ArryFill.asm  Csum.asm Csum.asm  Fact.asm Fact.asm

8 Exercise 1  Write a recursive implementation of Euclid's algorithm for finding the greatest common divisor (GCD) of two integers. Note: we will only test this procedure with nonnegative integers.  The GCD algorithm involves integer division using a recursive implementation, described by the following C++ code:  int GCD(int x, int y)  {  n = x % y;  if (n == 0)  return y;  else  return GCD(y, n);  }

9  Implement this function in assembly language and write a test program that calls the function several times, passing it different values. Display all results on the screen.  ch08_05.exe ch08_05.exe

10  Due date: 95/12/21  ftp://eec751@ftp.csie.nuk.edu.tw ftp://eec751@ftp.csie.nuk.edu.tw  Zip your files as a09xxxxx_951214.zip

11 Assembly Language Structures and Macros

12 Examples  List.asm List.asm  Walk.asm Walk.asm


Download ppt "Assembly Language Integer Arithmetic. Flags  MUL Carry and Overflow: 1, if the upper half of the product is not equal to zero.  IMUL One-Operand Format."

Similar presentations


Ads by Google