我在大会 相当新的,我有一个hardtime处理负数乘法与负数组装,并导致
#include <stdio.h>
void main() {
short int mat1[] = {-1,-2, 4,5, 4,-2}; // first array
short int mat2[] = {2,0,0,0, 0,2,0,0}; // second array
int mat3[1024]; // result array
__asm {
MOV AX, mat1[0] ; mat1[0]:= -1
MOV BX, mat2[0] ; mat2[0]:= 2
; my problem is how i can do this
; mat3[0] = mat1[0] * mat2[0] ;
; (operation result -> mat3[0] = -2)
}
}
附:这是我的功课提前
新问题 感谢:
尝试一些装配操作后:
MOV AX, mat1[ECX] ; eax is 0 and mat1[ecx] is -1
但这种操作之后 怎么来ax设置为65535,而不是到-1? 如何正确乘法然后如果AX寄存器不正确? 我很迷惑如何处理2
补充我有另外一个问题。 目前我有这个代码,我移动IMUL结果到数组。
MOV WORD PTR mat3[ECX*4]+0, AX
MOV WORD PTR mat3[ECX*4]+2, DX
我的问题是我怎么可以添加IMUL结果到当前的阵列[IDX]价值?
这里mat3 [current index] = 0,操作是正确的。 但是当例如mat3 [当前索引] = -2时,我的数字与我期望得到的数目不同。
ADD WORD PTR mat3[ECX*4]+0, AX
ADD WORD PTR mat3[ECX*4]+2, DX
我感谢你在你的帮助
无需回答。我遗憾地想通了。 – whebz
另请参见[我的答案在这里有关乘以16位数字并生成32位('int')结果](http://stackoverflow.com/questions/39581293/invalid-instruction-operands-on-mov-ah -word变量和 - 使用-IMUL-ON-16-BI/39582213#39582213)。 –