1
私は今、自分のコンピュータ構成コースのアセンブリでプログラミングを開始しましたが、このasm
ブロックをCプログラム内でコンパイルしようとすると、いつもエラーoperand size conflict
が発生します。オペランドサイズがx86アセンブリで競合する
オブジェクトは文字配列なので、各要素が1バイトであるべきではありませんか?私がmov eax, arrayOfLetters[1]
を実行するとコードが動作しますが、理由はわかりません。eax
レジスタは4バイトです。
#include <stdio.h>
#define SIZE 3
char findMinLetter(char arrayOfLetters[], int arraySize)
{
char min;
__asm{
push eax
push ebx
push ecx
push edx
mov dl, 0x7f // initialize DL
mov al, arrayOfLetters[1] //Problem occurs here
mov min, dl // read DL
pop edx
pop ecx
pop ebx
pop eax
}
return min;
}
int main()
{
char arrayOfLetters[ SIZE ] = {'a','B','c'};
int i;
printf("\nThe original array of letters is:\n\n");
for(i=0; i<SIZE; i++){
printf("%c ", arrayOfLetters[i]);
}
printf("\n\n");
printf("The smallest (potentially capitalized) letter is: %c\n", findMinLetter(arrayOfLetters, SIZE));
return 0;
}
周囲のCコードを表示できますか? – DCoder
@DCoder質問に感謝しました。 –
'mov 'を使うと、ワードをデスティネーションレジスタに移動しますが、' al'の幅は1バイトだけです。あなたはIMOの代わりに 'movb'を使うべきです。申し訳ありませんがあなたのコードをデバッグすることはできません私は手元にインテルスタイルのアセンブラを持っていません。ところで、あなたは 'mov al、arrayOfLetters [1]'が動作する、あるいはちょうどコンパイルできるという意味ですか? –