http://www.emu8086.com/assembler_tutorial/asm_tutorial_02.html
指定偏移量数据类型的前缀:
字节:byte ptr(或b.)
字(两字节):word ptr(或w.)
例:
byte ptr [BX] ;字节存取
word ptr [BX] ;字存取
某些情况下,汇编程序可以自动计算数据类型
-------------------------------------------------------------
in order to say the compiler about data type,
these prefixes should be used:
byte ptr - for byte.
word ptr - for word (two bytes).
for example:
byte ptr [BX] ; byte access.
or
word ptr [BX] ; word access.
assembler supports shorter prefixes as well:
b. - for byte ptr
w. - for word ptr
in certain cases the assembler can calculate the data type automatically.
-------------------------------------------------------------------------------------------
获取变量地址:
方法:
LEA (Load Effective Address),更好,因为还能获取下表变量(an indexed variable)地址;
OFFSET (alternative)。
用途:
如向某一个过程传递参数时。
举例:
例一(LEA):
ORG 100h MOV AL, VAR1 ; check value of VAR1 by moving it to AL. LEA BX, VAR1 ; get address of VAR1 in BX. MOV BYTE PTR [BX], 44h ; modify the contents of VAR1. MOV AL, VAR1 ; check value of VAR1 by moving it to AL. RET VAR1 DB 22h END
例二(OFFSET):
ORG 100h
MOV AL, VAR1 ; check value of VAR1 by moving it to AL.
MOV BX, OFFSET VAR1 ; get address of VAR1 in BX.
MOV BYTE PTR [BX], 44h ; modify the contents of VAR1.
MOV AL, VAR1 ; check value of VAR1 by moving it to AL.
RET
VAR1 DB 22h
END
注意:
LEA BX, VAR1
MOV BX, OFFSET VAR1
被编译成相同的机器语言:MOV BX,num(num是16位的var1偏移量)