Anda di halaman 1dari 34

Matakuliah : H0162/ Mikroprosesor

Tahun : 2006
Versi : 1/0

Pertemuan 02
Computer Data Format

1
Learning Outcomes

Pada akhir pertemuan ini, diharapkan


Mahasiswa dapat mendemonstrasikan
kemampuan:
• mengkonversikan antar sistem bilangan
(C3)

2
Outline Materi

• Sistem Bilangan
• Konversi antar Sistem Bilangan
• Format Data

3
4
Sistem Bilangan Desimal dan Biner

5
Sistem Bilangan

6
Biner

• Sistem bilangan Biner mengggunakan


hanya dua simbol yaitu 0 dan 1, walau
demikian, sistem basis 2 ini dapat
digunakan untuk mewakilkan jumlah
berapapun yang dapat diwakilkan oleh
desimal atau sistem bilangan lainnya.

7
Octal

• Mempunyai basis delapan, yaitu dari 0 s/d


7 dengan setiap satu digit octal dijadikan
tiga digit biner
• Konversi Biner  Octal yaitu dengan
setiap tiga digit biner dijadikan satu digit
octal

8
Desimal

• Mempunyai basis sepuluh yaitu dari 0 s/d


9

9
Hexadesimal

• Mempunyai basis enam-belas yaitu dari 0


s/d 9 serta A s/d F
• Dengan setiap satu digit hexa dijadikan
empat digit biner

10
Dasarnya: Desimal  Desimal

11
Konversi Bilangan

• Desimal  Desimal

• Biner  Desimal

12
Biner  Desimal

13
Biner  Desimal

14
Desimal  Biner

• Berapakah 87d dalam binernya?


• Caranya bagilah 87 dengan 2 sampai
habis, lalu tulis jawabannya dari bawah

15
Octal  Desimal

16
17
Hexadesimal  Desimal

18
Hexadesimal  Desimal

19
Hexadesimal  Desimal

20
Hexadesimal  Biner

Hexadesimal  Biner  Octal

00 101 100b = 054octal

21
Floating Point

• Exponent. The exponent is shown with excess 127. This


means that the machine exponent is the actual exponent
with 127 added. This has the effect of giving a range of 0
to 255 for the machine representation while the range of
actual values is -128 to +127. If the excess was not used
there would have to be a mechanism for showing a
negative exponent.
• In the example the actual exponent is 1000 (decimal 8).
• The machine representation is:
– 0000 1000 (8) + 0111 1111 (127) = 1000 0111 (decimal 135)
22
• Mantissa. The mantissa is the number being encoded.
Before the number is encoded the point is moved(or
floated) left or right until the value of the number is in the
range: 1 < n < 2
• This is known as normalisation. Since the first digit is
now always going to be 1 there is no need to encode this
digit. The mantissa only includes the digits after the point
and the leading 1 is assumed.
• The number shown above is -1.1011 0011 01*28

23
Computer Data Format

• Alphanumerik
– ASCII
– EBCDIC
• BCD
– Standard BCD
• Packed
• Unpacked
– Gray Code
• Sign dan Unsigned
24
ASCII
ASCII is the most widely used coding system for
alphanumeric characters. The name stands for
the American Standard Code for Information
Interchange.
ASCII characters use 7 bits to encode, upper case
letters, lower case letters, digits, and common
punctuation marks. The first 32 characters are
used for non printable characters, for example
carriage return, line feed, tab, ESC,
acknowledge, negative acknowledgement, etc.

Kunjungi http://www.asciitable.com 25
ASCII

26
EBCDIC

EBCDIC (Extended Binary Coded Decimal Interchange


Code) is a binary code for alphabetic and numeric
characters that IBM developed for its larger operating
systems. It is the code for text files that is used in IBM's
OS/390 operating system for its S/390 servers and that
thousands of corporations use for their legacy
applications and databases. In an EBCDIC file, each
alphabetic or numeric character is represented with an 8-
bit binary number (a string of eight 0's or 1's). 256
possible characters (letters of the alphabet, numerals,
and special characters) are defined.
IBM's PC and workstation operating systems do not use
IBM's proprietary EBCDIC. Instead, they use the industry
standard code for text, ASCII. Conversion programs
allow different operating systems to change a file from
one code to another
27
Standard BCD

• BCD (Binary Coded Decimal) adalah kode


domana setiap digit bilangan desimal
diwakilkan dengan ekivalennya karena
semua digit desimal hanya sebesar 9
maka 4 bit dibutuhkan untuk
mengambarkan tiap digit
–8 7 4(desimal)
– 1000 0111 0100(BCD)

28
BCD: Packed dan UnPacked

• Packed Data BCD packed disimpan


sebagai 2 digit per byte biasanya tersebut
digunakan dalam instruction set pada
mikroprossesor untuk penjumlahan dan
pengurangan BCD
– 12 = 0001 0010
• Unpacked Data BCD unpacked disimpan
sebagai 1 digit per byte data tersebut
biasa didapat dari keypad atau keyboard
– 12 = 0000 0001 0000 0010

29
Gray Code
• Definition: An ordering of 2n binary numbers such that only
one bit changes from one entry to the next.
• Gray code termasuk dalamkelas kode yang mempunyai
perubahan minimum, dimana hanya 1 bit dalam grup kode
yang berubah ketika bergerak dari langkahyang satu ke
langkah yang berikutnya. Gray code biasa digunakan dalam
situasi dimana kode-kode lain seperti biner dapat
menghasilkan error atau hasil yang meragukan, selama
masa perubahan dimana lebih dari 1 bit dari kode tersebut
yang berubah.
• Gray codes are useful in mechanical encoders since a slight
change in location only affects one bit. Using a typical binary
code, up to n bits could change, and slight misalignments
between reading elements could cause wildly incorrect
readings
• Gray code (http://www.nist.gov/dads/HTML/graycode.html)

30
31
http://www.ida.net/users/tetonsl/railroad/graycode.htm
32
Signed dan Unsigned
• MSB (Most Significant Bit) digunakan sebagai penanda
negative dimana 0 merupakan possitive number, dan 1
adalah negative number.
• Ada 2 cara merepresentasikan bilangan negative:
– Sign & Magnitude, dimana MSB (Most Significant Bit) merupakan
penandanya dan value-nya didapat dari magnitude-nya.
• Kelemahan sistem ini, adalah operasi aritmatik tidak bisa dilakukan
terhadap binary ini (karena misalkan binary signed 4 bit, sebenarnya
value hanya direpresentasikan oleh 3 bit terakhir dan bit MSB sebagai
sign saja). Dengan 4 bit, data memiliki range dari -7 hingga +7.

– Two's complement, dimana MSB (Most Significant Bit) merupakan


penandanya dan value-nya didapat dari konversi two's complement.
• Cara melakukan operasi Two's complement dapat dilihat pada simulasi
berikut (http://scholar.hw.ac.uk/site/computing/activity11.asp?outline=).
Dengan 4 bit, data memiliki range dari -8 hingga +7 dan dapat
dioperasikan dalam operasi arimatik.

33
Two Complement

34

Anda mungkin juga menyukai