Wang Shuang "assembly language" the third edition of the sixth chapter contains a number of paragraphs of the program

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.