unlimitedcoding
unlimitedcoding

Reputation: 31

when can I use * in assembly language?

with this data

.data
tableD DWORD 10h, 20h, 30h, 40h, 50h, 60h
Rowsize = ($ - tableD)
DWORD 60h,70h,80h,90h,0A0h
DWORD 0B0h,0C0h,0D0h,0E0h,0F0h

I can use

.code
mov eax,tableD[ebx + esi*TYPE tableD]

but I can't use

mov eax,tableD[ebx*2 + esi*TYPE tableD]

but I can use

mov eax,tableD[ebx*2 + esi]

can't I use 2 *s in there?

can I know the terms for those objects?

Upvotes: 3

Views: 167

Answers (1)

fuz
fuz

Reputation: 93172

The x86 architecture supports a four-part addressing mode of the following form:

base + index * scale + displacement

where all four parts can be absent (scale is 1 if absent). This means that there can be only one scaled component in a memory operand; so yes, you can only use one *.

Furthermore, scaling factors are limited to 1, 2, 4, or 8; other scaling factors cannot be encoded.

Upvotes: 6

Related Questions