You are on page 1of 3

Data Representation Binary Numbers

• Binary Numbers
• Translating between binary and decimal • Digits are 1 and 0
• Binary Addition • 1 = true
• Integer Storage Sizes • 0 = false
• Hexadecimal Integers • MSB – most significant bit
• Translating between decimal and hexadecimal • LSB – least significant bit
• Hexadecimal subtraction
MSB LSB
• Signed Integers • Bit numbering: 1011001010011100
• Binary subtraction 15 0

• Character Storage

Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. 21 Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. 22

Binary Numbers Translating Binary to Decimal

• Each digit (bit) is either 1 or 0 1 1 1 1 1 1 1 1 Weighted positional notation shows how to calculate the
• Each bit represents a power of 2: 27 26 25 24 23 22 21 20 decimal value of each binary bit:
dec = (Dn-1  2n-1) + (Dn-2  2n-2) + ... + (D1  21) + (D0  20)
D = binary digit

Every binary
number is a
sum of powers
of 2

binary 00001001 = decimal 9:


(1  23) + (1  20) = 9
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. 23 Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. 24

Translating Unsigned Decimal to Binary Exercises


• Repeatedly divide the decimal integer by 2. Each
remainder is a binary digit in the translated value:

37.6875 = 100101.1011
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. 25 Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. 26

1
Binary Addition Integer Storage Sizes
• Starting with the LSB, add each pair of digits, include
byte 8

Standard sizes:
the carry if present.
word 16
doubleword 32
quadword 64

carry: 1

0 0 0 0 0 1 0 0 (4)

+ 0 0 0 0 0 1 1 1 (7)

0 0 0 0 1 0 1 1 (11)
bit position: 7 6 5 4 3 2 1 0

What is the largest unsigned integer that may be stored in 20 bits?

Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. 27 Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. 28

Hexadecimal Integers Translating Binary to Hexadecimal


Binary values are represented in hexadecimal.
• Each hexadecimal digit corresponds to 4 binary bits.
• Example: Translate the binary integer
000101101010011110010100 to hexadecimal:

Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. 29 Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. 30

Converting Hexadecimal to Decimal Powers of 16

• Multiply each digit by its corresponding power of 16: Used when calculating hexadecimal values up to 8 digits
dec = (D3  163) + (D2  162) + (D1  161) + (D0  160) long:

• Hex 1234 equals (1  163) + (2  162) + (3  161) + (4  160), or


decimal 4,660.

• Hex 3BA4 equals (3  163) + (11 * 162) + (10  161) + (4  160), or


decimal 15,268.

Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. 31 Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. 32

2
Converting Decimal to Hexadecimal Convert Decimal Fraction to Octal Fraction

decimal 422 = 1A6 hexadecimal

Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. 33 Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. 34

You might also like