topik 9 - instruction sets - characteristics and functions

33
Topik 9 Instruction Sets - Characteristics and Functions

Upload: meiiti-zaa

Post on 29-Jun-2015

121 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: Topik 9 - Instruction Sets - characteristics and functions

Topik 9

Instruction Sets - Characteristics and Functions

Page 2: Topik 9 - Instruction Sets - characteristics and functions

Rangkaian Instruksi

Operasi processor tergantung pada instruksi yang sedang dieksekusinya yaitu instruksi mesin.

Rangkaian instruksi : kumpulan instruksi mesin berbeda yang dapat dieksekusi oleh processor. Berupa bilangan biner Biasanya direpresentasikan oleh kode

assembly

Page 3: Topik 9 - Instruction Sets - characteristics and functions

Elemen-elemen Instruksi

Setiap instruksi harus berisi informasi yang dibutuhkan processor untuk eksekusi, yaitu: Operation code (Op code)▪ Lakukan ini, e.g. : ADD, I/O

Source Operand reference▪ Terhadap ini, berupa input untuk operasi

Result Operand reference▪ Simpan hasilnya disini

Next Instruction Reference▪ Jika selesai, lakukan ini...

Page 4: Topik 9 - Instruction Sets - characteristics and functions

Operand Sumber dan Operand Hasil

Merupakan salah satu lokasi berikut:1. Memory utama atau memori virtual2. Processor register3. Immediate :

▪ nilai operand ada pada field instruksi yang sedang dieksekusi

4. I/O device

Page 5: Topik 9 - Instruction Sets - characteristics and functions

Representasi Instruksi

Dalam instruksi mesin, setiap instruksi mempunyai pola bit yang unik dan dibagi atas elemen-elemen terkait.

Selama eksekusi, instruksi akan dibaca dalam IR processor.

Processor harus dapat mengekstrak bagian-bagian isntruksi tersebut agar dapat dieksekusi.

Untuk konsumsi manusia, dipakai representasi symbolik dari instruksi mesin (mnemonics). E.g. ADD, SUB, LOAD Contoh pemakaian : ADD R,B Artinya :

Page 6: Topik 9 - Instruction Sets - characteristics and functions

Format Instruksi Sederhana

Page 7: Topik 9 - Instruction Sets - characteristics and functions

Jenis-jenis instruksi (1)

Contoh : dalam HLL ditulis : X = X + Y

Jika X dan Y alamat memory 513 dan 514,

Maka artinya : tambahkan nilai yang tersimpan pada variabel Y dengan nilai yang tersimpan di X, hasilnya disimpan di X.

Page 8: Topik 9 - Instruction Sets - characteristics and functions

Jenis-jenis instruksi (2)

Statement X = X + Y pada HLL dapat dilaksanakan sbb oleh instruksi mesin sederhana:1. Muat ke register isi dari alamat memory 5132. Tambahkan isi dari alamat memory 514 ke register

tersebut.3. Simpan isi dari register tersebut ke alamat memory

513.

Hubungan HLL dengan instruksi mesin : HLL memberikan instruksi dalam bentuk aljabar ringkas, sedangkan instruksi mesin memberikan instruksi dalam bentuk dasar yang melibatkan perpindahan data dari dan ke register.

Page 9: Topik 9 - Instruction Sets - characteristics and functions

Jenis-jenis instruksi (3)

1. Data processing : instruksi aritmatik dan logika

2. Data storage : Perpindahan data ke atau dari register dan lokasi

di memori.

3. Data movement Instruksi I/O

4. Program flow control Instruksi pengecekan dan percabangan.

Page 10: Topik 9 - Instruction Sets - characteristics and functions

Jumlah alamat (a)

Jumlah alamat setiap instruksi : salah satu cara untuk menggambarkan arsitektur processor .

Berapa jumlah alamat maksimum yang dibutuhkan oleh satu instruksi?

Page 11: Topik 9 - Instruction Sets - characteristics and functions

Contoh :

Y = (A – B)/ (C + (DxE))

Bagaimana instruksi mesin yang digunakan untuk menghitung persamaan tersebut?

Page 12: Topik 9 - Instruction Sets - characteristics and functions

Jumlah alamat (b)

3 alamat Operand 1, Operand 2, Hasil Contoh : a = b + c; Mungkin 4 – yaitu : instruksi berikut

(biasanya implisit) Tidak umum digunakan Membutuhkan format instruksi yng

relatif panjang untuk menyimpan 3 referensi alamat.

Page 13: Topik 9 - Instruction Sets - characteristics and functions

Instruksi 3 alamat

Instruction CommentSUB Y, A, B Y A - B

MPY T, D, E T D X E

ADD T, T, C T T + C

DIV Y, Y, T Y Y + T

Page 14: Topik 9 - Instruction Sets - characteristics and functions

Number of Addresses (c)

2 alamat Satu alamat berfungsi sebagai operand

sumber sekaligus operand hasil. Contoh : a = a + b Memperkecil kebutuhan ruang memory Membutuhkan pekerjaan ekstra▪ Membutuhkan penyimpanan temporer

sebelum operasi dilakukan.

Page 15: Topik 9 - Instruction Sets - characteristics and functions

Instruksi 2 alamat

INSTRUCTION COMMENT

MOVE Y, A Y A

SUB Y, B Y Y - B

MOVE T, D T D

MPY T, E T T X E

ADD T, C T T + C

DIV Y, T Y Y + T

Page 16: Topik 9 - Instruction Sets - characteristics and functions

Number of Addresses (c)

1 alamat Alamat kedua bersifat implisit Biasanya menggunakan Accumulator

(AC). AC berisi satu operand dan digunakan

untuk menyimpan hasil. Biasa digunakan pada mesin komputer

zaman dulu.

Page 17: Topik 9 - Instruction Sets - characteristics and functions

Instruksi 1 alamatinstruction comment

LOAD D AC D

MPY E AC AC X E

ADD C AC AC + C

STOR Y Y AC

LOAD A AC A

SUB B AC AC - B

DIV Y AC AC + Y

STOR Y Y AC

Page 18: Topik 9 - Instruction Sets - characteristics and functions

Number of Addresses (d) 0 (zero) addresses

Semua alamat bersifat implisit Menggunakan stack Contoh : c = a + b1. push a2. push b3. add4. pop c

Page 19: Topik 9 - Instruction Sets - characteristics and functions

Berapa banyak alamat akan dipakai?

Lebih banyak alamat instruksi lebih kompleks Memakai lebih banyak register▪ Operasi antar register akan lebih cepat

Lebih sedikit instruksi per program

Lebih sedikit alamat Operasi kurang kompleks Lebih banyak instruksi per program

Page 20: Topik 9 - Instruction Sets - characteristics and functions

Keputusan Perancangan (1) Operation repertoire

Berapa banyak operand? Apa saja yang dapat dilakukan operand

tersebut? Seberapa kompleks?

Tipe data Format Instruksi

Panjang op code Jumlah alamat

Page 21: Topik 9 - Instruction Sets - characteristics and functions

Keputusan perancangan(2) Registers

Jumlah register CPU yang tersedia Operasi apa yang dapat dilakukan, pada

register mana?

Model pengalamat (later…)

RISC v CISC

Page 22: Topik 9 - Instruction Sets - characteristics and functions

Jenis-jenis operand

1. Alamat2. Angka

▪ Integer/floating point

3. Karakter▪ ASCII etc.

4. Logical Data▪ Bits or flags

Page 23: Topik 9 - Instruction Sets - characteristics and functions

Jenis-jenis Operasi

1. Data Transfer2. Arithmetika3. Logika4. Konversi5. I/O6. System Control7. Transfer of Control

Page 24: Topik 9 - Instruction Sets - characteristics and functions

Data Transfer

Menentukan Sumber Tujuan Jumlah data

Dapat berupa instruksi yang berbeda untuk perpindahan yang berbeda. e.g. IBM 370

Atau satu instruksi dan alamat berbeda e.g. VAX

Page 25: Topik 9 - Instruction Sets - characteristics and functions

Arithmetic

Add, Subtract, Multiply, Divide Signed Integer Floating point ? May include

Increment (a++) Decrement (a--) Negate (-a)

Page 26: Topik 9 - Instruction Sets - characteristics and functions

Logical

Bitwise operations AND, OR, NOT

Page 27: Topik 9 - Instruction Sets - characteristics and functions

Conversion

E.g. Binary to Decimal

Page 28: Topik 9 - Instruction Sets - characteristics and functions

Input/Output

May be specific instructions May be done using data movement

instructions (memory mapped) May be done by a separate

controller (DMA)

Page 29: Topik 9 - Instruction Sets - characteristics and functions

Systems Control

Privileged instructions CPU needs to be in specific state

Ring 0 on 80386+ Kernel mode

For operating systems use

Page 30: Topik 9 - Instruction Sets - characteristics and functions

Transfer of Control

Branch e.g. branch to x if result is zero

Skip e.g. increment and skip if zero ISZ Register1 Branch xxxx ADD A

Subroutine call c.f. interrupt call

Page 31: Topik 9 - Instruction Sets - characteristics and functions

Branch Instruction

Page 32: Topik 9 - Instruction Sets - characteristics and functions

Nested Procedure Calls

Page 33: Topik 9 - Instruction Sets - characteristics and functions

Use of Stack