鱼C论坛

 找回密码
 立即注册
查看: 3206|回复: 2

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

[复制链接]
发表于 2013-12-9 20:56:56 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
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。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 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

评分

参与人数 1鱼币 +3 收起 理由
yinyuepingguo + 3 热爱鱼C^_^

查看全部评分

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2013-12-10 13:05:08 | 显示全部楼层
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-9-28 15:23

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表