dinoqqq / asmdebugger

ASM Debugger Online
27 stars 6 forks source link

sar instruction not supported #2

Open Darthfett opened 3 years ago

Darthfett commented 3 years ago

shift right with sign extension instruction (sar) is not supported.

I believe this is an accurate python implementation (though it could likely be more efficient without the branch).

Note: This implementation works on unsigned numbers (because python numbers can be arbitrarily large):

def sar(x, n, sz=32):
    return (x >> n) | (((2**n - 1) << (sz - n)) if (x & (1 << (sz-1))) else 0)
dinoqqq commented 3 years ago

@Darthfett unfortunately I don't plan to integrate this feature in the near future. If you find time for a PR, feel free so!