                               The CS Register

Code Segment


Graphical Breakdown:

      [       16 bits       ]
               CS

CS is the register that holds the segment where you code is.  When the
CPU performs an instruction fetch, it looks at CS:[IP/EIP] to get the
next instruction. In Real Mode, this register holds a segment but in 
protected mode, it is called a segment selector.

In real mode:
Segment*16 + Offset = 20 Bit Physical Address below 1 Meg.

CS Holds the segment part.  Each Segment can reference 65536 bytes, but,
they overlap.  Every Segment (In increments of 1) is 16 bytes apart.
Example:

0000h:0000h  0*16 + 0 = 00000h Physical.

Increment Segment by 1
0001h:0000h  1*16 + 0 = 00010h Physical.


So, 0000h:0000h to 0000h:0000Fh is unique and Can only be addressed by that segment. 

Where as

0000h:0010h  and 0001:0000h Are the same address.



In protected mode, you can address up to 4 Gigabytes of Memory at a time.
The "Segment Selector" selects a descriptor in a Descriptor Table.

The machine code for a CS typecast is:
2Eh

During startup of a .COM/.EXE in DOS, CS will hold the Code Segment.  In
a .COM, the first 256 bytes of the segment is the PSP.