• 沒有找到結果。

Computer Organization and Assembly Languages Final Project

N/A
N/A
Protected

Academic year: 2022

Share "Computer Organization and Assembly Languages Final Project"

Copied!
10
0
0

加載中.... (立即查看全文)

全文

(1)

Computer Organization and Assembly Languages Final Project

The comparison between 32-bit and 64-bit microprocessor architecture

B94902029 郭彥伶 B94902055 吳明瑾

References

1. Intel® 64 and IA-32 Architectures Software Developer's Manual Volume 1: Basic Architecture

2. AMD64 Architecture Programmer's Manual Volume 1: Application Programming 3. Wikipedia-X86-64: http://en.wikipedia.org/wiki/X86-64

4. Wikipedia-IA-32: http://en.wikipedia.org/wiki/IA-32

(2)

Preface

本學期在計算機組織與組合語言這門課中,老師介紹了 32-bit 的 architecture 還有 x86 assembly language,但卻甚少提及 64-bit 的 architecture,因此,在想要 了解 64-bit 的 architecture 及其在 media programming 方面與 32-bit 的差異之情況 下,我們決定了這個主題。

而這份 project 主要比較了 32-bit 和 64-bit 的 microprocessor architecture,內 容 則 涵 蓋 了 兩 種 architecture 中 memory 、 registers 、 instructions 及 media programming 方面(即 MMX, SSE, SSE2, SSE3)的對照。

Modes of Operation

32-bit

(1) Protected mode

z Multitasking

z Protected memory:讓每一個程式不會使用到其他程式所用的 memory,

避免兩個程式相衝。

z Virtual memory:讓程式可以 access 的 memory space 達到 4GB。

(2) Real-address mode

z 會在 DOS operating system 使用,程式可以任意存取 memory。

z 程式最多只能存取 1MB(20-bit)的 memory space。

z 在現在的 OS 中 (Ex. Windows, Linux),只有開機的時候才會屬於 Real-address mode。

64-bit

(1) Compatibility mode

z 此模式下,64-bit 的 OS 能夠在不需要重新編譯的情況下執行 16-bit 和 32-bit 的 x86 應用程式。

z 與 32-bit 中的 Protected mode 相似,所以只能存取 linear-address space 中 的前 4GB。

(2) 64-bit mode

z 只有在使用 64-bit OS 的前提下才會使用到 64-bit mode。

z 只有 64-bit 的 OS 在執行程式時,能夠存取最多到 64-bit 的 linear address space。

z 將 general purpose registers 和 SIMD extension registers,從 8 個增加到 16 個,而且 general purpose registers 擴充成 64-bit。

z 重新定義 opcode,使 operand size 可以支援到 64-bit 的 operand。

(3)

32-bit

(1) Protected Mode:

(2) Real Mode

Protected mode 可支援 16-bit 跟 32-bit 的程式。

使用 table-based memory segmentation, paging 以及 privilege-checking,segmentation function 把 32-bit 的 effective address 和 16-bit 的 selector (包含 2-bit 的 Required Privilege Level, 1-bit 的 Table Indicator, 13-bit 的 index),產生出一個 32-bit 的 linear address(為 16K 個 memory segments 之一),

每一個空間皆可達到 4GB。

Paging 是非必須的,32-bit 的 physical address 可以靠 paging 產生,或者是 linear address 在沒有 改變的情況下直接當成 physical address 使用。

Real mode 支 援 16-bit 的 程 式 使 用 register-based shift-and-add segmentation,但是不支 援 paging。

對 16-bit 的 effective addresses 做 zero-extended 加上往左 shift 4 bit 的 16-bit segment-base address (內含特定實體記憶體位址的 address),產生一個 20-bit 的 linear address。

此 linear address 再做 zero-extension extend 成 32-bit 的 physical address,但其最多只能存取 1MB 的 memory space。

(4)

64-bit

(1) 64-bit Mode

Segments以及real address在64-bit mode中 是無法使用的。

在64-bit mode中,程式產生一個可以達到 64 bits大小的virtual addresses,然後透過

PAE(Page Address Extensions) paging轉換到 physical address,但真正能執行的空間並沒有到 達64-bit。

(2) Compatibility Mode

由 程 式 所 產 生 的 16-bit 或 32-bit 的 effective addresses 跟此程式的 segments 結合,

產 生 一 個 32-bit( 最 大 可 以 zero-extended 到 64-bit)的 virtual(linear) address,之後 paging 的 方式與 64-bit mode 相同。

註 1:paging 將 virtual addresses 轉換為 physical addresses。

註 2:segmentation selector 加上 effective address 也可以稱做是 logical address 或者是 far pointer。

註 3:virtual address 又稱做 linear address。

Basic Program Execution Registers

1. General purpose registers

(5)

z EBX — Pointer to data in the DS segment

z ECX — Counter for string and loop operations

z EDX — I/O pointer

z ESI — Pointer to data in the segment pointed to by the DS register; source pointer for string operations

r to data (or destination) in the segment pointed to by the ES

gment) 2. Seg

CS(

的 se e 中,CS, DS, ES, SS 被視為 0,這樣使 code, data

3. EFLA

在 32-bit

. EIP (instruction pointer) register

z 此 register 包含了在現在這個 code segment 中下一個要執行的 instruction 的 offset。

z 在 64-bit mode 中,EIP 被擴充到 64 bits 稱為 RIP。

z EDI — Pointe

register; destination pointer for string operations

z ESP — Stack pointer (in the SS segment)

z EBP — Pointer to data on the stack (in the SS se ment registers

code segment), DS, ES, FS, GS(data segments), SS(stack segment)內含 16-bit gment selector,在 64-bit mod

, stack 成為 flat address space,FS, GS 則為 exceptions。

GS (program status and control) register

64-bit mode 中,EFLAGS 被擴充到 64 bits 稱為 RFLAGS,前面的 被保留,後面的 32-bit 就是原來的 EFLAGS。

4

(6)

Offset

32-bit

z Displacement — An 8-bit, 16-bit, or 32-bit value.

Base — The value in a general-purpose register

z .

z Scale factor — A value of 2, 4, or 8 that is multiplied by the index value.

幾個元素的 offset 被稱為 effective address,除了 Scale factor 以外,每 可以是正的值也可以是負的值(2s complement)。

z Index — The value in a general-purpose register.

包含以上 一個元素

64-bit

z Displacement — An 8-bit, 16-bit, or 32-bit value.

z Base — The value in a 32-bit (or 64-bit if REX.W is set) general-purpose register.

z Index — The value in a 32-bit (or 64-bit if REX.W is set) general-purpose register.

z Scale factor — A value of 2, 4, or 8 that is multiplied by the index value.

P + Displacement — In 64-bit mode, RIP-relative addressing uses a signed ss of the next instruction by

Media Programming

z RI

32-bit displacement to calculate the effective addre

sign-extend the 32-bit value and add to the 64-bit value in RIP.

MM p

能 。

32-bit

ister 稱作 MMX register。

— 64-bit packed byte integers (signed and unsigned)

X

它定義了一種簡單且有彈性的SIMD execution model用來操作64-bit

acked integer data,但是會使用到x87 FPU,故MMX與floating point的運算不 同時使用,而MMX在32-bit與64-bit的表現並無顯著的不同

z 含有 8 個 64-bit data reg

z 三種的 data type

— 64-bit packed word integers (signed and unsigned)

(7)

z 在 compatibility mode 與 64-bit mode,MMX 的指令就和它們在 protection offset computation 方法

SSE

藉由 ,SSE延伸且擴

D execution model,未使用x87 FPU是它與MMX另外的不同點。

32-bit

z

z M上operation的control、status bit的32-bit register,稱作 MXCSR register。

一種新的data type

it etching of data, control of the cacheability of data, and control the

6

z e,SSE的指令就和它們在protection mode相同。

以存取新增的8個XMM register(XMM8-XMM15) 。

SSE

它多 rs。

32-

新的data type

— 128-bit packed word integers — 128-bit packed doubleword integers

支援pairs of packed double-precision floating-point的操作,所以允許在 更精確的運算,增進了在科學、工程應用上與3D幾何

tegers的操作,所以對SIMD的operation提供了 這樣的能力對於RSA authentication和RC5

助的。

mode 相同,只是 memory operand 要以上面所述之 來 specify。

增加對packed和scalar single-precision floating-point的操作 充了SIM

含有 8 個 128-bit data register 稱作 XMM register。

一個提供XM

z

—128-bit packed single-precision floating-point data type

z 除了single-precision floating-point operation的指令外,開始有支援explic pref

ordering of store operations的指令。

4-bit

在compatibility mod

z 在64-bit mode,才可 2

支援了packed double-precision floating-point與128-bit packed intege bit

z 六種

— 128-bit packed double-precision floating-point — 128-bit packed byte integers

— 128-bit packed quadword integers

z 因為

XMM registers上做

技術上processor的表現。

z 因為提供了128-bit packed in 更穩定、更大的處理能力,

encryption這類的應用是非常有幫

(8)

6

z

z 新增的8個XMM register(XMM8-XMM15)

SSE3

ramming environment 與 SSE2 無任何差別也沒有新增任何 data type,

6

z 增的8個XMM register(XMM8-XMM15)

z 有些SSE3的instruction會直接操作到GPR,故要以上面所述之offset putation方法來specify。

4-bit

在compatibility mode,SSE2的指令就和它們在protection mode相同。

在64-bit mode,才可以存取

z 有些SSE2的instruction會直接操作到GPR,故要以上面所述之offset computation方法來specify。

其 prog

是針對 64-bit 的 architecture 來發展。

4-bit

z 在compatibility mode,SSE2的指令就和它們在protection mode相同。

在64-bit mode,才可以存取新

com

z 大部分的SIMD instruction是做垂直的運算,SSE3最大的不同點是增加了 12個水平的加減運算指令。

(9)

Conclusion

64-bit 的 architecture 早已行之有年,各大 OS 也都有對應的平台,但是應用 軟體產品卻很少有 64-bit 的產品而且缺乏 64-bit 的驅動程式,所以目前個人電腦 平台在 64-bit 的應用並不廣泛。

其實,64-bit 的運算,在個人電腦上實際應用不多,在 32-bit 的 architecture 上,已經可以存取高達 4GB 的 memory,對於一邊個人電腦使用戶來說,記憶體 的使用率距離 4GB 還有很大的距離;而以下是在 64-bit 的個人電腦中,對於檔 案壓縮以及影像壓縮的測試,但由於軟體環境尚未成熟,應該還有很大的進步空 間,至於要如何降低 64-bit 對記憶體使用量的影響,則是程式設計者的一大挑戰。

B 1.1.4 檔案解壓縮測試 MiniGZip with ZLI

試項目

(數字越低越好) 64 位元 32 位元 成長幅度

壓縮檔案 3.625 秒 8.796 秒 +145%

Athlon 64 3800+

1.2

解壓檔案 03 秒 1.250 秒 +3.9%

壓縮檔案 4.640 秒 7.828 秒 +69%

Pentium 4F 3.2GHz

解壓檔案 0.656 秒 0.719 秒 +9.6%

※註:ZLIB 採用針對 AMD 最佳化的版本。

DivX 影像壓縮測試

(數字越高越好) 64 位元

測試項目

32 位元 成長幅度

FPS 3.74 FP/s 3.72 FP/s +0.5%

Athlon 64 3800+

35.71 FP/s 33.80 FP/s +5.7%

En.FPS

FPS 7.28 FP/s 5.97 FP/s +22%

Pentium 4F 3.2GHz

En.FPS 27.13 FP/s 21.09 FP/s +28.6%

※註:DivX encoder 採 D 最佳化 ,我們將一 的 wmv 檔 YUV 格式,

再進行影像壓縮的工

用針對 AM 的 5.03 版本 個 770kB 案先轉為

作。

(以上資料引用自http://www.poweruser.com.tw/)

料解壓縮、資料加密、影像處理的特殊應用來說,64-bit 運算便佔了很大的優勢 因為擁有 64-bit 的 flat memory 的存取能力,相較於 4GB

rtual memory PAE 延伸到相當於 64G 6-bit 的

memory,對於大型的資料庫或者是伺服器,都將不會發生不規則存取大範圍記 對於資料庫、資

的 vi 的空間限制,甚至是 B 的 3

(10)

憶體的程式行為 使記憶體存 彰;因 的高階 伺服器市

被 4-bit 的 R 器產品 並不令 意外。

出,微 Longhorn 核心的 OS(也就是已上市的 Vista) 推出時,應 該就是推出 64-bit 產品的最佳時機,雖然 64-bit 系統的普遍化依然言之過早,但 是 64-bit 的系統取代 32-bit 的系統似乎是長期趨勢,也許未來的 Longhorn 和市 場持續成長的個人用 Linux 平臺,才是 64-bit 系統最後的答案。

,而 取效率不 此,現在 運算及

場幾乎都已經 眾多 6 ISC 處理 所主宰, 人感到

有報導指 軟

參考文獻

相關文件

•Last month I watched a dance class in 崇文 Elementary School and learned the new..

Since we use the Fourier transform in time to reduce our inverse source problem to identification of the initial data in the time-dependent Maxwell equations by data on the

With the help of the pictures and the words below, write a journal entry about what happened.. Write at least

I, and on behalf of the student specified in this Form, consent to the matching of the Data with the personal data held by the Education Bureau and/or the Immigration Department

2.1.1 The pre-primary educator must have specialised knowledge about the characteristics of child development before they can be responsive to the needs of children, set

 Promote project learning, mathematical modeling, and problem-based learning to strengthen the ability to integrate and apply knowledge and skills, and make. calculated

Now, nearly all of the current flows through wire S since it has a much lower resistance than the light bulb. The light bulb does not glow because the current flowing through it

This kind of algorithm has also been a powerful tool for solving many other optimization problems, including symmetric cone complementarity problems [15, 16, 20–22], symmetric