Morpheu5
Morpheu5

Reputation: 2801

Difference between `shl di` and `shl di, 1`

I tried to compile the following with NASM

shl di

which, according to this very non-sketchy source should multiply di by 2 once. However, I get an "invalid combination of opcode and operands" from NASM. After a bit of head-scratching, resolved to using

shl di, 1

which is magically OK with NASM and everything is OK with me too, except that now I am left with a question because, off the top of my head, I could have sworn that the first form was a thing, but maybe I'm misremembering things.

So, which is it?

Upvotes: 0

Views: 207

Answers (1)

Morpheu5
Morpheu5

Reputation: 2801

Apparently, NASM requires the count even if it's 1. Inspection of the generated machine code reveals that shl di and shl di, 1 indeed generate the same opcodes.

Upvotes: 2

Related Questions