问题描述
我知道您可以通过编写以下代码在nasm中创建一个字符串:
I know that you can create a string in nasm by writing this:
mystring db 'Hello World'
但是,如果我要移动单个字符,则说e,即字符串中的第二个字符到al寄存器.我怎样才能做到这一点?我应该写
But if I want to move a single character, let's say e, the second character in the string to the al register. How can I do that? Should I write
mov al, mystring+1
还是什么?以及如何使一个int变量?我可以写:
or something? And how do I make an int variable? Can I write:
myint db 4
推荐答案
'mystring + 1'是字符串第二个字节的地址.
'mystring + 1' is the address of the second byte of the string.
在al中存储该地址(的最低有效字节).要表明您不想存储该地址,而是要存储该地址中的字节,请编写以下代码:
stores (the least significant byte of) that address in al. To indicate that you don't want to store the address but the byte located at that address, write this:
要声明一个等于42的四字节整数,请使用:
To declare a four-bytes integer equal to say, 42, use:
这篇关于NASM-可变基础的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!