BAB II SISTEM BILANGAN DAN KODE BILANGAN
2.1
Pendahuluan Komputer dan sistem digital lainnya mempunyai fungsi utama mengolah
informasi. Sehingga diperlukan metode-metode dan sistem-sistem untuk merepresentasikan informasi dalam bentuk yang dapat dimanipulasi dan disimpan oleh perangkat elektronik. Bab ini membahas tentang sistem bilangan dan kode bilangan yang sering digunakan di dalam komputer dan sistem digital lainnya. Topik sistem bilangan mencakup sistem bilangan desimal, biner, oktal, dan heksadesimal serta sistem pengkonversian dari satu sistem bilangan ke sistem bilangan yang lain. Sedangkan kode bilangan mencakup kode Binary Coded Decimal (BCD), Excess-3, Gray, dan American Standrad Code for Information Interchange (ASCII).
2.2
Sistem Bilangan Sistem bilangan yang kita gunakan sehari-hari adalah sistem bilangan
desimal. Ketika berbicara angka, pikiran kita langsung terhubung dengan suatu digit dari 0 s/d 9. Di dalam sistem digital selain bilangan desimal, ada lagi sistem bilangan yang umum dipakai yaitu sistem bilangan biner, oktal, dan heksadesimal. Peralatan elektronika digital menggunakan sistem bilangan biner. Beberapa sistem komputer ada yang menggunakan sistem bilangan oktal. Komputer digital dan sistem
yang
berdasarkan
mikroprosesor
menggunakan
sistem
bilangan
heksadesimal.
2.2.1 Bilangan Desimal Sistem bilangan desimal menggunakan simbol 0, 1, 2, 3, 4, 5, 6, 7, 8, dan 9. Sistem bilangan desimal disebut juga sistem basis 10 atau radiks 10. Radiks dan basis merupakan istilah yang mempunyai arti yang sama, yaitu menyatakan jumlah digit yang terdapat pada satu sistem bilangan. Sistem bilangan desimal disebut sistem basis 10 karena mempunya 10 simbol untuk merepresentasikan bilangannya. Lambang basis dikutsertakan pada kanan bawah suatu bilangan.
Contoh : 28510 atau 285(10). Khusus untuk bilangan desimal, boleh tidak mencantumkan basis tersebut pada bilangannya. Dengan kata lain, setiap bilangan yang dalam penyajian tidak terdapat simbol radiks-nya, berarti bilangan tersebut adalah bilangan desimal. Sistem bilangan mempunyai karakteristik nilai-tempat (place-value), yang masing-masingnya mempunyai bobot sendiri-sendiri sesuai dengan tempat dimana angka/digit tersebut berada. Bobot untuk bilangan desimal adalah : •
Bobot satuan
: 100 = 1
•
Bobot puluhan
: 101 = 10
•
Bobot ratusan
: 102 = 100
•
Bobot ribuan
: 103 = 1000
, dst
Nilai suatu bilangan merupakan hasil penjumlahan dari perkalian setiap angka/digit dengan bobot tempat angka tersebut berada.
Misalnya : bilangan
desimal 347. Pada bilangan tersebut angka 3 menempati posisi satuan, angka 4 pada posisi puluhan, dan angka 7 pada posisi ratusan. Sehingga penjumlahan 300+40+7 menghasilkan angka desimal total sebesar 347. ratusan
puluhan
2
1
satuan
34710 = (3 x 10 ) + (4 x 10 ) + (7 x 100) =
300
+
40
+
7
2.2.2 Bilangan Biner Sistem digital biasanya dikonstruksi dengan dua keadaan, seperti saklar, transistor, dan komponen-komponen elektronika lainnya yang digunakan dalam sistem digital. Sistem bilangan yang cocok untuk merepresentasikan bilangan di dalam sistem digital adalah sistem bilangan biner. Itulah sebabnya mengapa kita perlu mempelajari sistem bilangan biner ketika kita ingin bekerja dalam sistem digital. Bilangan biner merupakan bilangan dengan radiks 2. Simbol yang digunakan hanya 0 dan 1. Setiap digit biner (binary digit) disebut bit. Bobot faktor biner berdasarkan tempat bit berada, seperti yang tertera berikut ini :
7
bit ke-5
bit ke-4
bit ke-3
bit ke-2
bit ke-1
bit ke-0
Bobot
25
24
23
22
21
20
Desimal
32
16
8
4
2
1
Bit ke-0 (bit paling kanan) dari bilangan biner merupakan bit yang tidak signifikan (LSB, Least Significant Bit), sedangkan bit paling kiri dari bilangan biner merupakan bit yang paling signifikan (MSB, Most Significant Bit). Contoh : B5
B4
B3
B2
B1
B0
1
0
1
0
1
1
MSB
LSB
Catt. Untuk pekerjaan dalam elektronika digital, Anda harus menghafal simbol biner yang digunakan untuk cacah paling sedikit sampai 9.
2.2.3 Bilangan Oktal Sistem bilangan oktal menggunakan 8 macam simbol bilangan, yaitu 0, 1, 2, 3, 4, 5, 6, dan 7, oleh karena itu bilangan oktal merupakan bilangan dengan radiks 8. Sistem bilangan ini merupakan metode dari kelompok bilangan biner (pengelompokan 3 bit), dan biasanya digunakan oleh perusahaan komputer yang menggunakan kode 3 bit untuk merepresentasikan instruksi/operasi. Pada sistem yang demikian, bilangan oktal digunakan sebagai perwakilan pengganti bilangan biner, sehingga pengguna dapat dengan mudah membuat ataupun membaca instruksi komputer. Untuk lebih memudahkan dalam memahami bilangan oktal, dapat dilihat pada tabel 2.1 berikut ini : Tabel 2.1 Bilangan Desimal yang direpresentasikan dengan Bilangan Biner dan Oktal
Desimal
Biner
Oktal
0
000
0
1
001
1
2
010
2
8
3
011
3
4
100
4
5
101
5
6
110
6
7
111
7
8
1000
10
9
1001
11
10
1010
12
2.2.4 Bilangan Heksadesimal Sistem bilangan heksadesimal menggunakan 16 simbol, yaitu : 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. Huruf A untuk cacahan 10, B untuk 11, C untuk 12, D untuk 13, E untuk 14, dan F untuk 15. Sistem bilangan ini merupakan metode dari pengelompokan 4 bit. Komputer digital dan sistem yang berdasarkan mikroprosesor menggunakan sistem bilangan heksadesimal. Untuk lebih memudahkan dalam memahami bilangan heksadesimal, dapat dilihat pada tabel 2.2 berikut ini : Tabel 2.2 Bilangan Desimal yang direpresentasikan dengan Bilangan Biner dan Heksadesimal
Desimal
Biner
Heksadesimal
0
0000 0000
00
1
0000 0001
01
2
0000 0010
02
3
0000 0011
03
4
0000 0100
04
5
0000 0101
05
6
0000 0110
06
7
0000 0111
07
8
0000 1000
08
9
2.3
9
0000 1001
09
10
0000 1010
0A
11
0000 1011
0B
12
0000 1100
0C
13
0000 1101
0D
14
0000 1110
0E
15
0000 1111
0F
16
0001 0000
10
17
0001 0001
11
18
0001 0010
12
19
0001 0011
13
20
0001 0100
14
21
0001 0101
15
Konversi Bilangan Desimal
2.3.1 Konversi Bilangan Desimal ke Bilangan Biner Dalam mengubah sistem bilangan desimal ke sistem bilangan lainnya dapat dilakukan dengan metode pembagian berurutan dengan radiksnya. Langkah-langkah metode pembagian untuk mengubah bilangan desimal menjadi bilangan biner (radiks 2) adalah sebagai berikut : 1. Berturut-turut bagi bilangan desimal yang diketahui itu dengan 2. 2. Letakkan hasil baginya tepat di bawah bilangan yang dibagi itu. 3. Letakkan sisa pembagian itu di samping hasil bagi tersebut. 4. Bilangan biner setaranya akan terbentuk oleh sisa pembagian itu dengan sisa terakhir menjadi angka pertama dan sisa pertama menjadi angka terakhir.
Contoh 2.1 Ubahlah bilangan desimal 115 menjadi bilangan biner.
10
Jawab : 2 115
sisa 1
2
57
sisa 1
2
28
sisa 0
2
14
sisa 0
2
7
sisa 1
2
3
sisa 1
1
Jadi,
115(10) = 1110011(2)
Untuk bilangan pecahan desimal, pengubahan bilangan tersebut menjadi bilangan biner dapat dilakukan dengan langkah-langkah berikut : 1. Berturut-turut kalikanlah pecahan desimal itu dengan 2. 2. Tulislah hasil perkalian itu dengan lengkap, tetapi pisahkan bagian bulat dari bagian pecahannya. 3. Letakkan hasil kali tersebut tepat di bawah bilangan yang dikalikan itu. 4. Lakukan perkalian itu hanya untuk bagian pecahannya saja dengan mengabaikan bagian bulatnya sampai semua angka di bagian pecahannya sama dengan nol atau sampai banyaknya angka yang diperlukan untuk derajat ketepatannya telah dicapai. 5. Bagian bilangan bulat hasil perkalian tersebut yang pertama yang diperoleh dari perkalian yang pertama merupakan bagian pecahan bilangan biner yang pertama. Untuk bilangan desimal yang merupakan gabungan antara bilangan bulat dan bilangan pecahan, masing-masing bagian itu (bulat dan pecahannya) dikerjakan secara terpisah.
Contoh 2.2 Ubahlah bilangan desimal 0,6875 menjadi bilangan biner.
11
Jawab :
Jadi,
0,6875
0,375
0,750
0,500
x2
x2
x2
x2
1,375
0,75
1,500
1,000
0,6875(10) = 0,1011(2)
2.3.2 Konversi Bilangan Desimal ke Bilangan Oktal Konversi bilangan desimal ke bilangan oktal dapat dilakukan dengan cara membagi bilangan desimal tersebut dengan 8 secara terus menerus, dan hasilnya dibaca dari bawah ke atas.
Contoh 2.3 Ubahlah bilangan desimal 574 menjadi bilangan oktal. Jawab : 8
574
sisa 6
8
71
sisa 7
8
8
sisa 0
1 Jadi, 574(10) = 1076(8) Konversi bilangan pecahan desimal ke bilangan oktal dapat dilakukan dengan cara mengalikan bilangan pecahan desimal tersebut dengan 8 secara terus menerus, sampai diperoleh bilangan nol di belakang koma. Jika setelah beberapa kali perkalian tidak menghasilkan bilangan nol di belakang koma, ambil beberapa digit sampai banyaknya angka yang diperlukan untuk derajat ketepatan. Berarti nilai tersebut adalah nilai aproksimasi (pendekatan).
Contoh 2.4 Ubahlah bilangan pecahan desimal 0,1875 menjadi bilangan oktal.
12
Jawab : 0,1875
0,500
x 8
x 8
1,500
4,000
Jadi, 0,1875(10) = 0,14(8)
2.3.3 Konversi Bilangan Desimal ke Bilangan Heksadesimal Konversi bilangan desimal ke bilangan heksadesimal dapat dilakukan dengan cara membagi bilangan desimal tersebut dengan 16 secara terus menerus, dan hasilnya dibaca dari bawah ke atas. Konversi bilangan pecahan desimal ke bilangan heksadesimal dapat dilakukan dengan mengalikan bilangan pecahan desimal tersebut dengan 16 secara terus menerus, sampai diperoleh bilangan nol di belakang koma.
Contoh 2.5 Ubahlah bilangan desimal 586 menjadi bilangan heksadesimal. Jawab : 16
586
sisa 10 = A
16
36
sisa 4
2 Jadi, 498(10) = 24A(H) Contoh 2.6
Ubahlah bilangan pecahan desimal 0,5 menjadi bilangan
heksadesimal. Jawab : 0,5 x16 8,000 Jadi, 0,5(10) = 0,8(H)
13
2.4
Konversi Bilangan Biner
2.4.1 Konversi Bilangan Biner ke Bilangan Desimal Konversi bilangan biner ke bilangan desimal dapat dilakukan dengan 2 (dua) cara, yaitu : Cara I : Kalikan setiap bit dengan bobot faktor biner yang bersesuaian lalu jumlahkan hasilnya. Cara II : Tulis bilangan binernya, lalu tulis bobot faktor biner di bawah masingmasing bit. Setelah itu coret bobot faktor biner di bawah bit 0, dan jumlahkan semua bobot faktor boner yang tidak dicoret.
Contoh 2.7 Ubahlah bilangan biner 1110010 menjadi bilangan decimal. Jawab : •
Cara I : 1010110(2) = (1x26) + (1x25) + (1x24) + (0x23) + (0x22) + (1x21) + (0x20) = 64 + 32 + 16 + 0 + 0 + 2 + 0 = 114(10)
•
Cara II : 1
1
1
0
0
1
0
26
25
24
23
22
21
20
64 + 32 + 16 + 8
+
4
+ 2 + 1
(tulis binernya)
= 114(10) (jumlahkan bilangan yang tidak dicoret)
Contoh 2.8 Ubahlah bilangan biner 1001,1110 menjadi bilangan decimal. Jawab : 1
0
0
1
23
22
21
20
8
+ 0
+ 0
+ 1
, 1 2-1
1
1
0
2-2
2-3
2-4
+ 0,5 + 0,25 + 0,125 + 0
= 9,875(10)
2.4.2 Konversi Bilangan Biner ke Bilangan Oktal Untuk mengubah bilangan biner ke bilangan oktal dapat dilakukan dengan mengelompokkan bilangan biner itu tiga bit – tiga bit dimulai dari bit LSB, kemudian mengubah masing-masing kelompok tersebut menjadi setara oktalnya.
14
Contoh 2.9 Ubahlah bilangan biner 10010111(2) menjadi bilangan octal. Jawab : 0 1 0 0 1 0 1 1 1(2) 2
2
= 227(8)
7
Contoh 2.10 Ubahlah bilangan biner 1110,100101 menjadi bilangan oktal. Jawab : 0 0 1 1 1 0 , 1 0 0 1 0 1(2) = 16,45(8) 1
6
4
5
2.4.3 Konversi Bilangan Biner ke Bilangan Heksadesimal Untuk mengubah bilangan biner ke bilangan heksadesimal dapat dilakukan dengan mengelompokkan bilangan biner itu empat bit – empat bit dimulai dari bit LSB, kemudian mengubah masing-masing kelompok tersebut menjadi setara heksadesimalnya.
Contoh 2.11 Ubahlah bilangan biner 101001001110 menjadi bilangan heksadesimal. Jawab : 1 0 1 0 0 1 0 0 1 1 1 0(2) = A4E(16) A
2.5
4
E
Konversi Bilangan Oktal
2.5.1 Konversi Bilangan Oktal ke Bilangan Desimal Konversi bilangan oktal ke bilangan desimal dapat dilakukan dengan cara mengalikan setiap digit dengan bobot faktor oktal yang bersesuaian lalu jumlahkan hasilnya.
Contoh 2.12 Ubahlah bilangan oktal 423 menjadi bilangan desimal.
15
Jawab : 415(8) = (4x82) + (1x81) + (5x80) = 256 + 8
+
5
= 269(10)
2.5.2 Konversi Bilangan Oktal ke Bilangan Biner Konversi bilangan oktal ke biner dapat dilakukan dengan cara mengubah setiap digit oktal menjadi bilangan biner 3 bit.
Contoh 2.13 Ubahlah bilangan oktal 745 menjadi bilangan biner. Jawab : 7
4
5(8)
111
100
101(2)
Jadi, 745(8) = 111100101(2)
2.6
Konversi Bilangan Heksadesimal
2.6.1 Konversi Bilangan Heksadesimal ke Bilangan Desimal Konversi bilangan heksadesimal ke bilangan desimal dapat dilakukan dengan cara mengalikan setiap digit dengan bobot faktor heksa yang bersesuaian lalu jumlahkan hasilnya.
Contoh 2.14 Ubahlah bilangan oktal 1C7 menjadi bilangan desimal. Jawab : 1C7(H) = (1x162) + (12x161) + (7x160) = 256
+ 192
+ 112
= 560(10)
2.6.2 Konversi Bilangan Heksadesimal ke Bilangan Biner Konversi bilangan heksadesimal ke bilangan biner dapat dilakukan dengan cara mengubah setiap digit heksadesimal menjadi bilangan biner 4 bit.
16
Contoh 2.13 Ubahlah bilangan heksadesimal D2A menjadi bilangan biner. Jawab : D
1101
2
A(8)
0010 1010(2)
Jadi, D2A(H) = 110100101010(2)
2.7
Kode Bilangan Data yang diproses di dalam sistem digital umumnya direpresentasikan
dengan menggunakan kode tertentu. Terdapat berbagai macam sistem kode seperti Binary Coded Decimal (BCD), gray, excess-3, dan ASCII. Dengan menggunakan kode bilangan, dapat disajikan berbagai macam jenis data seperti bilangan, simbol maupun huruf ke dalam besaran digital. Kode-kode tersebut disusun dengan suatu cara menggunakan bilangan biner yang membentuk kelompok tertentu. Beberapa istilah yang berhubungan dengan pengelompokkan bilangan biner, yaitu : •
Nibble adalah kode biner 4-bit Contoh : 1001, 1010, dan 1110
•
Byte adalah kode biner 8-bit Contoh : 10011101 dan 10100110 Catatan :
1 byte = 8 bit 1 KB (baca : Kilobyte) = 1024 byte = 210 byte
•
Word adalah kode biner 16-bit
•
Double Word adalah kode biner 32-bit
2.7.1 Kode BCD (Binary Coded Decimal) Kode BCD digunakan untuk merepresentasikan digit desimal 0 s.d. 9. Dalam kode BCD, setiap digit desimal tersebut direpresentasikan dengan menggunakan bilangan biner 4 bit. Bilangan biner 4 bit akan menghasilkan 16
17
kombinasi yang berbeda, sehingga pada system kode BCD terdapat 6 buah kode yang tidak digunakan (invalid code), yaitu : 1010, 1011, 1100, 1101, 1110, dan 1111. Kode BCD untuk digital 0 s.d 9 dapat dilihat pada Tabel 2.3.
Tabel 2.3 Kode BCD
Desimal
Kode BCD
0
0000
1
0001
2
0010
3
0011
4
0100
5
0101
6
0110
7
0111
8
1000
9
1001
Contoh 2.14 Tulislah kode BCD untuk bilangan decimal 3973. Jawab : 3
9
7
3
0011
1001
0111
0011
Jadi, 3973 (10) = 0011 1001 0111 0011 (BCD) Dengan menggunakan cara yang sama dengan contoh 2.14 di atas, dapat dilakukan konversi baliknya (mengubah kode BCD menjadi bilangan decimal).
Contoh 2.15 Ubahlah bilangan BCD 1001 0110 0111 0010 ke bilangan decimal.
18
Jawab : 1001
0110
0111
0010
9
6
7
2
Jadi, 1001 0110 0111 0010 (BCD) = 9672 (10) Sekilas kode BCD nampak seperti sistem biner, tetapi pada kenyataannya keduanya adalah berbeda. Untuk melihat perbedaan keduanya, perhatikan contoh 2.16 berikut.
Contoh 2.16 Ubahlah bilangan desimal 129 menjadi bilangan biner dan kode BCD. Jawab : Dengan menggunakan metode bagi 2, dapat ditemukan : 129(10) = 10000001(2)
Sistem Biner
Konversi sistem desimal ke kode BCD : 129(10) = 0001 0010 1001(BCD)
Kode BCD
Keunggulan kode BCD adalah mudahnya mengubah dari dan ke bilangan desimal. Kerugiannya adalah kode BCD tidak dapat digunakan untuk operasi aritmatika yang hasilnya melebihi 9. Kode BCD digunakan pada sistem digital bila informasi desimal diperlukan sebagai masukan atau diperagakan sebagai keluaran. Voltmeter digital, jam digital, dan termometer digital merupakan contoh alat yang menggunakan kode BCD karena alat itu memperagakan keluarannya dalam desimal. Kalkulator juga menggunakan kode BCD karena bilangan masukannya diberikan dalam bentuk desimal melalui tombol-tombolnya dan keluarannya diperagakan dalam bentuk desimal. Beberapa komputer jaman dulu mengolah bilangan BCD, tetapi jenis komputer ini lebih lambat dan lebih rumit dibandingkan komputer biner. Sebuah komputer tidak hanya sekedar memproses bilangan, tetapi juga harus dapat
19
bekerja dengan data-data non-numerik yang lain. Dengan kata lain, sebuah komputer modern harus dapat memproses data alfanumerik (huruf alfabet, bilangan, dan simbol-simbol lain. Karena itulah komputer modern menggunakan CPU yang memproses bilangan biner dan bukan bilangan BCD. Dalam
bidang
teknik
digital
terdapat
rangkaian
yang
dapat
membangkitkan kode BCD dari suatu bilangan desimal yang dimasukkan ke dalam inputnya, dan rangkaian tersebut dinamakan pengkode desimal ke BCD (decimal to BCD encoder). Terdapat pula rangkaian yang fungsinya merupakan kebalikan dari fungsi encoder, yaitu decoder BCD ke desimal. Untuk pembahasan yang lebih mendalam tentang encoder dan decoder, dapat dilihat pada Bab V.
2.7.2 Kode Excess-3 (XS-3) Excess-3 artinya kelebihan tiga. Sesuai dengan namanya, penetapannya diperoleh dari penambahan 3 pada nilai binernya. Tabel 2.2 berikut ini menunjukkan kode XS-3. Tabel 2.2 Kode Excess-3
Desimal
Kode Excess-3
0
0011
1
0100
2
0101
3
0110
4
0111
5
1000
6
1001
7
1010
8
1011
9
1100
Seperti halnya dengan kode BCD, kode XS-3 ini hanya menggunakan sepuluh dari enambelas kombinasi yang ada. Enam kelompok bit yang tidak dipakai adalah 0000, 0001, 0010, 1101, 1110, dan 1111.
20
Contoh 2.17 Kodekan bilangan decimal 129 ke system XS-3. Jawab :
Jadi,
1
2
9
0001
0010
1001
Setara binernya
0011
0011
0011 +
Tambah tiga
0100
0101
1100
129(10) = 0100 0101 1100 (XS-3)
Contoh 2.18 Kembalikan kode XS-3 0110 1001 1100 1000 menjadi bilangan desimal.
Jawab : 0110
1001
1100
1000
6
9
12
8
Setara desimalnya
3
3
3
3 -
Dikurang tiga
3
7
9
5
Jadi, 0110 1001 1100 1000(XS-3) = 3795(10) Kode XS-3 ini dirancang untuk mengatasi kesulitan kode BCD dalam perhitungan aritmatika. Penjumlahan dengan menggunakan kode XS-3 dapat dilakukan dengan mengikuti aturan berikut : 1. Penjumlahan mengikuti aturan penjumlahan biner biasa 2. a. Jika hasil penjumlahan untuk suatu kelompok menghasilkan suatu simpanan desimal, tambahkan 0011 ke kelompok tersebut. b. Jika hasil penjumlahan untuk setiap kelompok tidak menghasilkan simpanan desimal, kurangkan 0011 dari kelompok tersebut.
Contoh 2.19 Jumlahkan bilangan decimal 63 dengan 26 dengan menggunakan system penjumlahan kode XS-3.
21
Jawab : 63
→
1001 0110
26 +
→
0101 1001 +
89
→
1110 1111
penjumlahan biner biasa
- 0011 0011 – 1011 1100
Penjumlahan contoh 2.19 di atas tidak mempunyai simpanan decimal. Untuk proses penjumlahan yang mempunyai simpanan desimal dapat dilihat pada contoh 2.20.
Contoh 2.20 Jumlahkan bilangan decimal 38 dengan 29 dengan menggunakan system penjumlahan kode XS-3.
Jawab : 38
→
0110 1011
29 +
→
0101 1100 +
67
→
1100 0111
penjumlahan biner biasa
- 0011 0011 + 1001 1010
2.7.3 Kode Gray Kode gray merupakan kode 4-bit tanpa bobot dan tidak sesuai untuk operasi aritmatika. Kode gray memiliki keunikan, yaitu hanya satu bit yang berubah dalam setiap dua kata berurutan. Atau dengan kata lain, hanya satu bit yang berubah bila dicacah dari atas ke bawah. Kode gray biasanya digunakan sebagai data yang menunjukkan posisi dari suatu poros mesin yang berputar. Tabel 2.4 menunjukkan kode gray yang merepresentasikan digit desimal 0 s.d. 9.
22
Tabel 2.4 Kode Gray
Desimal
Biner
Kode Gray
0
0000
0000
1
0001
0001
2
0010
0011
3
0011
0010
4
0100
0110
5
0101
0111
6
0110
0101
7
0111
0100
8
1000
1100
9
1001
1101
10
1010
1111
11
1011
1110
12
1100
1010
13
1101
1011
14
1110
1001
15
1111
1000
2.7.4 Kode ASCII (American Standard Code for Information Interchange) Untuk memperoleh informasi yang keluar dan masuk pada computer, kita perlu menggunakan semacam kode alfanumerik (bilangan, huruf, dan symbolsimbol lainnya) untuk unit I/O dari computer yang bersangkutan. Dulu pernah terjadi bahwa setiap pabrik menggunakan kode yang berbeda dan menimbulkan segala macam kerancuan. Akhirnya industri-industri computer sepakat untuk menciptakan system kode untuk unit I/O tersebut yang dikenal sebagai ASCII. Dengan system kode ini setiap pabrik dapat membakukan perangkat keras I/O seperti keyboard, printer, monitor, dan lain-lain. Kode ASCII adalah kode 7-bit dengan format susunan : a6 a5 a4 a3 a2 a1 a0 Setiap a disusun dalam digit 0 dan 1. Kode 7-bit menghasilkan 128 karakter yang berbeda.
23
Tabel 2.5 Kode ASCII
Pada prakteknya, masing-masing karakter direpresentasikan dengan menggunakan 2 digit heksadesimal. Beberapa contohnya dapat dilihat pada tabel 2.6, sedangkan Tabel 2.7 menampilkan representasi karakter ke dalam heksadesimal secara lengkap. Tabel 2.6. Contoh Representasi Kode ASCII dalam Heksadesimal untuk kata “Digital”
Karakter
Kode ASCII Biner
Kode ASCII Heksadesimal
D
1000100
44
i
1101001
69
g
1100111
67
i
1101001
69
t
1110100
74
a
1100001
61
l
1101100
6C
24
Tabel 2.7. Kode ASCII dalam Heksadesimal
Data informasi dibawa dengan menggunakan karakter control (control character). Contoh : STX (start of text) dan ETX (end of text) digunakan untuk menentukan batas/limit suatu data/text. Karakter-karakter kontrol dapat dilihat pada tabel 2.8 berikut : Tabel 2.8. Karakter ASCII untuk Kontrol Informasi
Komputer modern menggunakan kode ASCII 8-bit (extended ASCII) yang merupakan perluasan dari ASCII 7-bit dengan tambahan 128 karakter lagi yang umumnya digunakan mewakili karakter grafik.
25
2.8 1.
Soal-soal Latihan Konversikan bilangan biner berikut ke bilangan desimal : (a) 11001101
2.
(b) 1C3B
(c) 12,A63
(b) 176
(c) 12,376
Konversikan bilangan desimal berikut ke bilangan oktal : (a) 376
6.
(c) 13,456
Konversikan bilangan desimal berikut ke bilangan biner : (a) 87
5.
(b) 1034
Konversikan bilangan heksadesimal berikut ke bilangan desimal : (a) 26A
4.
(c) 10,1101
Konversikan bilangan oktal berikut ke bilangan desimal : (a) 735
3.
(b) 1010011,1
(b) 1146
(c) 72,546
Konversikan bilangan desimal berikut ke bilangan heksadesimal : (b) 986
(b) 2136
(c) 523,675
7. Sebuah sistem PC menggunakan kode pengalamatan 20 bit untuk mengidentifikasi lokasi-lokasi memorinya. a. Berapa banyak karakter heksadesimal yang dibutuhkan untuk mengidentifikasi alamat untuk setiap lokasi memori? b. Berapa heksadesimal 5 digit lokasi memori untuk alamat yang ke 100 ? c. Jika menggunakan 50 lokasi memori untuk menyimpan data dan dimulai pada lokasi 00096H, berapa lokasi data yang terakhir ?
8.
Tentukan basis x dari bilangan di bawah ini : (a) 361(10) = 551(x)
9.
(b) 859(10) = 5B7(x)
(c) 982(10) = 1726(x)
210(10) = ……….. (2) = ………… (8) = …………. (16)
10. Ubahlah bilangan desimal 305 ke bilangan biner, oktal, heksadesimal, dan BCD 11. Kodekan bilangan desimal berikut ke dalam kode BCD dan Excess-3 : (a) 39
(b) 195
(c) 1475
12. Kembalikan kode BCD berikut menjadi bilangan desimalnya : (a) 1001 1000 0110
(b) 1000 0111 0100 1001 0001
13. Berapa representasi BCD yang dikirim ke display 2 digit thermometer digital yang mengukur suhu sebesar 38 derajat celcius? 14. Kembalikan kode Excess-3 berikut menjadi bilangan desimalnya : (a) 1001 1000 0110
(b) 1000 0111 0100 1001 0001
26
15. Kodekan
masing-masing
karakter
berikut
ke
dalam
kode
ASCII.
Representasikan dengan menggunakan bilangan heksadesimal. (b) 1980
(b) A = b + C
(c) Teknik Digital.
27
Cara mengubah bilangan desimal menjadi kode gray dapat dilihat pada contoh 2.21 berikut ini.
Contoh 2.21 Ubahlah 12(10) dalam bentuk kode Gray. ....... lihat hal 43 buku afif
28