Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: how to reference a variable #447

Open
Nekketsu opened this issue Aug 27, 2023 · 1 comment
Open

Question: how to reference a variable #447

Nekketsu opened this issue Aug 27, 2023 · 1 comment

Comments

@Nekketsu
Copy link

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.

@Misha1302
Copy link

perhaps the lea instruction will help you?

asm.lea(si, __[msg_hello]);

here is a usage example: Program.txt
(for windows, C#, in line 20)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants