0

I was trying to compare a variable to a register and to increment this variable, without success.

section .data
i : DB 0x0

global foo:function

foo:
cmp i, rdx
...
inc i

But Nasm is not pleased. I found a solution, storing 0x0 in a register, cmp and inc on this register. But I'm curious, and can you manipulate variable ?

thx

1 Answer 1

4

In NASM referring to variables is always done via the use of square brackets [ ].

NASM doesn't store size information about a variable. This means inc i is not enough. Here you need to code inc byte [i].

Since the variable i was defined as a byte you don't want to compare it with a qword register like RDX. You can code cmp [i],dl.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.