Download presentation
Presentation is loading. Please wait.
Published byErnest Greene Modified over 8 years ago
1
Memory, Bits, & Bytes
2
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 – Smallest unit of memory that can be read or written.
3
Memory addresses Each individually addressable “cell” is an 8-bit byte containing 2 8 = 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. 2 32 = 4G bytes arranged 0..2 32 -1
4
Representing strings Each byte will contain the ASCII value of a character.
5
Representing strings So “hello” is the sequence of bytes: 104 101 108 108 111 But how do we determine the end of the string? 104 101 108 108 111 0 – This method is also employed by C. – Other methods are possible.
6
Integers in memory Each individually addressable “cell” is an 8-bit byte containing 2 8 = 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) – quadword= 64 bits
7
Byte ordering Consider a word consisting of 2 bytes in memory with a value of 0801 16 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] 0801- big endian (Motorola) 0108- little endian (IA32, VAX) - either (switchable): IA64, ultraSparc
8
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.)
9
Endian-ness conversion 1.big endian: Motorola 2.little endian: IA32, VAX 3.bi-endian: IA64, ultraSparc – either/both supported – typically switchable at boot time
10
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).
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.