Dword ptr commands

Source: Internet
Author: User
DWORD dual is the abbreviation of Four-byte PTR pointer, that is, the data in Pointer [] is an address value, which points to a dual-type data such as mov eax, dword ptr [12345678] assigns the dual-font (32-bit) data in memory address 12345678 to eax
Agree

. 5 How long is the data to be processed by the command?
CPU commands can process data in two dimensions: byte (8 bits) and word (16 bits ). Therefore, in the machine commands, specify whether the commands perform word or byte operations. The assembly language uses the following methods to solve this problem.
(1) specify the size of the data to be processed using the register name.
For example:
In the following command, the Register indicates that the Command performs a word operation:
MoV ax, 1
MoV BX, DS: [0]
MoV ds, ax
MoV DS: [0], ax
INC ax
Add ax, 1000

In the following commands, the registers indicate that the commands perform byte operations:
mov Al, 1
mov Al, BL
mov Al, DS: [0]
mov DS: [0], Al
Inc Al
Add Al, 100
(2) if no register name exists, use the x ptr operator to specify the length of the memory unit. X can be word or byte in assembly instructions.
For example:
In the following command, the memory unit accessed by the command is indicated by the word PTR:
mov word ptr ds: [0], 1
Inc word PTR [BX]
Inc word ptr ds: [0]
Add word PTR [BX], 2
In the following command, the Byte PTR indicates that the memory unit for instruction access is a unit:
mov byte ptr ds: [0], 1
Inc byte PTR [BX]
Inc byte ptr ds: [0]
Add byte PTR [BX], 2
it is necessary to explicitly specify the length of the memory unit to be accessed using word PRT or byte PTR in memory unit access instructions without register involvement. Otherwise, the CPU cannot know the unit to be accessed, or the byte unit. If we use DEBUG to view the memory result as follows:
: 1000 FF ......
instructions:
mov ax, 2000 h
mov ds, ax
mov byte PTR [1000 h], 1
change the content in the memory to:
: 1000 01 FF ......
commands:
mov ax, 2000 h
mov ds, ax
mov word PTR [1000 h], 1
change the content in the memory to:
: 1000 01 00 FF ......
This is because mov byte PTR [1000 h]. 1 accesses the byte unit with the address DS: 1000 h and modifies the content of the DS: 1000 h unit; moV word PTR [1000 h], 1 accesses the word unit with the address DS: 1000 h. The content is changed to DS: 1000 h and DS: 1001 H.

(3) Other methods
By default, some commands access the word unit or byte unit. For example, if you push [1000 h], you do not need to specify whether the accessed word unit or byte unit, because the push command only performs word operations.

This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/GaryZhang29/archive/2008/05/13/2439504.aspx

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.