Answer the question
In order to leave comments, you need to log in
Question about segment registers and DS register loading process?
In assembler textbooks, you can see the following code for the exe program
.Data
name db 'name'
.Code
mov ax,@Data
mov ds,ax
ret
etc ......
I can not understand where the value of this register (DS) comes from can know where her data will be in order to indicate this value herself?
Answer the question
In order to leave comments, you need to log in
how can the program know where its data will be in order to indicate this value itself?
As they say, according to the principles of von Neumann, the program and data are not indistinguishable from each other. Accordingly, starting your program comes down to the fact that the launching program sets the code segment pointer to the beginning of your code. And then your program should spin as it can.
You write the program, then the compiler compiles it (yes, it doesn't sound very good). The compiler introduced such a simplification that you can specify the address of the data segment with the "@Data" construct. In a compiled program, this will be a constant, i.e. during compilation, the compiler itself will determine and substitute this constant.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question