icedland / iced

Blazing fast and correct x86/x64 disassembler, assembler, decoder, encoder for Rust, .NET, Java, Python, Lua

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question: how to reference a variable

Nekketsu opened this issue · comments

I'd like to assemble some code like this:

puts:
...

mov si, msg_hello
call puts

msg_hello: db 'Hello world!', 0x0d, 0x0a, 0

I use some code like this, but I don't know how to reference the msg_hello variable:

var puts = asm.CreateLabel();
var msg_hello = asm.CreateLabel();

asm.Label(ref puts);
...

asm.mov(si, msg_hello); // How to do this instruction?  It's incorrect like this.
asm.call(puts);

asm.Label(ref msg_hello);
asm.db(Encoding.ASCII.GetBytes("Hello world!"));
asm.db(0x0d, 0x0a, 0);

As I explained in the comments, I don't know how to reference the msg_hello variable, and the way I wrote it is clearly incorrect.

Could you please explain me how to make the code correct and work?

Thank you.