unicorn-engine / unicorn

Unicorn CPU emulator framework (ARM, AArch64, M68K, Mips, Sparc, PowerPC, RiscV, S390x, TriCore, X86)
http://www.unicorn-engine.org
GNU General Public License v2.0
7.34k stars 1.31k forks source link

BUGS - bit shift instructions `RCL`, `RCR`, `ROL`, `ROR`, `SAL`, `SAR`, `SHL`, `SHR` compute incorrect results #1855

Closed basavesh closed 11 months ago

basavesh commented 11 months ago

For example: Before Executing:

RSI: 0xdc40db8452b6cdfb

ATT Instruction: rclq $40, %rsi

After Executing:

RSI: 0xdc40db8452b6cdfb                   <--- wrong

Expected result:

RSI: 0xb6cdfb6e206dc229

@wtdcode

basavesh commented 11 months ago

ROR Example: Before:

0x6bafdf5779332264

ATT instr

rorq $31, %r11

UC After:

0xefabbc99913235d7

Expected:

0xf26644c8d75fbeae
basavesh commented 11 months ago

Looks like more of a keystone error than Unicorn Error. Closing this issue.

basavesh commented 11 months ago

The problem was with keystone's default radix being 16 and not 10. My x86_64 hardware's default radix is 10. This is a very strange deviation for me.

wtdcode commented 11 months ago

lol, that's quite confusing sometimes.