6.1 Using data in a code snippet
The meaning of "DW" is to define the font data. DW is define word.
Because they are in the code snippet, when the program is running, CS holds the segment address of the snippet, so we can get their segment address from CS.
Since the data defined with DW is at the beginning of the code snippet, the offset address is 0, and the 8 data is at offset 0, 2, 4, 6, 8, A, C, and E of the code snippet.
End can also tell the compiler where the program's entry is in addition to the end of the compiler program.
6.2 Using stacks in code snippets
6.3 Put data, code, stacks into different segments
We define multiple segments in the same way as we define code snippets, then define the required data in these segments, or get the stack space by defining the data.
We want to send it into BX, we need to use the following code:
MOV Ax,data
MOV Ds,ax
MOV bx,ds:[6]
We cannot use the following command:
MOV Ds,data
MOV ax,ds:[6]
A reference to the segment name in the program, such as "data" in the instruction "MOV ds,data", will be processed by the compiler as a numeric value representing the segment address.
"Code Snippet", "Data segment", "Stack segment" are all our arrangements.
"Assume Cs:code,ds:data,ss:stack" connects Cs, DS, and SS to code, data, and stack segments respectively.
The CPU exactly how to deal with the content of our defined segments, is as instruction execution, as data access, or as a stack of space, entirely by the program of specific assembly instructions, and assembly instructions to Cs:ip, SS:SP, DS and other registers set to determine.
Reference: "Small Turtle Collection 0 Basic Primer"
The third edition of Assembly language
Wang Shuang "assembly language" the third edition of the sixth chapter contains a number of paragraphs of the program