コメント内の式のアセンブリ言語コードを記述しようとしています。配列へのポインターが 64 ビット レジスターであり、最終結果を 32 ビット レジスターに格納する必要があるため、問題が発生しています。そのため、レジスターのしくみに関する基本的な理解が明らかに不足しています。試みた解決策を含めましたが、1 つの引数が 64 ビット レジスタで、もう 1 つの引数が 32 ビットである movl または subl を使用しようとすると、エラーが発生します。また、私の推論が正しいかどうかも定かではありません。どんな助けでも大歓迎です。
# WRITEME: At this point, %r12 and %rbx are each pointers to two arrays
# of 3 ints apiece, a0 and a1. Your job is to write assembly language code
# in the space below that evaluates the following expression, putting the
# result in register %esi (the 32 bit form of register %rsi):
#
# (a1[0]-a0[0]) * (a1[0]-a0[0]) +
# (a1[1]-a0[1]) * (a1[1]-a0[1]) +
# (a1[2]-a0[2]) * (a1[2]-a0[2])
#
#
# It is possible to do this using 11 instructions. You need to use extra
# registers, of course. Since you are not calling any functions, you have a
# lot of choices. %r12 and %rbx are already occupied, but you could use
# %r13d through %r15d (32 bit forms of %r13 through r15) safely, and also
# %eax, %ecx, %edx and of course %esi, since that is where the result will
# be stored.
###########
# Your code here
movl $0, %esi
movl %rbx, %eax #errors here
subl %r12, %eax #and here
imull %eax, %eax
movl 4(%rbx), %ecx
subl 4(%r12), %ecx
imull %ecx, %ecx
movl 8(%rbx), %edx
subl 8(%r12), %edx
imull %edx, %edx
movl %eax, %esi
addl %ecx, %esi
addl %edx, %esi