Information
Information
html
Part A - Introduction
Information
Define the units for building local variables and constants
The information stored in RAM includes both program instructions and the data used or produced by those instructions. This
information is stored in bits, bytes and words. The two most common numbering systems for representing information stored in
RAM are the binary and hexadecimal numbering systems.
This chapter defines these units, reviews the numbering systems and describes the method of addressing RAM.
UNITS
Bits
The most fundamental unit of modern computers is the binary digit or bit. A bit is either on or off. One represents on, while
zero represents off.
Because bits are too numerous to handle individually, we adopt larger units and define those units as groups of bits.
Bytes
The fundamental addressable unit of RAM is the byte. One byte consists of 2 nibbles. Each nibble consists of 4 bits
Byte
Nibble Nibble
Bit Bit Bit Bit Bit Bit Bit Bit
In one byte, we can store any one of 256 (28) possible values:
00000000 <- 0
00000001 <- 1
00000010 <- 2
00000011 <- 3
00000100 <- 4
...
00111000 <- 56
...
11111111 <- 255
The binary values are on the left. The equivalent decimal values are on the right. Note that our counting system starts from 0,
not from 1.
1 of 3 2/3/2016 7:14 PM
The C Programming Language | ICT - Seneca https://scs.senecac.on.ca/~btp100/pages/content/compu_p.html
Words
We call the natural size of the execution environment a word. A word consists of an integral number of bytes and is typically the
size of the CPU's general registers. Word size may vary from machine to machine. On a 16-bit machine, a word consists of 2
bytes. On a Pentium 4 machine, the general registers contain 32 bits and a word consists of 4 bytes. On an Itanium 2 machine,
the general registers contain 64 bits, but a word still consists of 4 bytes.
Hexadecimal
The most convenient numbering system for representing information is the hexadecimal system (base 16). Two hexadecimal
digits holds the information stored in one byte. Each digit holds 4 bits of information. The digit symbols in the hexadecimal
number system are {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F}. The characters A through F denote the decimal values 10
through 15 respectively. We use the 0x prefix to identify a number as hexadecimal (rather than decimal - base 10).
For example, the hexadecimal value 0x5C is equivalent to the 8-bit value 010111002.
To learn how to convert between hexadecimal and binary refer to the chapter entitled Data Conversions in the Appendices.
ADDRESSES
Each byte of RAM has a unique address. A linear map provides a simple method of addressing any byte in RAM. Addressing
starts at zero, is sequential, and ends at the address equal to the size of RAM less 1.
consists of 32 (= 4 * 8) Gigabits
has a low address of 0x00000000
has a high address of 0xFFFFFFFF
Hex: 1 Nibble 1 Nibble 1 Nibble 1 Nibble 1 Nibble 1 Nibble ... 1 Nibble 1 Nibble
Contents: ...
Hex: 0x00000000 0x00000001 0x00000002 ... 0xFFFFFFFF
Note that each byte, and not each bit, has its own address. We say that RAM is byte-addressable.
Abbreviations
2 of 3 2/3/2016 7:14 PM
The C Programming Language | ICT - Seneca https://scs.senecac.on.ca/~btp100/pages/content/compu_p.html
Note that the multiplying factor is 1024, not 1000. 1024 bytes is 210 bytes, which is approximately 103 bytes.
Limit on Addressability
The maximum size of addressable RAM depends on the size of the address registers in the CPU. The highest address that is
accessible is the largest address that an address register can hold:
On Pentium machines where the address registers hold 32 bits, the maximum size of addressable memory is 4 GB
(Gigabytes) (addresses can range from 0 to 232-1, that is 0 to 4,294,967,295).
On Pentium machines where the address registers hold 36 bits, the maximum size of addressable memory is 64 GB
(Gigabytes) (addresses can range from 0 to 236-1, that is 0 to 68,719,476,735).
On Itanium 2 machines the address registers hold 64 bits and the maximum size of addressable memory is 16 EB
(Exabytes) (addresses can range from 0 to 264-1, that is 0 to 18,446,744,073,709,551,615).
Segmented Memory
The segmented memory model is a logical technique for managing the addresses of large numbers of bytes. This model
distinguishes segments of memory by their contents. With segmented memory, program instructions reside in one dedicated
segment, global data in another segment and local program data in yet another segment.
Segmentation provides a layer of protection. If a program instruction attempts to change information in the CS segment or to
execute information in the DS or SS segment, the CPU reports a segmentation fault and terminates execution.
In a segmented memory model, an address consists of two parts. We express it in segment:offset notation
0100:006A
To obtain the physical address multiply the segment value by 0x10 and add the offset value to the result. For example, the
physical address of 0100:006A is 0x0100 * 0x10 + 0x006A = 0x0106A.
EXERCISES
Complete the exercises in Terminology
Read Wikipedia on Segmentation Faults
3 of 3 2/3/2016 7:14 PM