计算像“$-label"这样的字符串长度时,x86 汇编中的美元符号 ($) 是什么意思? [英] What does the dollar sign ($) mean in x86 assembly when calculating string lengths like "$ - label"?

查看:17
本文介绍了计算像“$-label"这样的字符串长度时,x86 汇编中的美元符号 ($) 是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,如果我们正在编写一个简单的 hello world 类型的程序,.data 部分可能包含如下内容:

For example, if we were writing a simple hello world type program, the .data section might contain something like:

section .data

msg     db      'Enter something: '
len     equ     $ - msg

这个例子中的 $ 代表什么,为什么 $ - msg 等于字符串的长度?

What does the $ in this example represent, and why does $ - msg equal the length of the string?

推荐答案

在这种情况下,$ 表示根据汇编程序的当前地址.$ - msg 是汇编器的当前地址减去 msg 的地址,即字符串的长度.

In this case, the $ means the current address according to the assembler. $ - msg is the current address of the assembler minus the address of msg, which would be the length of the string.

这篇关于计算像“$-label"这样的字符串长度时,x86 汇编中的美元符号 ($) 是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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