The following two statements for initializing the data segment register
mov AX, @Data
mov DS, AX
but the actual data segment address is known only when the loader loads the program in memory.
- What does the assembler puts in place of @data?
- When the loader gets the actual data segment base address does it replace the instruction mov AX, @data with the mov AX, Actual Base Address?
- Why it is necessary to write this statement when the actual base address is not known before the loading stage?
mov AX, @Datarequires a fixup. I believe the linker will fill @Data in with the segment relative to the beginning of the executable and mark it for fixup by the DOS loader (there is a fix up table in the header of the executable). When you run the program the DOS program loader will read the DOS header from the executable and add the segment where DOS physically loaded the program with the segment placed in the instruction by the linker. That will yield a run-time value for@Data.mov AX, @Datamov DS, AXin your code, the DS (Data segment) will not be known at runtime by the program itself. Without setting up DS you likely won't read and write variables in memory where they expect to be read and written from and your program just won't work as expected.