NASM - Variable Basics

2019-09-22 08:09发布

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

标签: assembly nasm
1条回答
Anthone
2楼-- · 2019-09-22 08:46

'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

查看更多
登录 后发表回答