xor ebx,ebx
mov bh ,0x04 ;how to change that "bh" to "ebx" ,and keep  codes  same meaning?

and why people always use xor instead of mov XXX,0 ?

有帮助吗?

解决方案

xor ebx,ebx mov bh ,0x04;how to change that "bh" to "ebx" ,and keep codes same meaning?

Assuming I understand you correctly, what you want is this:

mov ebx, 0x0400

(bh is the upper 8 bits of bx, which is itself the lower 16 bits of ebx. So the value you need is the original value shifted left by 8, which we get by adding two hex 0 digits).

why people always use xor instead of mov XXX,0 ?

To put it simply: because it's shorter and faster. See What is the purpose of XORing a register with itself? and Does using xor reg, reg give advantage over mov reg, 0?

其他提示

Since bh is the second lowest byte of ebx, you can just do mov ebx, 0x0400.

xor is used because it's shorter opcode and the processors have special support to recognize it as zeroing the register. See the optimization manual, section 3.5.1.8 Clearing Registers and Dependency Breaking Idioms.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top