UMBC CMSC 211

UMBC | CSEE


Segment Registers

The address that is in an instruction is actually the offset part of the address. Whether it is OFFSET label or just label in the source code, it is stored as the offset in the instruction in memory.

The actual registers are:

bp. Used implicitly in push, pop, and call and ret instructions for the return address.
Register Namefor addesses in...
cs Code Segment call and jmp instructions and instruction fetches (using ip)
ds Data Segment all other instructions.
es Extra Segment when an extra segment register is needed.
The operations on segment registers is extremely limited: Notice this meanings that: The default segment can be overridden by preceding the insturction by a segment override byte. The assembler will usually supply the override for you, but occasionally you must use an explicit segment override: mov WORD PTR es:[bx + 8 ], 100

You can call a procedure that is in a different segment. This is known as a far call and both the original cs and ip pushed and popped. There are also far jumps possible.

When DOS loads a program, it gets the initial values of ss:sp and cs:ip from a short header record in the .EXE file. The stack starts at the first paragraph after the code and data segments and its size is the sum of all the values in the .STACK directives (which is what is loaded into the sp). The ip is loaded with the offset of the label that you provided in END Label directives in one of the source code files.


UMBC | CSEE