Assembly Language - PowerPoint PPT Presentation

About This Presentation
Title:

Assembly Language

Description:

One-Operand Format ... Two-Operand Formats, Three-Operand Formats ... Note: we will only test this procedure with nonnegative integers. ... – PowerPoint PPT presentation

Number of Views:30
Avg rating:3.0/5.0
Slides: 13
Provided by: csieN4
Category:

less

Transcript and Presenter's Notes

Title: Assembly Language


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 AXALr/m byte
  • IMUL r/m16 DXAXAXr/m word
  • IMUL r/m32 EDXEAXEAXr/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
  • Csum.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

10
  • Due date 95/12/21
  • ftp//eec751_at_ftp.csie.nuk.edu.tw
  • Zip your files as a09xxxxx_951214.zip

11
Assembly Language
  • Structures and Macros

12
Examples
  • List.asm
  • Walk.asm
Write a Comment
User Comments (0)
About PowerShow.com