2 nin kuvvetleri P&H sections 4.1-4.3 section 4.8 - sayfa 280 1 2 9 512 2 4 10 1,024 3 8 11 2,048 4 16 12 4,096 5 32 13 8,192 6 64 14 16,384 7 128 15 32,768 8 256 16 65,536 1 2 2^10 2^20 2^30 2^40 2^32 2 nin kuvvetleri approx 1 bin (Kilo) approx 1 million (Mega-) approx 1 billion (Giga-) approx 1 trillion (Tera-) approx 4 billion (4 Giga-) Ilgili prefixes ler Kilo approx 1 thousand 10^3 Mega approx 1 million 10^6 Giga approx 1 billion 10^9 Tera approx 1 trillion 10^12 Start with capital letters 3 4
Kucukler milli one thousandth 10 ^ -3 micro one millionth 10 ^ -6 nano one billionth 10 ^ -9 pico one trillionth 10 ^ -12 Start with small letters Speed of light is 1 foot per nanosecond Decimal Octal Hexadecimal Binary Number systems 5 6 Decimal system, base 10 History -- we have 10 fingers 253 means 2*100 + 5*10 + 3*1 1,10,100 (from R to L) are the weights 10 digits, values 0 through 9 After 9 comes 10 (double digits) Octal system, base 8 Mickey Mouse has 8 fingers 253 means 2*64 + 5*8 + 3*1 1, 8, 64 agirliklari gosterir 8 digits, degerler 0 dan 7 ye kadar 7 den sonra 10 gelir Octal system bazi eski bilgisayarda bellek address lerinin gosterimi icin kullanilirdi Ornek: 177462 7 8
Hexadecimal system, base16 16 digits, degerler 0-9 ve A-F 3B6 = 3*256 + B*16 + 6*1 Agirliklar 1, 16, 256 F den sonra 10 gelir Modern bilgisayarlarda bellek address lerini gostermek icin kullanilmaktadir Ornek: 3C0F95EA Binary system, base 2 2 digits, degerler 0 ve 1 1011 = 1*8 + 0*4 + 1*2 + 1*1 Agirliklar: 1, 2, 4, 8 1 den sonra 10 gelir 0 1 10 11 100 101 110 111 1000 9 10 Binary system, base 2 Bilgisayarlarda hesaplamalar binary system e gore olur Bellege ve diske instruction ve data nin depolanmasinda kullanilir Insanlar icin pratik degildir 100101011101 = 4701 Nnumber systems Bilgisyarda hesaplamalar binary systeme gore yapilir Kullanici icin input/output decimal systeme gore gerceklenir Software binary i decimal e ve decimal i de binary e cevirir 11 12
Convert Binary to Decimal Convert Decimal to Binary Binary Value 10101 2 1*16 + 0*8 + 1*4 + 0*2 + 1*1 = 21 10 53 10 = 110101 2 Aasgidakileri cevir: 1100 =? 1001 =? 0111 =? 13 53 21 5 1 64 32 16 8 4 2 1 1 1 0 1 0 1 18 10 =? 31 10 =? 14 Decimal notation with fractions 72.53 10 = 7*10 + 2*1 + 5*.1 + 3*.01. decimal point i gosterir Agirliklar 100 10 1..1.01.001 Bu scientific notation degil Bu floating point gosterimi degil Binary notation with fractions 110.10 2 = 1*4 + 1*2 + 0*1 + 1*.5 + 0*.25 = 6.5 10. binary point i gosterir Agirliklar 8 4 2 1. 1/2 1/4 1/8 Bu scientific notation degil Bu floating point gosterimi degil 11.11 10 =? decimal 15 16
Decimal, Hexadecimal, Octal Dec Hex Oc Dec Hex Oct 0 0 000 8 8 1000 1 1 001 9 9 1001 2 2 010 10 A 1010 3 3 011 11 B 1011 4 4 100 12 C 1100 5 5 101 13 D 1101 6 6 110 14 E 1110 7 7 111 15 F 1111 Convert Binary to Power 2 base Very easy -- convert digit-by-digit A27F <=> 1010 0010 0111 1111 (Hex-Bin) 327 <=> 011 010 111 (Octal-Binary) B4C5 =? 1010 0110 1001 =? 17 18 Binary-coded decimal (BCD) Defn: Store each decimal digit in binary Ornek: 259 stored as 0010 0101 1001 Pro: digit-by-digit conversion is easy Con: Takes 4 bits per digit, uses only 10, 16 degerden 6 tanesi kullanilmaz, 62 pct efficient Eski makinalarda, ozellikle mali hesaplamalarda kullanilirdi Bits Bytes Words Bitler nasil birlestirilmeliki pratikte kullanilabilir seyler yapilabilsin? 19 20
Binary Digit (Bit) Bilgi depolamada temel birim 2 durum soz konusu: 0-1, T-F, umkunon- Off, High-Low A coin flip is a binary digit: Head or Tail A light switch is a binary digit: Off or On Iki deger alabilen herhengi bir seyi 1 bitle temsil etmek Combining bits 1 bit in 2 durumu var: 0 1 2 bit in 4 duumu var : 00 01 10 11 3 bit in 8 durumu var: 000 001 010 011 100 101 110 111 N bit in 2 N durumu var 21 22 Byte 8 bit ten olusan grup 256 durumu var 1 byte 256 fakli durumu temsil edebilir Disk ve memory kapasiteleri byte olarak ifade edilir Combine bytes into words Yaygin kullanilan word buyuklukleri: 16 bits (2 bytes) 64K degisik durumu temsil eder 32 bits (4 bytes) 4 billion degisik durum 64 bits (8 bytes) 16 quintillion degisik durum Word size standard degil, bilgisyardan bilgisayara degisebilir MIPS word leri 32 bits 23 24
Most, Least Significant Bit Label bit positions MSB LSB 1001101001011011 0 15 1001101001011011 Standard Common Bus, buses Bus: big vehicle you ride in (otobus) Bus (computers): collection of wires 15 0 1001101001011011 Less common MIPS 25 26 Bus nasil temsil edilir? MSB LSB 1001101001011011 16 To somewhere Bitler sunu temsil edebilirler. addresses integers floating point numbers characters instructions states, e.g., that a calculated result is negative 27 28
Addressing individual items MSB 10011 LSB 5 Memory 32 Locations Linear Address 00000 Page 2 Addressing pages and items 10 011 Location 3 Page 0 8 items, numbered 0-7 Page 1 Linear Address 00000 0-Origin Range 0-31 11111 29 Memory 4 pages 8 items per page Page 2 Page 3 8 items, numbered 0-7 11111 30 Memory: important message Memory (paged) bir linear array (dizi) olarak dusunulebilir Dolayisiyle onceki iki slides gercekte ayni seyi ifade ederler Farklilik sadece onlari nasil dusundugumuzden kaynaklanmakta Difference is only in how we think about them Daha sonra instruction ve data nin memory e (DRAM) page ler halinde getirildiklerini gorecegiz Bitler sunu temsil edebilir. addresses integers floating point numbers characters instructions states, e.g., that a calculated result is negative 31 32
Use 3 bits for an integer 8 fakli durum temsil edilebilir Her bir durum farkli bir bit permutasyonu ile temsil edilir 33 1-Origin, 3-bit integer bits represent 000 1 001 2 010 3 011 4 100 5 101 6 110 7 111 8 Natural count 1-8 8 is highest value No zero represented No negative numbers 34 0-Origin, 3-bit integer Sign and Magnitude, 3-bit integer bits represent 000 0 001 1 010 2 011 3 100 4 101 5 110 6 111 7 Unnatural count 0-7 7 is highest value Great for addressing Zero is represented No negative numbers 35 bits represent 111-3 110-2 101-1 100-0 000 0 001 1 010 2 011 3 Neg ve Pos degerler Dogal olmayan sayma 2 tane 0 var 3 en buyuk deger MSB sign bit i gosterir Carpma isleminde kolaylik Bazi ozel durumlarda kullanilir 36
One s complement, 3-bit integer Two s complement, 3-bit integer bits represent 100-3 101-2 110-1 111-0 000 0 001 1 010 2 011 3 Neg ve Pos numbers Flip bits to negate (sayini negative ini bulmak icin 1 ler 0 lara 0 lar 1 lere donusturulur) Unnatural counting Iki tane 0 var En buyuk deger 3 MSB sign bit idir 37 Nadiren kullanilir bits represent 100-4 101-3 110-2 111-1 000 0 001 1 010 2 011 3 Neg ve Pos numbers Natural counting Tek bir 0 var Weights: -4 2 1 En yuksek deger 3 MSB sign bit ini gosterir Toplama icin buyuk kolaylik Standard for computers 38 Two s complement, 16-bit integer bits represent 1000 0000 0000 0000-32768 1000 0000 0000 0001-32767 1111 1111 1111 1110-2 1111 1111 1111 1111-1 0000 0000 0000 0000 0 0000 0000 0000 0001 1 Two s complement icin araliklar 4 bits, range: -8 +7 16 bits, range: -32768 +32767 N bits, range: -2^(N-1) 2^(N-1) - 1 0111 1111 1111 1111 32767 39 40
Negate a number in 2 s comp Butun bitleri flip (invert) et ve 1 ekle Negate 3: 0011 1101 Negate -3: 1101 0011 Negate 6? Negate -8? Negate -6? Negate 0? Largest negative 2 s comp value En kucuk negative sayinin positive i yok cunku bu positive sayi belirlenen alana sigmaz Eger algorithmayi uygularsak? 4 bits: Negate -8 1000 (flip) 0111 (add 1) 1000 Baslangictaki deger elde edildi! 41 42 Invert ve Negate Invert: Her bir bit flip ( 0 sa 1, 1 se 0 sifir) edilir. Ayni zamanda bu isleme Complement de denir Negate (sayiyi negative lemek anlamina gelir) sayiyi flip le ve sonra 1 ekle 2 s complement inde kac tane sign bit i var? 5 0101 (4 bit) 000101 (6 bit) 00000101 (8 bit) Sign bit MSB ile ayni -5: 1011 (4 bit) 111011 (6 bit) 11111011 (8 bit) 43 44
2 s comp icin sign extension Eger bir degeri daha genis bir formata kopyalarsak, sign bit I sola dogru extend edilir 0100 0100 00000100 00000000 00000100 00000000 00000000 00000000 00000100 1101 1101 11111101 11111111 11111101 11111111 11111111 11111111 11111101 45 Bit ler sunu temsil edebilir. addresses integers floating point numbers characters instructions states, e.g., that a calculated result is negative 46 Decimal formatta scientific notation Buyuk sayi: 6.02 x 10 23 Kucuk sayi: 1.32 x 10-9 3 digit mantissa, 2 digit exponent Very wide range, inexact representation, imperfect accuracy, exponent can be + or - Can shift: 0.602 x 10 24 Normalized form: one digit to left of dec point 47 Normalized Number 0.000000001 10 = 1.0 10 x 10-9 3,155,760,000 10 = 3.15576 10 x 10 9 Yukaridaki iki sayi scientific notation da yazilmistir (Nokta nin solunda sadece bir digit var) Normalized number : en solda 0 bulundurmayan scientific notation da yazili number a denir. 1.0 10 x 10-9 normalized scientific notation 0.1 10 x 10-8 normalized scientific notation da degil 10.0 10 x 10 10 normalized scientific notationda degil 48
Floating Point Number Binary tabanli ve normalized duzende yazili sayilara Floating Point Number (FPN) denir C dilinde float ile declare edilirler 1.0 2 x 2-1 1.xxxxxxx 2 x 2 yyyyy xxxxxxx fraction kismini olusturur yyyyy exponent kismini olusturur 49 IEEE 754 Standard IEEE 754 Standard modern bilgisyarlarda floating point number lar temsil etmek icin kullanilan standard dir. 1980 den sonra cikan hemen hemen tum bilgisayarlar bu standardi kullanir Iki tur standard var 32 bits ( single precision) ( C de float) 1 bit sign, 8 bit exponent, 23 bit significant (mantissa) 64 bits (double precision) ( C de double) 1 bit sign, 11 bit exponent, 52 bit significant (mantissa) Her ikisinde de exponent ler icin biased noatation kullanilir 127: singleprecision 50 1023: double precision Ornek S Exponent Significand S 17.15 17.15 10001.001001 E 10001.001001 4 1.0001001001. 2 0 10000011 00010010011001100110011 F.15 *2 = 0.3 0.3 * 2 = 0.6 0.6 * 2 = 1.2 1.2 * 2 = 0.4 0.4 * 2 = 0.8 0.8 * 2 = 1.6 1.6 * 2 = 1.2 1 51 0 10000011 00010010011001100110011 Binary conversion: (-1) s x (1+Significand) x 2 (Exponent Bias) (-1) 0 x (1 + 2-4 + 2-7 +2-10 + 2-11 + 2-14 + 2-15 + 2-18 + 2-19 + 2-22 + 2-23 ) x 2 (131-127) 17.15 52
-0.75 10 0.75 x 2 = 1.5 0.5 x 2 = 1.0-0.75 10 = - 0.11 = - 1.1 x 2-1 1 01111110 10000000000000000000000 Single precision 10111111111010000000000000000000 00000000000000000000000000000000 Double precision Bitler sunu temsil edebilirler. addresses integers floating point numbers characters instructions states, e.g., that a calculated result is negative 53 54 Characters Character ler ASCII code unda temsil edilirler ASCII American Standard Code for Information Interchange Her bir character 1 byte la temsil edilir ABC 65 10 66 10 67 10 0x414243 String ler ASCII null character i ile sonlanir Null in ASCII kod karsiligi 0 (0x00) dir For string, terminate with ASCII null, code 0 Full table in H&P, page 142 55 Bit ler sunu temsil edebilirler. addresses integers floating point numbers characters instructions states, e.g., that a calculated result is negative 56
From the Three levels of language Machine Language op code addr 1 addr 2 10100101 1011010, 1010010 10010101 1101101, 1110101 10010101 1101001, 1110101 11101101 1101100, 1101101 Instructions ve addresses bit lerle temsil edilir All these bits can represent. addresses integers floating point numbers characters instructions states, e.g., that a calculated result is negative 57 58 Storage of state information Processor da current instruction (execute edilmekte olan instruction ) in address inin bilinmesi gerekli Bu address bilgisi PC denen (Program Counter) registerinda tutulur. Hesap sonucuyla ilgili durum bilgileri CarryOut, Negative, Overflow Microcode un current step i Microcoded instructions larda instruction in execute olmasi bir cok adimdan gecer 59