flat assembler
Message board for the users of flat assembler.
Index
> Main > How reset bits for one asm command? |
Author |
|
Roman 29 Apr 2023, 06:34
For example.
I want reset bits from 23 to 31 I could using loop and btr, but I want reset faster in one asm command. How do this? |
|||
29 Apr 2023, 06:34 |
|
revolution 29 Apr 2023, 06:58
Code: and eax,0x007fffff |
|||
29 Apr 2023, 06:58 |
|
Furs 29 Apr 2023, 17:29
You can also use bzhi if you have BMI2 and a non-constant bit position.
|
|||
29 Apr 2023, 17:29 |
|
Roman 30 Apr 2023, 10:25
My Idea put in rax 8 bytes text and rdx 8 bytes text.
Cut all symbols until 32 And compare rax and rdx Code: Text db 'defxyz defzxy1 ' Mov rax, qword [Text] Some way in rax reset to null this part " d" Mov rdx, qword [Text+7] Some way in rdx reset rdx bits to null ;rax=defxyz Rdx=defzxy1 Cmp rax, rdx My variant Code: tmp dq 0,0 Mov rax, "r01234 d" Mov qword [tmp], rax Mov ebx, tmp-1 .1: Inc ebx Cmp byte [ebx], 0 Jz .2 Cmp byte [ebx], 32 Jnz .1 Mov qword [ebx], 0 .2: Mov rax, qword [tmp] |
|||
30 Apr 2023, 10:25 |
|
macomics 30 Apr 2023, 11:40
Code: Text db 'defxyz defzxy1 ' Mask dq 0x0000FFFFFFFFFFFF mov rax, qword [Text] and rax, qword [Mask] mov rdx, qword [Text + 7] and rdx, qword [Mask] cmp rax, rdx Code: Text db 'defxyz defzxy1 ' mov rax, 0x0000FFFFFFFFFFFF mov rdx, rax and rax, qword [Text] and rdx, qword [Text + 7] cmp rax, rdx Code: Text db 'defxyz defzxy1 ' mov rax, qword [Text] mov rdx, qword [Text + 7] mov cl, 16 shl rax, cl shl rdx, cl shr rax, cl shr rdx, cl cmp rax, rdx |
|||
30 Apr 2023, 11:40 |
|
Roman 30 Apr 2023, 11:52
Thanks ! Cool variant.
Code: Text db 'defxyz defzxy1 ' mov rax, 0x0000FFFFFFFFFFFF mov rdx, rax and rax, qword [Text] and rdx, qword [Text + 7] cmp rax, rdx But not universal and failed on this: Code: Text db 'defxyz22 defzxy1 ' Text2 dq 0,0 mov rax, 0x0000FFFFFFFFFFFF mov rdx, rax and rax, qword [Text] and rdx, qword [Text + 7] mov [Text2],rax ;='defxyz' but must be 'defxyz22' mov [Text2+7],rdx ;='2 defzxy' but must be '2' |
|||
30 Apr 2023, 11:52 |
|
Roman 30 Apr 2023, 13:17
https://www.officedaytime.com/simd512e/simdimg/pcmp.php?f=pcmpeqb
Code: Text db 'def xyz22 defzxy1 22' Text3 dq 0,0 movups xmm1,dqword [Text] movaps xmm0,xmm1 movups xmm2,dqword [Text+10] PCMPEQB xmm1, xmm2 ;result out to xmm1 andps xmm0,xmm1 movups dqword[Text3],xmm0 movq rax,xmm0 mov ebx,2 bsf rax,rbx ;eax=1 because all 3 bits = 1 _ mean 0 (if not equal byte xmm1,xmm2) After Text3 = d,e,f,_,x,y,_,_,2,_,_,_,_,_,_,_ |
|||
30 Apr 2023, 13:17 |
|
macomics 30 Apr 2023, 13:56
Roman wrote: But not universal and failed on this: My example works correctly. Resets what is set. It is you who expect from him what cannot be. Why on earth should it define spaces in a string. What did you write in the title of the topic. What you wanted, you got... |
|||
30 Apr 2023, 13:56 |
|
Roman 30 Apr 2023, 18:42
New variant:
Code: Text db 'def xyz22 defzxy1 22' TexB db 16 dup(32) movups xmm1,dqword [Text] movaps xmm0,xmm1 xorps xmm3,xmm3 movups xmm2,dqword [TexB] jmp .22 .20: vpslldq xmm0, xmm0, 1 movaps xmm1,xmm0 .22: PCMPEQB xmm1, xmm2 comisd xmm1,xmm3 ;5 loops jnz .20 movq rax,xmm0 ;rax=0x6665640000000000 |
|||
30 Apr 2023, 18:42 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.