Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

assembly - Why doesn't MS-DOS initialize the DS and ES registers?

Why does the initialization of the DS and ES registers has to be done manually by the programmer?

For example:

MOV AX, DTSEG
MOV DS, AX

On the other hand, the CS and SS registers are initialized by the operating system (in MS-DOS). Why is this so?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Because CS and SS registers are essential for program execution in contrast to DS and ES registers which point to user-defined data segments. By default no data is present in the executing program this nothing to initialize the DS and ES with. As a program writer you can specify where your data is by setting the data segments registers.

Edit: as was correctly noted by @FrankKotler, in .com file (the entire program size doesn't exceed single segment), DS and ES are initialized and equal to CS. For other execution models, DS and ES are initialized by pointer to PSP (which isn't the pointer to real user data).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...