NASM-可变基础 [英] NASM - Variable Basics

查看:75
本文介绍了NASM-可变基础的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道您可以通过编写以下代码在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.

mov al,mystring + 1

mov al, mystring + 1

在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:

其他,[mystring + 1]

mov al, [mystring + 1]

要声明一个等于42的四字节整数,请使用:

To declare a four-bytes integer equal to say, 42, use:

myint dd 42

myint dd 42

这篇关于NASM-可变基础的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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