History

x86asm: Add lzcnt/tzcnt support

We already support popcnt, add lzcnt and tzcnt as well.

Mathias Krause committed 3 years ago

Commit 9cfc8f61 parent 07969204 files · +31 −1Browse files

Unified · Split

4 files
  1. i386-asm.h +3 −0
  2. i386-tok.h +2 −0
  3. tests/asmtest.S +23 −1
  4. x86_64-asm.h +3 −0
i386-asm.h+3−0
@@ -75,6 +75,9 @@ ALT(DEF_ASM_OP2(btcw, 0x0fba, 7, OPC_MODRM | OPC_WLX, OPT_IM8, OPT_REGW | OPT_EA · 74 unmodified lines
7575
7676 ALT(DEF_ASM_OP2(popcntw, 0xf30fb8, 0, OPC_MODRM | OPC_WLX, OPT_REGW | OPT_EA, OPT_REGW))
7777
78+ALT(DEF_ASM_OP2(tzcntw, 0xf30fbc, 0, OPC_MODRM | OPC_WLX, OPT_REGW | OPT_EA, OPT_REGW))
79+ALT(DEF_ASM_OP2(lzcntw, 0xf30fbd, 0, OPC_MODRM | OPC_WLX, OPT_REGW | OPT_EA, OPT_REGW))
80+
7881 /* prefixes */
7982 DEF_ASM_OP0(wait, 0x9b)
8083 DEF_ASM_OP0(fwait, 0x9b)
i386-tok.h+2−0
@@ -269,6 +269,8 @@ · 268 unmodified lines
269269 DEF_WLX(btr)
270270 DEF_WLX(btc)
271271 DEF_WLX(popcnt)
272+ DEF_WLX(tzcnt)
273+ DEF_WLX(lzcnt)
272274
273275 DEF_WLX(lar)
274276 DEF_WLX(lsl)
tests/asmtest.S+23−1
@@ -766,7 +766,29 @@ int $0x10 · 765 unmodified lines
766766 popcnt %rbx, %rdi
767767 popcntq %rcx, %r8
768768 #endif
769−
769+
770+ lzcnt %cx, %ax
771+ lzcntw %cx, %ax
772+ lzcnt %edx, %ebx
773+ lzcntl 8(%edi), %ecx
774+#ifdef __x86_64__
775+ lzcnt %rdi, %rdx
776+ lzcntq %r12, %r15
777+ lzcnt 0x40(%rcx), %r11
778+ lzcntq (%r8), %rsi
779+#endif
780+
781+ tzcnt %cx, %ax
782+ tzcntw %cx, %ax
783+ tzcnt %edx, %ebx
784+ tzcntl -24(%edi), %ecx
785+#ifdef __x86_64__
786+ tzcnt %rbp, %rdx
787+ tzcntq %rax, %r15
788+ tzcnt -8(%rbp), %rcx
789+ tzcntq (%r8), %r12
790+#endif
791+
770792 #ifdef __i386__
771793 boundl %edx, 0x10000
772794 boundw %bx, 0x1000
x86_64-asm.h+3−0
@@ -83,6 +83,9 @@ ALT(DEF_ASM_OP2(btcw, 0x0fba, 7, OPC_MODRM | OPC_WLX, OPT_IM8, OPT_REGW | OPT_EA · 82 unmodified lines
8383
8484 ALT(DEF_ASM_OP2(popcntw, 0xf30fb8, 0, OPC_MODRM | OPC_WLX, OPT_REGW | OPT_EA, OPT_REGW))
8585
86+ALT(DEF_ASM_OP2(tzcntw, 0xf30fbc, 0, OPC_MODRM | OPC_WLX, OPT_REGW | OPT_EA, OPT_REGW))
87+ALT(DEF_ASM_OP2(lzcntw, 0xf30fbd, 0, OPC_MODRM | OPC_WLX, OPT_REGW | OPT_EA, OPT_REGW))
88+
8689 /* prefixes */
8790 DEF_ASM_OP0(lock, 0xf0)
8891 DEF_ASM_OP0(rep, 0xf3)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t