Memory, Bits, Bytes, and BCD

1 / 13

# Memory, Bits, Bytes, and BCD - PowerPoint PPT Presentation

Memory, Bits, Bytes, and BCD. Memory. Part of the computer where programs and data are stored. Read and written (changed). Bit Binary digit Basic unit of memory 1 or 0 Why binary? Because we can most reliably (electronically) distinguish between 1 and 0. Byte = 8 bits

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about 'Memory, Bits, Bytes, and BCD' - quana

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

### Memory, Bits, Bytes, and BCD

Memory
• Part of the computer where programs and data are stored.
• Bit
• Binary digit
• Basic unit of memory
• 1 or 0
• Why binary? Because we can most reliably (electronically) distinguish between 1 and 0.
• Byte = 8 bits
• Smallest unit of memory that can be read or written.
Representing numbers
• Integers
• 2’s complement is most popular
• Real numbers
• Floating point
• IEEE 754 standard format is most popular
• Fixed point
• 2’s complement integers (using standard integer arithmetic)
• BCD = binary coded decimal
• All of the above are supported by IA32!
BCD = binary coded decimal

4 bit encoding of 0..9 (decimal)

base 10 base 2 BCD

0 0000 0000 same

1 0000 0001 "

2 0000 0010 "

3 0000 0011 "

4 0000 0100 "

5 0000 0101 "

6 0000 0110 "

7 0000 0111 "

8 0000 1000 "

9 0000 1001 "

10 0000 1010 0001 0000

11 0000 1011 0001 0001

12 0000 1100 0001 0010

. . .

? ? ?

BCD = binary coded decimal

4 bit encoding of 0..9 (decimal)

base 10 base 2 BCD

0 0000 0000 same

1 0000 0001 "

2 0000 0010 "

3 0000 0011 "

4 0000 0100 "

5 0000 0101 "

6 0000 0110 "

7 0000 0111 "

8 0000 1000 "

9 0000 1001 "

10 0000 1010 0001 0000

11 0000 1011 0001 0001

12 0000 1100 0001 0010

… … …

99 0110 0011 1001 1001

100 0110 0100 invalid

… … invalid

255 1111 1111 invalid

Why BCD?
• What happened when we converted 0.10 (base 10) to base 2?

0.10 x 2 = 0.20 .0

0.20 x 2 = 0.40 0

0.40 x 2 = 0.80 0

0.80 x 2 = 0.60 1

0.60 x 2 = 0.20 1

.

.

.

• Each individually addressable “cell” is an 8-bit byte containing 28 = 256 possible values (0..255).
• The number of memory cells is independent of the cell size.
• Most modern processors have at least a 32-bit address space.

232 = 4G bytes arranged 0..232-1

Integers in memory
• Each individually addressable “cell” is an 8-bit byte containing 28 = 256 possible values (0..255).
• To allow for larger values, we group bytes together.
• byte = 8 bits
• word = 16 bits
• double word = 32 bits (long word)
Byte ordering
• Consider a word consisting of 2 bytes in memory with a value of 080116 at address 10.
• It is a word (2 bytes) so it occupies memory location 10 and memory location 11.
• It can be stored in memory as either:

M[10] M[11]

08 01 - big endian (Motorola)

01 08 - little endian (IA32, VAX)

- either (switchable): IA64, ultraSparc

Endian-ness
• Extends from 4 to 8 (and 16) byte integers too.
• (Note: For integers larger than 2 bytes, other orderings are possible but they are not used.)
Endian-ness conversion
• big endian: Motorola
• little endian: IA32, VAX
• bi-endian: IA64, ultraSparc
• either/both supported
• typically switchable at boot time
Endian-ness conversion
• What happens if one sends a message (that contains multi-byte integers) from one system to another across the internet, and they have different endian-ness?
• We need a way to convert from one format to another (future topic; also see htonl Unix/Linux function).