I want use cmp instruction, Whether to set up the following syntax in assembly language?
example:
cmp [temp + si],[temp + si+1]
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, you can’t do (exactly) this. For almost any instruction on an Intel x86, one of the operands must be a register.
There is an exception to that:
cmpsbcompares[ds:si]to[es:di](or, in 32-bit mode,[ds:esi]to[es:edi], or in 64-bit mode, usesrsiandrdi).If you want to use
sito point to both operands, however, you’ll need to load some other register, then compare:Another possibility is to load from
[si], and incrementsi:Since this is only able to use
si, nottemp+si, you’d need to add those together before using this. This is a little shorter, but (at least theoretically) slower on most current processors. To regain the speed, you could also use the more primitive instructions:Or, since you’re using
+tempfor both instructions, you might gain a little by doing that addition ahead of time:One thing to keep in mind though: since you’re working with data in memory, this may not make any real difference in speed — if you do much with memory, the bandwidth to memory is often (usually?) the bottleneck, so optimizing execution of the instructions on the processor itself makes little difference.