#### paml27

• Jr. Member
• Posts: 36
« on: October 28, 2022, 03:01:46 PM »
Hello,

vmovsd xmm0,[rdi+0+r9*24] – why is this an invalid effective address

vmovsd xmm1,[rdi+0+r9*8] – and this is a valid effective address?

Thanks,

Pam

#### Frank Kotler

• NASM Developer
• Hero Member
• Posts: 2601
• Country:
« Reply #1 on: October 28, 2022, 03:22:31 PM »
Hi pam127,

I am not sure. It looks to me like the "* 24" might be the problem. 2, 4, 8... 16? and 32? maybe? I'm not sure what to do about it if 24 is what you want.

Best,
Frank

#### paml27

• Jr. Member
• Posts: 36
« Reply #2 on: October 28, 2022, 03:43:23 PM »
Hi, Frank,

When I come back from my meeting I am going to try vmovsd xmm0,[rdi+0+r9*16*3+8*3] and I'll let you know what happens.

Pam

#### fredericopissarra

• Full Member
• Posts: 228
• Country:
« Reply #3 on: October 28, 2022, 04:29:59 PM »
If the instruction has a SIB field (scale, index, base), then there is only 2 bits for the scale. So, it is 1, 2, 4 or 8, no more.

The easiest way to do [rdi+r9*48+24] is:
Code: [Select]
`mov    rax,r9mov    rdx,r9  ; if you want to preserve r9.shl    rax,5   ; rax = r9 * 32shl    rdx,4   ; rdx = r9 * 16add    rax,rdx ; rax = (32 + 16)*r9movsd  xmm0,[rdi+rax+24]`
« Last Edit: October 28, 2022, 04:45:54 PM by fredericopissarra »

#### paml27

• Jr. Member
• Posts: 36
« Reply #4 on: October 28, 2022, 06:08:53 PM »
I've tried various combinations, but Frederico's method is the only way to do it for what I need.

Thanks to both of you.

#### fredericopissarra

• Full Member
• Posts: 228
• Country:
`  mov eax,[rbx*3]  mov eax,[rbx*5]  mov eax,[rbx*9]`As shortcuts to:
`  mov eax,[rbx+rbx*2]  mov eax,[rbx+rbx*4]  mov eax,[rbx+rbx*8]`Notice that "scales" don't allow the full SIB, as in
`mov eax,[rbx+rdx*3] ; invalid!`"Scales" as 6, 7 or greater than 9 aren't possible because the calculation is base+index*scale. Subtracting (base-index*scale) isn't possible, due to cannonincal addresing.