Author Topic: error: division operator may only be applied to scalar values  (Read 4393 times)

Offline communism

  • New Member
  • Posts: 1
error: division operator may only be applied to scalar values
« 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;
Code: [Select]
lea eax, [ebp-ecx/2]
lea ebx, [argv-ecx/2]
and I'm getting;
Code: [Select]
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?

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2505
  • Country: us
Re: error: division operator may only be applied to scalar values
« Reply #1 on: August 15, 2015, 09:30:41 PM »
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