flat assembler
Message board for the users of flat assembler.

Index > Main > 1Byte to 8Byte Least Significant Bit

Author
Thread Post new topic Reply to topic
Fastestcodes



Joined: 13 Jun 2022
Posts: 75
Fastestcodes 11 Aug 2022, 06:29
What is the fastest? What is the shortest?
Post 11 Aug 2022, 06:29
View user's profile Send private message Reply with quote
f2065



Joined: 01 Jan 2012
Posts: 16
Location: Russia,Moscow
f2065 11 Aug 2022, 09:01
Code:
shr al, 1
setc dh
shr al, 1
setc dl
shr al, 1
setc ch
shr al, 1
setc cl
shr al, 1
setc bh
shr al, 1
setc bl
shr al, 1
setc ah    
Post 11 Aug 2022, 09:01
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 11 Aug 2022, 09:46
Of course PDEP instruction would make this trivial, and I'm just having a bit of fun:
Code:
; input in AL

        movzx   edx,al
        shr     edx,4
        and     eax,0Fh

        mov     ecx,204081h
        mov     ebx,01010101h

        imul    eax,ecx
        and     eax,ebx

        imul    edx,ecx
        and     edx,ebx

; output in EDX:EAX    
Post 11 Aug 2022, 09:46
View user's profile Send private message Visit poster's website Reply with quote
Fastestcodes



Joined: 13 Jun 2022
Posts: 75
Fastestcodes 11 Aug 2022, 13:05
set lsb 1: or al,01h
set lsb 0: and al,0feh
Post 11 Aug 2022, 13:05
View user's profile Send private message Reply with quote
Fastestcodes



Joined: 13 Jun 2022
Posts: 75
Fastestcodes 11 Aug 2022, 13:11
8Byte original: 5f 5f 60 60 60 60 61 61
input Byte 00000000b
8Byte 5e 5e 60 60 60 60 60 60
input Byte 11111111b
8Byte 5f 5f 61 61 61 61 61 61
Post 11 Aug 2022, 13:11
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 11 Aug 2022, 13:58
Code:
; 8-byte data at ESI (assume DS=ES), input byte in DL:
        mov     edi,esi
        mov     ecx,8
@@:
        lodsb
        shr     al,1
        shr     dl,1
        rcl     al,1
        stosb
        loop    @b    
Post 11 Aug 2022, 13:58
View user's profile Send private message Visit poster's website Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 928
Location: Russia
macomics 11 Aug 2022, 15:13
Code:
; input al = byte, output edx:eax
movzx eax, al
mov edx, 0x00204081
ror eax, 4
mov ecx, 0x01010101
mul edx
shld edx, eax, 4
and edx, ecx
and eax, ecx    
Post 11 Aug 2022, 15:13
View user's profile Send private message Reply with quote
Fastestcodes



Joined: 13 Jun 2022
Posts: 75
Fastestcodes 11 Aug 2022, 17:03
Code:
read 32MB pic to [m1]
read 4MB data to [m0]
[esi]=[m0]
[edi]=[m1]
mov al, [edi]
...
mov dh,[edi+7]
push eax
mov al,[esi];databyte
cmp al,00h
je La00
cmp al,01h
je La01
....
cmp al,0ffh
je Laff

La00:
pop eax
and al,0feh
...
and dh,0feh; if al=00h, 8Byte least significant bit will be 0,0,0,0,0,0,0,0
jmp Lawm

La01:
....;if al=01h, 8Byte least significant bit will be 0,0,0,0,0,0,0,1

Laff:
...; if  al=0ffh, 8Byte least significant bit will be 1,1,1,1,1,1,1,1

Lawm: ;write to mem
mov [edi],al
mov [edi+1],ah
...
mov [edi+7],dh
write out from [m1] to outfile

Every 8 picture Byte contains 1 secondary dataByte(8 least significant bit) 32MB pic,4MB secondary data.
    
Post 11 Aug 2022, 17:03
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.