我在大會 相當新的,我有一個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)。 –