2012-03-25 55 views
0

有人可以告訴我如何比較ASM x64中的兩個參數(RDIRSI)嗎?比較兩個參數ASM x64

我對編譯一個問題,當我使用:

cmp byte[rdi+rax],byte[rsi+rax] 

我得到一個錯誤:

"error: invalid combination of opcode and operands" 
+2

您不能有兩個內存操作數。先將一個加載到一個寄存器中。 – harold 2012-03-25 17:08:19

+0

好的,謝謝。像那樣 :? MOV RCX,RDI CMP字節[RDI + RAX],字節[RCX + RAX] 我有一個錯誤太.. :( – Zat42 2012-03-25 17:13:10

+1

喜歡的是:'MOV CL,字節[RDI + RAX]; CMP CL ,字節[rsi + rax]' – 2012-03-25 17:32:21

回答

4

cmp指令,像大多數的x86/x86-64的指令,允許最多隻有一個內存操作數。因此,要比較兩個內存位置的內容,需要將其中至少一個加載到一個寄存器中:

mov cl, byte[rdi+rax] 
cmp cl, byte[rsi+rax]