gpt4 book ai didi

SHL eax、ecx 的程序集 x86 错误

转载 作者:行者123 更新时间:2023-12-02 07:19:54 25 4
gpt4 key购买 nike

我在 Assembly x86 类的代码中遇到这个编译错误,

A2070: invalid instruction operands

这条线是

shl eax, ecx

ecx 应该是循环的(减 1)并且此时永远不会大于 5,那么为什么我不能移动值呢?我需要将 eax 中的值乘以 2^n,n 是 ecx 中的值,左移。

createArray PROC   
;saving 5 multiples of the value currently in eax into an array addres that
is ;on the stack
push ecx
push eax
push esi
push ebp
mov ebp, esp
mov ecx, 5
mov esi, [ebp+24] ;address of array
L1:
call multiply ;call multiply with two numbers eax, ecx
pop eax
mov [esi],eax
add esi, 4

Loop L1
....cont
createArray endp

multiply PROC
shl eax, ecx ; this line right here
push eax
multiply endp

如果我替换

shl eax, 5

然后就可以了 我只是不知道为什么 ecx 不工作。

最佳答案

移位指令don't accept a 32-bit register as their count operand .

您需要在 cl 中使用低位:

shl eax, cl

关于SHL eax、ecx 的程序集 x86 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49313418/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com