Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mem constructor for [base + index] #124

Closed
TACIXAT opened this issue May 12, 2024 · 2 comments · Fixed by #125
Closed

Mem constructor for [base + index] #124

TACIXAT opened this issue May 12, 2024 · 2 comments · Fixed by #125

Comments

@TACIXAT
Copy link

TACIXAT commented May 12, 2024

Should the Mem constructor that takes base and index registers have scale set to 1 instead of 0?

static constexpr Mem ptr(BitSize bitSize, const Gp& base, const Gp& index) noexcept

Succeeds:

a.mov(zasm::x86::al, zasm::x86::byte_ptr(zasm::x86::rsi, zasm::x86::rcx, 1, 0));

Fails impossible instruction:

a.mov(zasm::x86::al, zasm::x86::byte_ptr(zasm::x86::rsi, zasm::x86::rcx));

Likely cause:

    // ptr [base + index]
    // ex.: mov eax, ptr [ecx+edx]
    static constexpr Mem ptr(BitSize bitSize, const Gp& base, const Gp& index) noexcept
    {
        return Mem(bitSize, Seg{}, base, index, 0, 0);
    }
@ZehMatt
Copy link
Collaborator

ZehMatt commented May 12, 2024

I will have to look into that, I remember there was a special case about this.

ZehMatt added a commit that referenced this issue May 12, 2024
Fix #124: memory scale defaulting to 0 rather than 1 when index is supplied
@ZehMatt
Copy link
Collaborator

ZehMatt commented May 12, 2024

I've merged the change so its now 1 by default when index is supplied, thanks for the reporting the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants