mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:48:12 +00:00
UserspaceEmulator: Split SAR inline assembly into 8/16/32 bit variants
This commit is contained in:
parent
743d4ccb8f
commit
133803b8a7
1 changed files with 13 additions and 4 deletions
|
@ -702,12 +702,21 @@ T SoftCPU::sar_impl(T data, u8 steps)
|
|||
|
||||
u32 result = 0;
|
||||
u32 new_flags = 0;
|
||||
asm("sarl %%cl, %%eax\n"
|
||||
|
||||
if constexpr (sizeof(T) == 4)
|
||||
asm volatile("sarl %%cl, %%eax\n" ::"a"(data), "c"(steps));
|
||||
else if constexpr (sizeof(T) == 2)
|
||||
asm volatile("sarw %%cl, %%ax\n" ::"a"(data), "c"(steps));
|
||||
else if constexpr (sizeof(T) == 1)
|
||||
asm volatile("sarb %%cl, %%al\n" ::"a"(data), "c"(steps));
|
||||
|
||||
asm volatile(
|
||||
"mov %%eax, %%ebx\n"
|
||||
: "=b"(result));
|
||||
asm volatile(
|
||||
"pushf\n"
|
||||
"pop %%eax\n"
|
||||
: "=a"(new_flags), "=b"(result)
|
||||
: "a"(data), "c"(steps));
|
||||
"pop %%eax"
|
||||
: "=a"(new_flags));
|
||||
|
||||
set_flags_oszapc(new_flags);
|
||||
return result;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue