OFFSET assembly language operators: returns the offset data label

OFFSET operator returns the offset of the data label. This offset in bytes, it indicates the start address of the data from the reference distance data segment. As shown in the data section named variable myByte following FIG.

OFFSET assembly language operators: returns the offset data label

OFFSET example

In the following example, we will use the following three types of variables:

  .data  bVal BYTE ?  wVal WORD ?  dVal DWORD ?  dVal2 DWORD ?

In bVal assumed offset position 00404000 (hexadecimal), then the operator returns the value OFFSET follows:

  MOV ESI, OFFSET bVal; ESI = 00404000h MOV ESI, OFFSET wVal; ESI = 00404001h MOV ESI, OFFSET DVAL; ESI = 00404003h MOV ESI, OFFSET dVal2; ESI = 00404007h

OFFSET may be applied directly - offset operand. MyArray set includes five 16-bit words. The following MOV instruction offset was first myArray then add 4, and then form the resulting address is transmitted directly to the ESI. Thus, it can be said ESI points to an array in the third integer.

  .data  myArray WORD 1,2,3,4,5  .code  mov esi,OFFSET myArray + 4

The offset may also be used to initialize a variable another double word variable, effectively creating a pointer. The following example, pArray points to the starting address bigArray:

  .dat bigArray DWORD 500 DUP (?) pArray DWORD bigArray

Following the instruction value of the pointer is loaded into the ESI, therefore, the ESI can register points to the start address of the array:

  mov esi,pArray

4.1  Operand Type
4.2  MOV instructions
4.3  MOVZX to doing it and instructions MOVSX
4.4  LAHF SAHF instruction and
4.5 of 5  XCHG instructions
4.6  immediate offset operands
4.7  assembly language data transfer Example
4.8  addition and subtraction Detailed
4.9  the OFFSET operator
4.10  the ALIGN directive
4.11  the PTR operator
4.12  the TYPE operator
4.13  lengthof operator
4.14  the LABEL directive
4.15  indirect addressing
4.16  the JMP and LOOP instruction
4.17  64 MOV instruction
4.18  64-bit addition and subtraction

Guess you like

Origin blog.csdn.net/Javaxuxuexi/article/details/93401648