chapter eleven the mmx instruction set

10
Chapter Eleven The MMX Instruction Set ささ

Upload: mabyn

Post on 05-Jan-2016

39 views

Category:

Documents


1 download

DESCRIPTION

Chapter Eleven The MMX Instruction Set. さだ. 11.1 Chapter Overview. MMX マルチメディアアプリケーション用に追加された 57 命令 今ではほとんどの CPU が対応している 現在アセンブラプログラマが活躍できる数少ない分野. 11.2 Determining if a CPU Supports the MMX Instruction Set. CPU MMX 対応のと、 MMX 非対応のアプリケーションを両方用意する ソフトウェア工学的には楽 アプリケーション実行中に、アルゴリズムを切り替える - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Chapter Eleven  The MMX Instruction Set

Chapter Eleven The MMX Instruction Set

さだ

Page 2: Chapter Eleven  The MMX Instruction Set

11.1 Chapter Overview

• MMX– マルチメディアアプリケーション用に追

加された 57 命令– 今ではほとんどの CPU が対応している– 現在アセンブラプログラマが活躍できる

数少ない分野

Page 3: Chapter Eleven  The MMX Instruction Set

11.2 Determining if a CPU Supports the MMX Instruction Set

• CPU• MMX 対応のと、 MMX 非対応

のアプリケーションを両方用意する– ソフトウェア工学的には楽

• アプリケーション実行中に、アルゴリズムを切り替える– CPU が MMX 対応かどうかを、

CPUID を取得して判断する– もし 23 ビット目が ON であれば

MMX に対応している

Page 4: Chapter Eleven  The MMX Instruction Set

11.3 The MMX Programming Environment

• MMX 対応になって追加されたもの– Eight MMX registers (MM0..MM7). – Four MMX data types (packed bytes, packed w

ords, packed double words, and quad word). – 57 MMX Instructions.

Page 5: Chapter Eleven  The MMX Instruction Set

11.3.1 The MMX Registers

• レジスタ– MM0 ~ MM7 、 64 ビットで 8

つ、データ専用• FPU レジスタにオーバレイ

している– FPU 命令と同時に使用できない– FPU レジスタを退避するのは

コストが大きい– EMMS (Exit MMX Machine Stat

e) 命令を実行するのは 50 クロックもかかる

– FPU と MMX を頻繁に切り替えるのはよくない!

Page 6: Chapter Eleven  The MMX Instruction Set

• なぜ、こんな仕様に?– 従来の OS を変更する必要がないため– コンテキストスイッチ時に、 OS は MMX レジスタ

を FPU レジスタだと思って保存してくれる– Intel としてはナイスアイディアだったらしい

• とはいえ、 OS もすぐに進化して MMX をサポート– 結局、上記のメリットは短期間しかなかった– 今となっては、 FPU と MMX を同時に利用できな

いデメリットのほうが大きい

Page 7: Chapter Eleven  The MMX Instruction Set

11.3.2 The MMX Data Types

• 64 ビットのレジスタを 2,4,8の Packed Bytes に分けて利用– 一応、そのまま分けずに利用

できるが、 general ではない• Packed Bytes に並列に命令を

実行可能– SIMD (Single Instruction Multipl

e Data)

Page 8: Chapter Eleven  The MMX Instruction Set

11.4 The Purpose of the MMX Instruction Set

• SIMD– 音楽や映像など、大きなデータに対して計

算するような用途に向いている– MMX は何でも計算速度を向上させるわけ

ではない

Page 9: Chapter Eleven  The MMX Instruction Set

11.5 Saturation Arithmetic and Wraparound Mode

• Wraparound Mode– 桁溢れが切り捨て– 音の増幅などで効果的– 例: FF + 02 = 101 01⇒

• Saturation Mode– 値が丸められる– 画像の光度増などで効果的– 例 :FF + 02 FF⇒

Page 10: Chapter Eleven  The MMX Instruction Set

11.6 MMX Instruction Operands

• MMX 命令の基本形– mmxInstr( source, dest );

• Dest はほぼ全て MMX レジスタ– mmxInstr( mmi, mmi ); // i=0..7– mmxInstr( mem, mmi ); // i=0..7