Intel assembly language programming (fifth edition)-Part 1

Source: Internet
Author: User
Tags array definition

Learning in progress

-- Data-related operators and pseudo commands:

(1) The offset operator returns the offset address of the data label. Offset indicates the distance from the label to the data segment. Unit: bytes.

(2) The align directive align the positions of variables in byte, word, double word or segment boundary, align boundary values (1, 2, 4, 16) such:

Bval byte? 00404000

Align 2

Wval word? 00404002

The CPU processes the data stored in an even address faster than the data stored in an odd address.

(3) The default size declared by the reload operand of the PTR operator. MoV ax word PTR mydouble

(4) The type operator returns the size of a single element of the variable calculated in bytes.

(5) the lengthof operator calculates the number of elements in the array. The elements are defined by the values that appear in the same row. When the nested DUP definition is used in the array definition, lengthof returns the product of two counters.

Array word 5 DUP (3 DUP (?))

Lengthof array; 5*3

(6) the return value of the sizeof operator is the product of the return values of lengthof and type.

(7) The label directive allows you to insert a label and assign it a size attribute without allocating any actual storage space. A common usage is to provide an alias and a different size attribute for the variable defined later in the data segment. For example

. Data

Val16 lable word

Val32 DWORD 12345678 H

. Code

MoV ax, val16; AX = 5678 H

MoV dx, [val16 + 2]; AX = 1234 H

Val16 is an alias for the storage address named val32.

-- Indirect addressing: use registers as pointers and operate the values of registers. Description operand: When the operand uses indirect addressing.

Protection Mode: Any 32-bit General registers (eax, EBX, ECx, EDX, ESI, EDI, EBP, and ESP) enclosed in square brackets for indirect operands ), the register contains the data offset.

Real address mode: use 16-bit registers to store the offset address of the variable. Only the Si, Di, BX, and BP registers can be used. Avoid using BP as much as possible, because BP is often used to address stacks rather than data segments.

General protection fault GP: In protection mode, if the valid address points to a region outside the program data segment, the CPU may generate GP. MoV ax, [esi] ESI is not the first time. GP is not generated in real address mode.

-- Inc byte PTR [esi]; specifies the size of the operand

INC [esi]; Error

-- The address change operand combines constants and registers to get a valid address. Any 32-bit general-purpose register can be used as the address change register.

Constant [Reg]

[Constant + Reg]

MoV ESI, 3; subscript

MoV eax, array [ESI * type array]; Use the type Operator

-- Pointer: a variable containing other variable addresses is called a pointer variable or pointer. It is very useful to manipulate arrays and data structures. ptr dword array or ptr dword offset Array

-- The typdef operator allows you to create user-defined types.

Pbyte typedef PTR byte; Create pointer to byte

PTR pbyte array; point to array

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.