NASM - The Netwide Assembler
NASM Forum => Programming with NASM => Topic started by: communism on August 15, 2015, 06:06:55 PM
-
I have two lines of code in my program that don't get along with NASM very well;
lea eax, [ebp-ecx/2]
lea ebx, [argv-ecx/2]
and I'm getting;
program.asm:56: error: division operator may only be applied to scalar values
program.asm:57: error: division operator may only be applied to scalar values
when trying to compile. I thought that regular arithmetic would be kosher... apparently not.
Any suggestions?
-
Use instructions that exist.
An effective address can consist of an (optional) displacement plus an (optional) base register plus an (optional) index register multiplied by a scale of 1, 2, 4, or 8. A scale factor of 1/2 is not available. (if it were, would it address a half byte?) The minus sign isn't going to work, either.
Usually when Nasm complains about not having a "scalar value", it means you've tried to do arithmetic on a label - a "relocatable value". The difference between two labels is a "scalar value" and you can do it, but that won't help you here.
Best,
Frank