使用MOV指令时分配的值是多少? [英] What is the value assigned when using MOV instruction?

查看:26
本文介绍了使用MOV指令时分配的值是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你能解释一下MOV指令的两种用法有什么区别吗?

Can you explain what is the difference between the two usages of MOV instruction?

mov eax,[namedDataItem]
mov eax,namedDataItem

这里的namedDataItem是.data段中定义的命名数据项.

Here namedDataItem is a named data item defined in .data section.

推荐答案

摘自NASM 手册

规则很简单,任何对内存内容的访问location 需要在地址周围加上方括号,并且任何访问变量的地址没有.

The rule is simply that any access to the contents of a memory location requires square brackets around the address, and any access to the address of a variable doesn't.

这也意味着 NASM 不需要 MASM 的 OFFSET 关键字,因为MASM 代码 mov ax,offset bar 与 NASM 的含义完全相同mov ax,bar.

This also means that NASM has no need for MASM's OFFSET keyword, since the MASM code mov ax,offset bar means exactly the same thing as NASM's mov ax,bar.

所以,两行之间的区别是:第一行移动内容,第二行移动地址.

So, the difference between both lines is : the first one moves the CONTENT, the second moves the ADDRESS.

这篇关于使用MOV指令时分配的值是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆