summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-07-11 13:43:27 +0200
committerAndreas Kling <kling@serenityos.org>2020-07-11 13:43:27 +0200
commit133803b8a75304803a5816c7e7e42d7b71ec84dd (patch)
tree0d8943c26c9500336e8d608650749e046c5c77b2
parent743d4ccb8fb26cc2778e54d874b1989ec8d42f44 (diff)
downloadserenity-133803b8a75304803a5816c7e7e42d7b71ec84dd.zip
UserspaceEmulator: Split SAR inline assembly into 8/16/32 bit variants
-rw-r--r--DevTools/UserspaceEmulator/SoftCPU.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/DevTools/UserspaceEmulator/SoftCPU.cpp b/DevTools/UserspaceEmulator/SoftCPU.cpp
index f650401241..c7462b5d86 100644
--- a/DevTools/UserspaceEmulator/SoftCPU.cpp
+++ b/DevTools/UserspaceEmulator/SoftCPU.cpp
@@ -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;