yinyuepingguo 发表于 2013-12-9 20:56:56

关于汇编中SIZE和LENGTH存在‘BUG’的问题

code segment
    TEST1 DB 8 DUP (0,0,0)
    start:
    mov ax,SIZE TEST1
    mov ax,Length TEST1
    mov ax,4c00H
    int 21h
code ends
    end start      SIZE OPR和LENGTH OPR不应该是分别取操作数的大小和长度吗?但是为什么这里SIZE和LENGTH都为8?个人认为应该是24。

小名明SIU 发表于 2013-12-10 13:02:29

The LENGTH and SIZE operators are allowed for compatibility with previous versions of the assembler. When applied to a data label, the LENGTH operator returns the number of elements created by the DUP operator; otherwise it returns 1. When applied to a data label, the SIZE operator returns the number of bytes allocated by the first initializer at the <variable> label.

大致意思是length是返回由DUP创建的单元个数   对于其他的返回1   SIZE是length和type的乘积,type是创建单元的类型的字节数

你的dup创建了8个单元的(0,0,0),所以length是8    db是一个字节所以size = length * type=8

yinyuepingguo 发表于 2013-12-10 13:05:08

小名明SIU 发表于 2013-12-10 13:02 static/image/common/back.gif
The LENGTH and SIZE operators are allowed for compatibility with previous versions of the assembler. ...

了解了。谢谢{:1_1:}
页: [1]
查看完整版本: 关于汇编中SIZE和LENGTH存在‘BUG’的问题