Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In 64-bit ASM. Is there a nice way of NOTing only the bottom 32-bits of a register

Tags:

x86

assembly

Assuming we have some value in RAX. We wish to NOT the lower 32-bits of RAX, and leave the upper 32 bits unchanged. Is there a nice way of doing this?

A command like:

not eax

Unfortunately zero extends.

I can do it as follows:

mov rbx,rax
not ebx ; or not rbx
and rax, 0xffffffff00000000
or rax, rbx

but it feels like there should be a nicer way.

like image 859
tinyhippo Avatar asked Mar 15 '23 02:03

tinyhippo


1 Answers

You could XOR it with 0x00000000ffffffff, that would flip the bottom 32 bits.

like image 164
Vatine Avatar answered Apr 06 '23 23:04

Vatine