Ozet. Review pointers (in C) Memory Addressing

Benzer belgeler
Lecture 7. Assembler language nedir? Language in 3 seviyesi. Language 3 seviyesi. Nicin onu ogreniriz?

MIPS assembler language de branching

BM-311 Bilgisayar Mimarisi

BM-311 Bilgisayar Mimarisi

BM-311 Bilgisayar Mimarisi

BM-311 Bilgisayar Mimarisi

Assembly Language Programming

BM 375 Bilgisayar Organizasyonu Dersi Vize Sınavı Cevapları 10 Nisan 2009

Memory. Amac. Baslangictan beri programcilar unlimited hizli memory ler hayal etmisler 1972, PDP-11/20. Oku H&P sections 7.1, 7.2

Hem lw hem de sw komutlarının ofseti 16-bitlik işaretli tamsayıdır.

İŞLETİM SİSTEMİ İşletim sistemi kullanıcıyla bilgisayar donanımı arasında iletişim sağlayan programdır.

Spatial locality nin getirdigi avantaji kullanmak

Ilgili prefixes ler. 2 nin kuvvetleri. 2 nin kuvvetleri

Giris {\} /\ Suhap SAHIN

Multiplication/division

K uark projesi. Temel Özellikler :

Onluk duzende toplama. Lecture 4. Addition and Subtraction. Onluk tabanda toplama

Pros and Cons of Pointers. Pointers. Avantajlar. Dezavantajlar

Von Neumann Mimarisi. Mikroişlemciler ve Mikrobilgisayarlar 1

Quiz:8086 Mikroişlemcisi Mimarisi ve Emirleri

CISC Complex Instruction Set Computers

x86 Ailesi Mikroişlemciler ve Mikrobilgisayarlar

BİLGİSAYAR MİMARİSİ. Bilgisayar Bileşenleri Ve Programların Yürütülmesi. Özer Çelik Matematik-Bilgisayar Bölümü

Komutların Yürütülmesi

D Duplex : Alıcı + Verici Çalışma Debouching : DMA : Direct Memory Access Data-Bus : Data Veri Yolu Data Flow : Veri Akışı Data Processing : Veri

Dr. Feza BUZLUCA İstanbul Teknik Üniversitesi Bilgisayar Mühendisliği Bölümü

MİKROBİLGİSAYAR SİSTEMLERİ. Teknik Bilimler Meslek Yüksekokulu

En kucuk calisabilir birime satetement denir Statements semicolon (;) ile sonlanir Yalniz basina ; null statement i ifade eder

BM-311 Bilgisayar Mimarisi. Hazırlayan: M.Ali Akcayol Gazi Üniversitesi Bilgisayar Mühendisliği Bölümü

Bölüm 3: Adresleme Modları. Chapter 3: Addressing Modes

Mikroişlemci ve Yapısı. Mikroişlemciler ve Mikrobilgisayarlar

BM-311 Bilgisayar Mimarisi

İşlemci Tasarımı ve Aşamaları

Mikroçita. Mikroçita Rapor 2:

BM-311 Bilgisayar Mimarisi

BM-311 Bilgisayar Mimarisi

MİKROİŞLEMCİ MİMARİLERİ

EEM 306 Mikroişlemciler ve Lab. Doç.Dr. Mehmet SAĞBAŞ

BM-311 Bilgisayar Mimarisi

Mikrobilgisayar Sistemleri ve Assembler

Ders 3 ADRESLEME MODLARI ve TEMEL KOMUTLAR

BİLGİSAYAR MİMARİSİ. Komut Seti Mimarisi. Özer Çelik Matematik-Bilgisayar Bölümü

Logical signals. Active high or asserted logic. Logic threshold, yaklasik 1.4 volts. Read H&P sections B.3, B.4, B.5 Read H&P sections 5.1 and 5.

Big Endian & Little Endian K.Atilla Toker İzmir Üniversitesi Meslek Yüksek Okulu Bilgisayar Programcılığı Ver:01

MİKROİŞLEMCİLER 1 Ders 1

80x86 MICROPROCESSOR Instructions

Algoritmalar ve Programlama. DERS - 2 Yrd. Doç. Dr. Ahmet SERBES

Unlike analytical solutions, numerical methods have an error range. In addition to this

Maltepe Üniversitesi Bilgisayar Mühendisliği Bölümü BİL 203 Veri Yapıları ve Algoritmalar I

PC is updated PS güncellenir

DOĞU AKDENİZ ÜNİVERSİTESİ BAHAR BİLGİSAYAR MÜHENDİSLİĞİ BÖLÜMÜ BLGM-324 BİLGİSAYAR MİMARİSİ DENEY #6

Bahar Dönemi. Öğr.Gör. Vedat MARTTİN

BİL 361 BİLGİSAYAR MİMARİSİ VE ORGANİZASYONU Güz Dönemi ÖDEV 1

Ders Özeti. Ders 2. PC nin İç Organizasyonu. Mikroişlemcinin Organizasyonu. Basitçe İşlemciyi Oluşturan Parçalar. Mikroişlemciler

Adresleme Modları. Mikroişlemciler ve Mikrobilgisayarlar

Bilgisayar Mimarisi ve Organizasyonu Giriş

C-Serisi PLC İleri Seviye Eğitim

SAYI SİSTEMLERİ. 1. Sayı Sistemleri. Sayı Sistemlerinde Rakamlar

Bölüm Bazı Temel Konseptler

Bölüm 6. Diziler (arrays) Temel kavramlar Tek boyutlu diziler Çok boyutlu diziler

Mikrobilgisayar Mimarisi ve Programlama

C++ Programming: Program Design Including Data Structures, Third Edition. Bölüm 1: Bilgisayarlar ve Programlama Dillerine Kısa Bakış

Virtualmin'e Yeni Web Sitesi Host Etmek - Domain Eklemek

Komut Seti Mimarisi (ISA)

BBS 514 YAPISAL PROGRAMLAMA (STRUCTURED PROGRAMMING)

Pre-requisite : EE240

Selection Sort Insertion Sort

İşletim Sistemlerine Giriş

Komut Seti Mimarisi (ISA)

BM-311 Bilgisayar Mimarisi

Mikroişlemciler ve Assembler Programlama. Teknoloji Fakültesi / Bilgisayar Mühendisliği Öğr.Gör. Günay TEMÜR

PROGRAMLAMAYA GİRİŞ DERS 2

Gömülü Sistemler. (Embedded Systems)

İSTANBUL TİCARET ÜNİVERSİTESİ BİLGİSAYAR MÜHENDİSLİĞİ BÖLÜMÜ MİKROİŞLEMCİLİ SİSTEM LABORATUVARI KESMELİ GİRİŞ/ÇIKIŞ

MTM 305 MĠKROĠġLEMCĠLER

2 İş Hattı (Pipeline)

İSTANBUL TİCARET ÜNİVERSİTESİ BİLGİSAYAR MÜHENDİSLİĞİ BÖLÜMÜ MİKROİŞLEMCİLİ SİSTEM LABORATUARI MİKROİŞLEMCİLİ A/D DÖNÜŞTÜRÜCÜ

Sınavında sık yapılan temel hatalar:

İşletim Sistemleri (Operating Systems)

2 İş Hattı (Pipeline)

Arithmetic ve Logical Operations

8086 Mikroişlemcisi Komut Seti

CITIUS-ALTIUS-FORTIUS

Embedded(Gömülü)Sistem Nedir?

CITIUS-ALTIUS-FORTIUS

BLM1011 Bilgisayar Bilimlerine Giriş I

BM-311 Bilgisayar Mimarisi

BİLGİSAYAR MİMARİSİ. Halil Özmen

DERS 3 MİKROİŞLEMCİ SİSTEM MİMARİSİ. İçerik

DOĞU AKDENİZ ÜNİVERSİTESİ BAHAR BİLGİSAYAR MÜHENDİSLİĞİ BÖLÜMÜ BLGM-324 BİLGİSAYAR MİMARİSİ. PC-SPIMGirişi(MIPS R2000 Simulatörü)

BİLGİSAYAR MİMARİSİNDE YENİ YAKLAŞIMLAR DÖNEM PROJESİ

5.2 Komut Biçimleri Komut Setleri İçin Tasarım Kararları

BİLGİSAYAR MİMARİLERİ

Bölüm 4 Veri Aktarma Komutları

7.Yazmaçlar (Registers), Sayıcılar (Counters)

Şekil. 64 Kelimelik Yığıtın Blok Şeması

Bilgisayarların Gelişimi

Tek Vuruşluk Đşlemci. -- Company : Ege Universitesi, Elektrik-Elektronik Mühendisliği

C++ Statements. { ve } arasında ifade edilen bir dizi statement bir compound statement (birleşik ifade) oluşturur.

BBM Discrete Structures: Midterm 2 Date: , Time: 16:00-17:30. Question: Total Points: Score:

Transkript:

Ozet Oku H&P Sections 31 thru 34 (read again) Section A10 Hardware-Software interface Processor nasil calisir Hardware ve software arasinda tradeoffs Show how processor works 11/26/2004 Bilgisayar Mimarisi 81 11/26/2004 Bilgisayar Mimarisi 82 Memory Addressing Her bir memory location 32 bit (4 byte) boyunda 4 byte data CPU ve memory arsinda transfer olur 32 bits of data transfer to and from memory simultaneously Memory byte addressable Sonraki memory location ina erismek icin onceki address e 4 eklenir 1200 1204 1208 1212 1216 1220 1224 1228 1232 Memory 1224 11/26/2004 Bilgisayar Mimarisi 83 32 17 Data Review pointers (in C) Pointer: an address stored in a variable int i = 17; // Primitive integer variable // contains a value int *p = &i; // pointer to an integer * means the variable is a pointer & means address of 11/26/2004 Bilgisayar Mimarisi 84

Pointer in Memory Integer data i is stored in location 1224 p points to the data is stored in location 1224 int value = *p; gives value 17 This accesses data indirectly 1200 1204 1208 1212 1216 1220 1224 1228 1232 Memory 1224 17 Pointer in Memory p++ adds 4 to p (p now 1228) (because we declared p as a pointer to an integer) Now p points to the data stored in location 1228 int value = *p; gives value 7 1200 1204 1208 1212 1216 1220 1224 1228 1232 Memory 1228 17 7 32 Data 32 Data 11/26/2004 Bilgisayar Mimarisi 85 11/26/2004 Bilgisayar Mimarisi 86 Memory Addressing Byte addr 000 Byte addr 003 MSB 32-bit word LSB 000 004 008 012 016 020 024 Byte addr 027 11/26/2004 Bilgisayar Mimarisi 87 Memory Addressing Memory linear bir array, address 0 la baslar 4-byte align edilmis Leftmost byte daima 0, 4, 8, Address lerindedir Binary olarak, son iki bit haric butun address bitleri word u address ler, son iki bit ise word icindeki byte i address ler 11/26/2004 Bilgisayar Mimarisi 88

Memory addressing Bireysel byte lar address lenebilir, fakat word size 4 bytes 4 eklenerek bir sonraki word un address i bulunur 4 cikarilarak bir onceki word un address i bulunur 4 le carpilarak location numarasi address e donusturulur Memory addressing Decimal form da 4 uncu word un least significant byte (LSB) nin address i nedir? 11/26/2004 Bilgisayar Mimarisi 89 11/26/2004 Bilgisayar Mimarisi 810 Byte lari address leme 32-bit data path a sahip bir islemci nicin sadece word lari address lemez? 8-bit character ler cok yaygin Character lerin efficient bir sekilde memory de tutulmasi istenir Her bir character i word e yerlestirsek, memory gereksinimi 4 katina cikmis olacakti Memory address is a pointer Address bir yerde tutulmali Memory General purpose register PC Pointer buyulu bir sey degil Uzerinde islemler yapilabilen integer 11/26/2004 Bilgisayar Mimarisi 811 11/26/2004 Bilgisayar Mimarisi 812

MIPS memory addressing Load /store machine Memory den okuma sadece load instruction i ile olur Memory e yazma sadece store instruction i ile olur Byte, halfword, word icin load/store mumkun Double word pseudo instruction olarak gerceklenir General Register addressing 5 bit kullanilarak 32 register address lenir Ancak 32-bit word ler address lenir Bireysel byte lari address leme yok 5-bit address instruction code unda kodlanmistir 11/26/2004 Bilgisayar Mimarisi 813 11/26/2004 Bilgisayar Mimarisi 814 MIPS 32-bit word MIPS general registers MSB 31 0 101010101010101010101010101010101010 LSB We ll use this from now on, though I will occasionally slip back into familiar turf and number them 0 thru 31 32 register a sahip Daha sonra bunlardan bahsedilecek simdilik temporary register lari kullanacagiz $t0 $t9 Gercek address leri 8 17 decimal 11/26/2004 Bilgisayar Mimarisi 815 11/26/2004 Bilgisayar Mimarisi 816

Source ve destination Assembler language program larda genel terimler Source: data nin geldigi yer Destination: sonucun gittigi yer add $t2, $t0, $t1 // R2 = R0 + R1 Sources: $t0 and $t1 (MIPS bunlari rs ve rt diye adlandirir) Destination: $t2 (MIPS bunu rd diye adlandirir) general register larin avantajlari Really hizli math ve logic operations! Register lar CPU chip inde Gunumuzde cok ucuz 11/26/2004 Bilgisayar Mimarisi 817 11/26/2004 Bilgisayar Mimarisi 818 general register larin dezavantajlari Data uzerinde islem yapmayan, ve sadece data nin tasinmasini saglayan load-store instruction larina ihtiyac var Complex programdaki tum variable lari tutacak sayida general register yok Subroutine ler cagrilirken register larin save edilmesi Code size uzar, daha kompleks, anlasilmasi daha zor 11/26/2004 Bilgisayar Mimarisi 819 Code this: F = (G + H) - (I + J) 3-operand memory machine ADD TEMPA, G, H ADD TEMPB, I, J SUB F, TEMPA,TEMPB MIPS is a 3-operand register machine 3-operand register machine LW $t0, G LW $t1, H ADD $t2, $t0, $t1 LW $t0, I LW $t1, J ADD $t3, $t0, $t1 SUB $t0, $t2, $t3 SW $t0, F 11/26/2004 Bilgisayar Mimarisi 820

MIPS instruction format R CPU Diagram, 3-operand assembler language 6 5 5 5 5 6 op rs rt rd shamt funct Opcode reg addresses shift amount function Opcode IR R1 R2 Select R3 Ta ALU Tb PC MAR Address M U X MEM Opcode and function together specify the operation; don t know why MIPS splits them Rigid format -- wires come from their bits This is the Instruction Register -- next slide M U X General Registers Data 11/26/2004 Bilgisayar Mimarisi 821 11/26/2004 Bilgisayar Mimarisi 822 ADD $t2, $t0, $t1 which is R format SUB $t0, $t2, $t3 which is R format 000000 01000 01001 01010 00000 100000 op rs rt rd shamt function 000000 01010 01011 01000 00000 100010 op rs rt rd shamt function Only difference between ADD and SUB is one bit in the function field What does it control? remember next slide? 11/26/2004 Bilgisayar Mimarisi 823 11/26/2004 Bilgisayar Mimarisi 824

1-bit ALU for And, Or, Add, Sub InvertB A CarryIn Select Ain Bin MUX B Y MUX + Cin CarryOut 11/26/2004 Bilgisayar Mimarisi 825 design gereksinimleri load /store (word) instruction larina ihtiyac var Load/store memory i address lemek icin cok sayida bit e ihtiyac gosterir R format address adressleme icin yeterli alan yok IR 32 bit genisliginde Dolayisiyle yeni bir format tanimlanmali Instruction formati simple ve regular olmaktan uzaklasir (CISC mimarilerinin instruction formati ile karsilastirildiginda hala cok simple ve regular) 11/26/2004 Bilgisayar Mimarisi 826 MIPS instruction format I (immediate) LW $t1, 4($t0) which is I format I Format R Format 6 5 5 16 op rs rt address 6 5 5 5 5 6 op rs rt rd shamt funct 100011 01000 01001 0000000000000100 op rs rt address I Format rt destination register destination register Loads, stores ve icinde immediate bulenan instruction formati 64K lik memory addresslenir (rs nin gosterdigi locationdan itibaren) 11/26/2004 Bilgisayar Mimarisi 827 11/26/2004 Bilgisayar Mimarisi 828

Immediate data Data instruction in icine konur addi $t0, $t1, 7 # t0 = t1 + 7 Small constant lari registerlarin iceriklerine eklemek icin yaygin bir yontem Immediate format kullanir ( I Format) Constant larin boyu 16 bitle sinirli (-32K thru 32K) I-Format ayni zamanda load/store icin kullanilir instruction format larin onemi Ezberlemeye gerek yok Sadece mantigi anlamaya calisilmali ve farkli amaclar icin nasil farkli yorumlandigi anlasilmali IR is rigid -- it is the hardware of the CPU See next slide 11/26/2004 Bilgisayar Mimarisi 829 11/26/2004 Bilgisayar Mimarisi 830 R I Multiple use of IR bits 5 To Gen Regs OP RS RT RD shamt funct OP RS RT address 16 To MAR Bits of opcode dictate which use 5 bits always go to two places, but only one J format Ucuncu format Jump instructionlari icin kullanilir 26-bit address leme yapar use is enabled subject of control 11/26/2004 Bilgisayar Mimarisi 832 11/26/2004 Bilgisayar Mimarisi 831

Instruction Jump Jump register Jump and link Jump and link register MAL jr R PC <-- R Jump Instructions j address PC<-address (address label veya register olabilir) jal address R 31 <-- PC + 4; PC <-- address jalr R d, R s R d <-- PC + 4; PC <--R s TAL j I 0000 10ii iiii iiii iiii iiii iiii iiii PC <-- [PC] 3128 [I] 250 0 2 jr R s 0000 00ss sss0 0000 0000 0000 0000 1000 PC <--[R s ] jal I R 31 <-- [PC] + 4; PC <-- [PC] 3128 [I] 250 0 2 jalr R d, R s 0000 00ss sss0 0000 dddd d000 0000 1001 R d <-- [PC] + 4; PC <-- [R s ] 11/26/2004 Bilgisayar Mimarisi 833 Assembler directives Assemblerden sophistice seylerin yapilmasini istemek icin kullanilan command ler Genellikle memory allocation ile ilgili isler ile baslarlar Start with a pagea-51 11/26/2004 Bilgisayar Mimarisi 834 # Example to illustrate assembler directives # and general form of stand-along program align 2 # Align on full word boundary data # Allocate data here nsc: word 3 # Number of golf scores score: word 80, 82, 85 # Array of golf scores text # Program block starts here main: add $t4,$zero,$zero # Clear running sum in t4 la $t0, scores # t0 = base addr of scores 1208 is base addr of Scores Score 85 has an offset of 8 bytes (Java equivalent of Scores[2]) In MIPS, base addr is stored in a register offset is a constant la lw lw Base-offset addressing of integer arrays $t0, Scores # base addr to t0 $t1, 0($t0) # Scores[0] to t1 $t2, 8($t0) # Scores[2] to t2 1200 1204 1208 1212 1216 1220 Memory -- -- 80 82 85 -- Scores 11/26/2004 Bilgisayar Mimarisi 835 11/26/2004 Bilgisayar Mimarisi 836

Instruction larin formatlari mimarinin performansina etkide bulunur Assembly dilleri memory e dogrudan erismeyi saglayan instructionlar icerirler Assembly dilinde data type kavrami yoktur Bellek gozlerindeki bitlerin sabit bir anlami yoktur Bu bitlerin anlami instructionlarin bunlari nasil kullandigina baglidir Bellekteki bir word unsigned integer, floating point number veya character (bir kac) olarak yorumlanabilir Hatta bu word bir instruction olarak da olabilir Instructions Bir cok modern processor lerin (MIPS RISC mimarisi dahil) instruction lari fixed-size (tum instructionlarin boyu ayni) 32-bit dir Instructionlarin fixed-size olmasi bir cok kolayliga yol acar Instruction larin fetch edilmesi (memory den CPU ya getirilmesi) Sonraki run olacak instruction in adresinin hesaplanmasi 11/26/2004 Bilgisayar Mimarisi 837 11/26/2004 Bilgisayar Mimarisi 838 Load/store architecture RISC Mimarisi Eger memory e sadece load/store instructionlariyle erisilebiliyorsa buna load/store architecture denir Modern RISC (Reduced Instruction Set Computer) processor ler load/store mimarisine sahiptirler Komutlarin kisa ve sabit uzunlukta olmasina yol acar 11/26/2004 Bilgisayar Mimarisi 839 70 li yillarin sonu ve seksenli yillarin basinda RISC projesi yurutulmustur Proje IBM, Stanford University ve UC-Berkeley tarafindan ortaklasa yurutulmustur IBM 801, Stanford MIPS, Berkeley RISC 1, 2 Temel ozellikleri One cycle execution Pipelining Large number of registers 11/26/2004 Bilgisayar Mimarisi 840

MIPS RISC vs CISC 11/26/2004 Bilgisayar Mimarisi 841 MIPS mimarisi yaklasik 111 instructiondan olusur 21 arithmetic instructions (+, -, *, /, %) 8 logic instructions (&,, ~) 8 bit manipulation instructions 12 comparison instructions (>, <, =, >=, <=, ) 25 branch/jump instructions 15 load instructions 10 store instructions 8 move instructions 4 miscellaneous instructions 11/26/2004 Bilgisayar Mimarisi 842 Registers MIPS architecture iki farkli register file i vardir 32 genel register ($r0 $r31) Her biri 32-bit liktir 32 farkli registerin kodlanmasi icin 5 bit lik bir alan gerekir (instruction code) $r0 daima 0 (sifir) icerir $r1 assembler tarafindan kullanilir (makine diline translation sirasinda, pseudo instructions and large constants) $26 ve $27 operating system tarafindan kullanilirlar $28, $29 ve $r31 procedure cagriminda kullanilirlar (parameter passing, holding return address vs) Registers 32 floating point registers Floating point operand larini tutmak icin kullanilirlar $f0,, $f31 Floating point operands 32 (single precision)/64 (double precision) olabilir Double precision icin FP registerlar ciftler halinde kullanilabilirler ($f0,f1), ($f16, $f17) Odd numbered (tek numarali ) FP registerlar arithmetic instructionlarinda kullanilamazlar Sadece data transferleri icin kullanilabilirler 11/26/2004 Bilgisayar Mimarisi 843 11/26/2004 Bilgisayar Mimarisi 844

Registers Special purpose (ozel amacli) registers PC (Program Counter): Bir sonraki Execute edilecek instruction in adresini tutar SP (Stack Pointer) General purpose register file $r0 $r1 $r31 32 bit Floating point register file $f0 $f1 $f2 $f3 $f30 $f31 11/26/2004 Bilgisayar Mimarisi 845 32 bit 11/26/2004 Bilgisayar Mimarisi 846 Load/Store Architecture Eger bellege erisim sadece load/store instructionlari ile sinirli ise buna load/store architecture denir Bu mimaride sadece iki grup instruction address belirlerler (load/store, control instructions) Veriler uzerinde islemler yapmak icin once bu veri bellekten okunup (load) bir register a yazilmasi gerekir Registerlar uzerinde islem yapildiktan sonra bellege tekrar yazilir (store) Butun RISC islemciler load/store architecture ina SAL: sub difference, subtrahend, minuend MAL: lw $8, subtrahend lw $9, minuend sub $10, $8, $9 sw $10, difference 11/26/2004 sahiptir Bilgisayar Mimarisi 847 11/26/2004 Bilgisayar Mimarisi 848

Instruction larda Adress Belirlenmesi Load/store architecture larda registerlar source (kaynak) operand lari temin eder (arithmetic ve logic instruction) Bu arithmetic ve logic instruction lari en fazla uc register kodlarlar (source1, source2, destination) Load/store instruction lari verinin bellekten okunacagi / yazilacagi adresi belirlemesi gerekir Brach instruction lari da branch edilecek instruction in adresini belirlemek zorunda SPIM de address ler 32 bit oldugu icin load/store veya branch instruction in kendisinde kodlanamazlar (instructionlarin uzunluklari 32 bit) 11/26/2004 Bilgisayar Mimarisi 850 11/26/2004 Bilgisayar Mimarisi 849 Effective Address Load/store ve branch instructionlari nasil address belirler? Effective address hesabi: load/store ve branch instruction larinin ifade ettigi address in hesaplanmasi Bunun icin cesitli yontemler var Addressing modes Islemciler cesitli methodlarla address belirlerler Bu yontemlere addressing modes denir Addressing modes operand in address inin nasil hesaplanmasi gerektigini belirler Immediate addressing Address direct olarak instructionin icine yerlestirilir Eger instruction da address icin 8 bitlik bir alan ayrilmissa bu alan 128 +127 olarak yorumlanabilir PC-relative Instruction Branch less than zero MAL bltz R, label If (R < 0), then PC<-- label TAL bltz R s, I 0000 01ss sss0 0000 iiii iiii iiii iiii if ([R s ] < 0), then PC <--[PC] +4 + ([I 15 ] 14 [I] 150 0 2 ) 11/26/2004 Bilgisayar Mimarisi 851 11/26/2004 Bilgisayar Mimarisi 852

Register Operand bir register da bulunur Register Direct Operand in address i bir register da bulunur opcode reg one-word instruction opcode reg one-word instruction value reg address reg operand effective address 11/26/2004 Bilgisayar Mimarisi 853 11/26/2004 Bilgisayar Mimarisi 854 Base Displacement Effective address bir register in iceriginin (the base) instruction in icerisinde belirlenen bir constant (the displacement) a eklenmesiyle bulunur Bu mode indexed veya relative olarak da bilinir Instruction Load word MAL lw R, address R <-- M[address] TAL lw R t, I(R b ) 1000 11bb bbbt tttt iiii iiii iiii iiii R t <-- M[[R b ] + (I 15 ) 16 I 15 0 ] opcode reg constant one-word instruction reg address 11/26/2004 Bilgisayar Mimarisi effective address 855 + 11/26/2004 Bilgisayar Mimarisi 856

Control Instructions Load/store mimarilerde sadece load/store instructions ve control instructions address belirlerler Kontrol instructions kosul dogru oldugunda gidilecek instruction in address ini belirlemek zorunda Genelde target address ler bulunulan yerden kisa mesafeler oldugu icin, cogu target address ler control instruction inin address ine kucuk degerli bir offset eklenerek bulunur (PC-relative label: beq var1, var2, label label program assembled edilirken hesaplanir beg var1,var2,offset addressing) 11/26/2004 Bilgisayar Mimarisi 857 11/26/2004 Bilgisayar Mimarisi 858 Load/Store Instructions Immediate addressing lw R, address En genel halde adreess bir constant, bir base register icerir Address, registerin belirledigi degere constant eklenmek suretiyle bulunur Address 4 un kati olmak zorunda lw $22, 12($25) displacement base register Target address: 12+[$12] 11/26/2004 Bilgisayar Mimarisi 859 li R, constant # R constant la R, label la $8, var_name lw $8, ($8) # label a bound olan variable addressini R ye yazar lw $8, var_name la $8, ar # load address of array ar add $8, $8, 20 # get address of sixth element lw $8, ($8) # load element ar[5] 11/26/2004 Bilgisayar Mimarisi 860

data ar: word 0:50 text # $8 -- a flag, 1 if the algorithm is done # $9 -- an offset to the correct element of the array # $10 -- address of the element to compare # $11 -- the array element for comparison # $12 -- the neighbor of the array element for comparison # $14 -- base address of array ar la $14, ar loop: li $8, 1 # flag = true li $9, 0 for: add $10, $14, $9 lw $11, ($10) # load element lw $12, 4($10) # load next element sub $13, $11, $12 blez $13, noswap # if they are in order, don t swap li $8, 0 sw $11, 4($10) # swap elements sw $12, ($10) noswap: add $9, $9, 4 sub $13, $9, 196 # see if end of the array reached blz $13, for beq $8, $0, loop # loop until done 11/26/2004 done Bilgisayar Mimarisi 861