Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
CSeg, DSeg, SSeg, and SPtr Functions
◄Summary► ◄Details► ◄Example► ◄Back►
Return
Word Address value stored in CS, DS, SS, or SP register
Description
The CSeg, DSeg, SSeg, and SPtr functions return the current value
from the segment registers CS, DS, and SS, and stack-pointer
register SP, respectively. The functions require no arguments.
The values returned are addresses of type word.
The CS register holds the 16-bit base address of the current code
segment. The code segment stores the main program and procedures
and functions. Because a program and its units occupy separate
segments, this value may vary throughout the execution of the
program. The value returned by CSeg depends on the part of the
code which made the call to CSeg.
The DS register holds the 16-bit base address of the data segment.
The data segment stores program and unit global variables. Because
a program has only one data segment, this value remains the same
throughout the execution of the program.
The SS register holds the 16-bit base address of the stack. The
stack stores local variables and information for procedure or
function calls. This segment value remains the same throughout the
execution of the program.
The SP register holds the current processor stack pointer, a 16-bit
offset address pointing to the top of the stack. The stack stores
local variables and procedure or function call information. The
stack grows downward, meaning that the offset held in SP decreases
as stack space is used.