Assembly Language Integer Arithmetic Flags MUL l Carry
Assembly Language Integer Arithmetic
Flags ¡ MUL l ¡ Carry and Overflow: 1, if the upper half of the product is not equal to zero. IMUL l One-Operand Format ¡ l 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
IMUL Instruction ¡ One-Operand Formats l l l ¡ IMUL r/m 8 IMUL r/m 16 IMUL r/m 32 ; AX=AL*r/m byte ; DX: AX=AX*r/m word ; EDX: EAX=EAX*r/m doubleword Two-Operand Formats l l The product is the first operand. The first operand must be a register. IMUL r 16, r/m 16 IMUL r 16, imm 8 IMUL r 16, imm 16
IMUL Instruction ¡ Two-Operand Formats l l l ¡ IMUL r 32, r/m 32 IMUL r 32, imm 8 IMUL r 32, imm 16 Three-Operand Formats l 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
IMUL Instruction l l IMUL r 16, r 32, r/m 16, r/m 32, imm 8 imm 16 imm 8 imm 32
Assembly Language Advanced Procedures
Examples Arry. Fill. asm ¡ Csum. asm ¡ Fact. asm ¡
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); }
¡ ¡ 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. ch 08_05. exe
Due date: 95/12/21 ¡ ftp: //eec 751@ftp. csie. nuk. edu. tw ¡ Zip your files as a 09 xxxxx_951214. zip ¡
Assembly Language Structures and Macros
Examples List. asm ¡ Walk. asm ¡
- Slides: 12