Q. What is CODE SEGMENT?
The logical program segment is termed as code segment. When linker links a program it makes a note in header section of program's executable file defining the location of code segment when DOS invokes the loader to load an executable file in memory then loader reads that note. As it loads the program in memory loader also makes notes to itself of exactly where in memory it essentially places every one of the program's other logical segments. As loader hands execution over to program it has just loaded it sets CS register to address the base of segment identified by linker as code segment. This reduces each instruction in code segment addressable in segment relative terms in form CS: xxxx.
Linker also presumes by default that first instruction in code segment is aimed to be first instruction to be executed. That instruction shall appear in memory at an offset of 0000H from base of code segment so linker passes that value on to loader by leaving an another note in header of program's executable file. Loader sets IP (Instruction Pointer) register to that value. This sets CS:IP to segment relative address of first instruction in program.