NASM - Variable Basics

独自空忆成欢 提交于 2019-12-13 09:25:10

问题


I know that you can create a string in nasm by writing this:

mystring db 'Hello World'

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

or something? And how do I make an int variable? Can I write:

myint db 4

回答1:


'mystring + 1' is the address of the second byte of the string.

mov al, mystring + 1

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:

mov al, [mystring + 1]

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

myint dd 42



来源:https://stackoverflow.com/questions/30082772/nasm-variable-basics

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!