访问嵌入式X86程序集中的特定位 [英] Access specific bit in embedded X86 assembly
问题描述
我正在尝试访问特定位并进行修改. 我已将0x01ABCDEF(十六进制值)移至ecx,并希望能够检查特定位置的位值. 例如我必须取0x01ABCDEF(0xEF)的字节0 检查位置7的位是否为1 将中间的4位设置为1,其余的设置为0.
I am trying to acces a specific bit and modify it. I have moved 0x01ABCDEF (hex value) into ecx and want to be able to check bit values at specific position. For example I must take byte 0 of 0x01ABCDEF (0xEF) check if bit at position 7 is 1 set the middle 4 bits to 1 and the rest to 0.
推荐答案
我完成asm已经有好几年了,但是您想使用0x80设置您的值,如果结果为零,则未设置位,因此您跳了退出,否则继续进行操作,并将eax设置为所需的值(我假设您所指的四位是第四个字节中的00111100.
It's been years since I've done asm, but you want to and your value with 0x80 and if the result is zero your bit is not set so you jump out, otherwise continue along and set your eax to the value you want (I assume the four bits you mean are the 00111100 in the fourth byte.
例如(将其作为伪代码处理,因为它已经太久了):
For example (treat this as pseudo code as it's been far too long):
and eax, 0x80
jz exit
mov eax, 0x3C
exit:
这篇关于访问嵌入式X86程序集中的特定位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!