Microprocessors - CH 3
Microprocessors - CH 3
Arit hmetic
and Logic
In st ructio ns
The x86 PC
Assembly Language, Design, and Interfacing © 2010, 2003, 2000, 1998 Pearson Higher Education, Inc.
By Muhammad Ali Mazidi, Janice Gillespie Mazidi and Danny Causey Pearson Prentice Hall - Upper Saddle River, NJ 07458
2 . 5: DATA TYPES AND DATA DEFINITION
The x86 PC
Assembly Language, Design, and Interfacing © 2010, 2003, 2000, 1998 Pearson Higher Education, Inc.
By Muhammad Ali Mazidi, Janice Gillespie Mazidi and Danny Causey Pearson Prentice Hall - Upper Saddle River, NJ 07458
OBJE CT IVES
this chapter enables the student to:
The x86 PC
Assembly Language, Design, and Interfacing © 2010, 2003, 2000, 1998 Pearson Higher Education, Inc.
By Muhammad Ali Mazidi, Janice Gillespie Mazidi and Danny Causey Pearson Prentice Hall - Upper Saddle River, NJ 07458
3 . 1: U NSIGNED ADDITION AND SUB TR AC TI O N
addi ti on of unsigned numbers
The x86 PC
Assembly Language, Design, and Interfacing © 2010, 2003, 2000, 1998 Pearson Higher Education, Inc.
By Muhammad Ali Mazidi, Janice Gillespie Mazidi and Danny Causey Pearson Prentice Hall - Upper Saddle River, NJ 07458
3 . 2: U NSIGNED MULTIPLICATION & D IV IS I ON
mult ip lication of unsigned num be rs
• In multiplying two numbers in the x86 processor,
use of registers AX, AL, AH, and DX is necessary.
– The function assumes the use of those registers.
• Three multiplication cases:
– byte times byte; word times word; byte times word.
The x86 PC
Assembly Language, Design, and Interfacing © 2010, 2003, 2000, 1998 Pearson Higher Education, Inc.
By Muhammad Ali Mazidi, Janice Gillespie Mazidi and Danny Causey Pearson Prentice Hall - Upper Saddle River, NJ 07458
3 . 2: U NSIGNED MULTIPLICATION & D IV IS I ON
divi si on of unsigned numbers
• byte/byte - the numerator must be in the AL
register and AH must be set to zero.
– The denominator cannot be immediate but can be in a
register or memory, supported by the addressing modes.
• After the DIV instruction is performed, the quotient is in AL
and the remainder is in AH.
The x86 PC
Assembly Language, Design, and Interfacing © 2010, 2003, 2000, 1998 Pearson Higher Education, Inc.
By Muhammad Ali Mazidi, Janice Gillespie Mazidi and Danny Causey Pearson Prentice Hall - Upper Saddle River, NJ 07458
OBJE CT IVES ( cont )
this chapter enables the student to:
The x86 PC
Assembly Language, Design, and Interfacing © 2010, 2003, 2000, 1998 Pearson Higher Education, Inc.
By Muhammad Ali Mazidi, Janice Gillespie Mazidi and Danny Causey Pearson Prentice Hall - Upper Saddle River, NJ 07458
3 . 3: L OGIC INSTRUCTIONS
SHIF T LEFT
• SHL - Logical shift left, the reverse of SHR.
– After every shift, the LSB is filled with 0.
• MSB goes to CF.
– All rules are the same as for SHR.
The x86 PC
Assembly Language, Design, and Interfacing © 2010, 2003, 2000, 1998 Pearson Higher Education, Inc.
By Muhammad Ali Mazidi, Janice Gillespie Mazidi and Danny Causey Pearson Prentice Hall - Upper Saddle River, NJ 07458
3 . 3: L OGIC INSTRUCTIONS
COMP AR E of unsigned numbers
• C M P destination,source
– Compares two operands & changes flags according to the
result of the comparison, leaving the operand unchanged.
• Destination operand can be in a register or in memory.
• Source operand can be in a register, in memory, or immediate.
• CF, AF, SF, PF, ZF, and OF flags reflect the result.
– Only CF and ZF are used.
The x86 PC
Assembly Language, Design, and Interfacing © 2010, 2003, 2000, 1998 Pearson Higher Education, Inc.
By Muhammad Ali Mazidi, Janice Gillespie Mazidi and Danny Causey Pearson Prentice Hall - Upper Saddle River, NJ 07458
3 . 5: R OTATE INSTRUCTIONS
The x86 PC
Assembly Language, Design, and Interfacing © 2010, 2003, 2000, 1998 Pearson Higher Education, Inc.
By Muhammad Ali Mazidi, Janice Gillespie Mazidi and Danny Causey Pearson Prentice Hall - Upper Saddle River, NJ 07458