Something about Assembly language 2

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偏移量)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值