310 likes | 677 Views
Apakah Set Arahan?. Koleksi arahan yg lengkap yg difahami oleh CPU Kod Mesin (Machine code) Perduaan (Binary) Selalunya diwakili oleh kod2 penghimpunan (assembly codes). Element2 Arahan. Kod operasi (Operation code - op code). Buat ini (Do this).
E N D
Apakah Set Arahan? • Koleksi arahan yg lengkap yg difahami oleh CPU • Kod Mesin (Machine code) • Perduaan (Binary) • Selalunya diwakili oleh kod2 penghimpunan (assembly codes)
Element2 Arahan • Kod operasi (Operation code - op code). • Buat ini (Do this). • Sumber rujukan operan (Source operand reference). • Ke ini (To this). • Rujukan jawapan operan (Result operand reference). • Letak jawapan di sini. • Rujukan arahan berikut (Next instruction reference). • Pabila ia selesai, buat ini pulak...
Pewakilan Arahan • Dlm kod mesin, setiap arahan mempunyai pola bit yg unik • Utk kemudahan manusia (yakni pengaturcara), pewakilan simbolik digunakan • Cth. Add, sub, load • Operan juga boleh diwakili dgn cara ini • Add a,b
Format2 Arahan • Paparan bit2 dlm arahan • Termasuk opcode • Termasuk (tersirat atau nyata) operan2 • Selalunya lbh drpd satu format arahan dlm set arahan.
Format Arahan Arahan 4 6 6 Operand Reference 1 Operand Reference 2 Op-Code Operand field 16 bits
Jenis2 Arahan • Pemprosesan data (Data processing) • Penyimpanan data (Data storage - memori utama) • Pergerakkan data (Data movement- I/O) • Program flow control
Panjang Arahan • Dipengaruhi oleh dan mempengaruhi: • Saiz Memori • Oraganisasi Memori • Struktur bas • Kekompleksan CPU • Kelajuan CPU • Keseimbangan ant ‘powerful instruction repertoire’ & ‘saving space’.
Number of Addresses (a) • 3 addresses • Operand 1, Operand 2, Result • a = b + c; • May be a forth - next instruction (usually implicit) • Not common • Needs very long words to hold everything
Number of Addresses (b) • 2 addresses • One address doubles as operand and result • a = a + b • Reduces length of instruction • Requires some extra work • Temporary storage to hold some results
Number of Addresses (c) • 1 address • Implicit second address • Usually a register (accumulator) • Common on early machines
Number of Addresses (d) • 0 (zero) addresses • All addresses implicit • Uses a stack • e.g. push a • push b • add • pop c • c = a + b
Bilangan Alamat • Mesin satu alamat • Add b => ac = ac + b • Mesin dua alamat • Sub a, b => a = a - b • Mesin tiga alamat • Add a, b, c => a = b + c
Bilangan Alamat • Arahan tiga alamat • Arahan komen/makna • Sub y, a, b y<= a-b • MPY t, d, e t<= d*e • Add t, t, c t<= t+c • Div y, y, t y<= y/t • Y= (a-b) / (c+d*e)
Bilangan Alamat • Arahan dua alamat • MOV y, a y<= a • Sub y, b y<= y-b • MOV t, d t<= d • MPY t, e t<= t*e • Add t, c t<= t+c • Div y, t y<= y/t • Y= (a-b) / (c+d*e)
Bilangan Alamat • Arahan satu alamat • LOD d ac<= d • MPY e ac<= ac*e • Add c ac<=ac+c • STR y y<= ac • LOD a ac<= a • Sub b ac<= ac-b • Div y ac<= ac/y • STR y y<= ac • Y= (a-b) / (c+d*e)
Berapa banyak alamat? • Lebih alamat • Lbh komplek (powerful?) arahan • Lbh daftar (register) • Inter-register operations are quicker • Sedikit arahan per program • Sedikit alamat • Krg komplek (powerful?) arahan • Lbh arahan per program • Cepat Ambil/Laksana arahan
Keputusan Rekabentuk (1) • Himpunan operasi • Berapa byk operasi? • Apa yg blh dilakukan? • Berapa komplek? • Jenis2 data • Format2 arahan • Panjang kod operasi • Bilangan alamat
Keputusan Rekabentuk (2) • Daftar2 (Registers) • Bil. daftar2 CPU yg ada • Which operations can be performed on which registers? • Mod Alamat (later…) • RISC v CISC
Jenis2 Operan • Alamat2. • Nombor2. • Integer/floating point. • Characters. • ASCII etc. • Data Logikal. • Bits or flags. • (Aside: is there any difference between numbers and characters? Ask a C programmer!).
Pentium Data Types • 8 bit byte • 16 bit word • 32 bit double word • 64 bit quad word • Addressing is by 8 bit unit • A 32 bit double word is read at addresses divisible by 4
Specific Data Types • General - arbitrary binary contents • Integer - single binary value • Ordinal - unsigned integer • Unpacked BCD - one digit per byte • Packed BCD - 2 BCD digits per byte • Near pointer - 32 bit offset within segment • Bit field • Byte string • Floating point
Jenis2 Operasi • Perpindahan data (Data transfer) • Aritmetik • Logikal • Pertukaran (Conversion) • I/O • Kawalan sistem (System control) • Transfer of control
Perpindahan Data • Tentukan • Sumber (Source) • Destinasi (Destination) • Amount of data • Berkemungkinan arahan yg berbeza utk permindahan yg berbeza • E.G. IBM 370 • Atau satu arahan dan berlainan alamat • E.G. VAX
Aritmetik • Tambah, tolak, darab, bahagi • Integer bertanda • Titik apungan? • Mungkin juga termasuk • Increment (a++) • Decrement (a--) • Negate (-a)
Logikal • Bit wise operations • And, or, not
Pertukaran • Cth. Binary to decimal
Input/output • Mungkin ada arahan spesifik • Mungkin dilakukan m’gunakan arahan peralihan data (memory mapped) • Mungkin dilakukan oleh controller (DMA) yg terasing.
Kawalan Sistem • Arahan terlindung • CPU perlu berada dlm situasi tertentu • Ring 0 on 80386+ • Kernel mode • Utk kegunaan OS
Permindahan Kawalan • Cabang (Branch) • E.G. Branch to x if result is zero • Langkau (Skip) • E.G. Increment and skip if zero • ISZ register1 • Branch xxxx • Add a • Panggil subrutin (Subroutine call) • C.F. Interrupt call
Pentium Floating Point Data Types • See Stallings (5th Ed - Chapter 9, 6th Ed – Chap 10) / Instruction Sets: Characteristics and Function