Bilgisayar Mimarisi
Binary, Octal, Hex, real numbers
Kaynak:
Oğuz Ergin - Bilgisayar Mimarisi
Kitap: Computer Organization and Design, Fifth Edition: The Hardware/Software Interface
Binary, Octal and Hexadecimal Number Systems
Converting binary to decimal
(1101 1011)2 = ( ? )10
Binary, Octal and Hexadecimal Number Systems
Converting decimal to binary
(96)10 = ( ? )2
Binary, Octal and Hexadecimal Number Systems
Converting octal to decimal
(145)8 = ( ? )10
Binary, Octal and Hexadecimal Number Systems
Converting decimal to octal
(96)10 = ( ? )8
Binary, Octal and Hexadecimal Number Systems
Converting hexadecimal to decimal
(19F)16 = ( ? )10
Binary, Octal and Hexadecimal Number Systems
Converting decimal to hexadecimal
(96)10 = ( ? )16
Binary, Octal and Hexadecimal Number Systems
Converting hexadecimal to binary
(A96)16 = ( ? )2
Binary, Octal and Hexadecimal Number Systems
Converting binary to hexadecimal
(1011 0101 0110)2 = ( ? )16
Binary, Octal and Hexadecimal Number Systems
Converting binary to hexadecimal
(1011 0101 0110)2 = ( ? )16
Addition in binary numbers
Subtraction of Binary Numbers
taking 2’s complement
number 1’s complement 1’s complement + 1 2’s complement
1111 0000 0000 + 1 0001
1010 0101 0101 + 1 0110
1011 0100 0100 + 1 0101
Subtraction of Binary Numbers
(1001)2 - (0011)2 = ( ? )2
● take 2’s complement of second number
● add numbers
● if MSB is 0, result is positive
● if MSB is 1, result is negative. Take 2’s complement of result.
Addition and Subtraction of Hex numbers
Addition and Subtraction of Hex numbers
bit unit terminology
Bit
Nibble (4 bits)
Byte (8 bits)
Word (16 bits)
double-word (32 bits)
quad-word (64 bits)
bit unit terminology
Ex. How many Megabytes (MB) of data per second can be downloaded with 24
Mb/s internet speed?
ASCII
ASCII (American Standard Code for Information Interchange) data represent alphanumeric characters in
the memory of a computer system. The standard ASCII code is a 7-bit code.
ASCII
BCD Data
Binary-coded decimal (BCD) information is stored in either packed or unpacked forms. Packed
BCD data are stored as two digits per byte and unpacked BCD data are stored as one digit per
byte. The range of a BCD digit extends from 0000 to 1001, or 0–9 decimal.
Byte-sized data
Byte-sized data are stored as unsigned and signed integers.
The difference in these forms is the weight of the leftmost bit position. Its value is 128 for the
unsigned integer and minus 128 for the signed integer.
For example, 80H represents a value of
128 as an unsigned number; as a signed
number, it represents a value of minus
128.
Unsigned integers range in value from 00H
to FFH (0–255). Signed integers range in
value from -128 to 0 to + 127.
Byte-sized data
Word-Sized Data
A word (16-bits) is formed with two bytes of data.
The least significant byte is always stored in the lowest-numbered memory location, and the most
significant byte is stored in the highest. This method of storing a number is called the little endian
format.
An alternate method, not used with
the Intel family of microprocessors, is
called the big endian format.
In the big endian format, numbers are
stored with the lowest location
containing the most significant data.
The big endian format is used with the
Motorola family of microprocessors.
Word-Sized Data
Doubleword-sized data
Doubleword-sized data requires four bytes of memory because it is a 32-bit number.
In the 80386 through the Core2, memory and registers are also 32 bits in width.
Doubleword-sized data
Real numbers
Because many high-level languages use the Intel family of microprocessors, real numbers are
often encountered.
A real number, or a floating-point number, as it is often called, contains two parts: a mantissa,
significand, or fraction; and an exponent.
Real numbers
these steps to represent the number +12 as a real number (floating point) in IEEE 754 standard
single precision format. IEEE 754 single precision format uses 32 bits, with 1 bit for the sign, 8 bits
for the exponent, and 23 bits for the mantissa (fraction).
1. Determine the Sign Bit:
○ Since the number is positive, the sign bit will be 0.
2. Convert the Number to Binary:
○ The binary representation of 12 is 1100.
3. Normalize the Binary Number:
○ Normalization is done by expressing the number in 1.xxxxx format.
○ The binary 1100 is normalized to 1.100 (in binary) and is equivalent to 1.100 x 2^3 because we moved the decimal
point three places to the left.
4. Calculate the Exponent and Apply Bias:
○ In IEEE 754, the exponent is stored with a bias. For single precision, this bias is 127.
○ Since the actual exponent is +3 (from 1.100 x 2^3), the biased exponent is 3 + 127 = 130.
○ The binary representation of 130 is 10000010.
Real numbers
these steps to represent the number +12 as a real number (floating point) in IEEE 754 standard
single precision format. IEEE 754 single precision format uses 32 bits, with 1 bit for the sign, 8 bits
for the exponent, and 23 bits for the mantissa (fraction).
1. Determine the Mantissa:
○ The mantissa is the fractional part after normalization, which is 100 in this case (from 1.100).
○ In IEEE 754, the leading 1 (before the decimal point) is implicit and not stored. So, we only store 100.
○ This needs to be represented in 23 bits, so we pad it with zeros on the right: 10000000000000000000000.
2. Combine the Parts:
○ The final IEEE 754 representation consists of the sign bit, the 8-bit exponent, and the 23-bit mantissa.
○ Sign bit: 0
○ Exponent: 10000010
○ Mantissa: 10000000000000000000000
Therefore, the IEEE 754 single precision representation of the number +12 is:
0 10000010 10000000000000000000000
This binary sequence represents the number +12 in IEEE 754 floating-point format.
Real numbers
Single-precision numbers are 32-bit numbers, use the DD directive.
Use the define quadword(s), or DQ, directive to define 64-bit double-precision real numbers.
Optional directives for real numbers are REAL4, REAL8, and REAL10 for defining single-, double-,
and extended precision real numbers.