flat assembler
Message board for the users of flat assembler.

flat assembler > Main > Shift sequence of bytes.

Author
Thread Post new topic Reply to topic
Rubyko



Joined: 03 Mar 2017
Posts: 6
Hello. How to right or left shift a sequence of bytes by specified N bits effectively? Suggestions ?
Post 04 Mar 2017, 05:44
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 15875
Location: 162173 Ryugu
Have a look at shld and shrd. You can chain them together to make multiple {q|d}word shifts. If the shift amount is more than 32 bits (or 64 bits for 64-bit code) then shift by whole units and add the sh{l|r}d to the last few bits.
Post 04 Mar 2017, 06:28
View user's profile Send private message Visit poster's website Reply with quote
Rubyko



Joined: 03 Mar 2017
Posts: 6
Yes, it might work. Thank you.
Post 04 Mar 2017, 09:25
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 2653
Location: dank orb
The FASMG source code has a routine to do multi-byte shift.

See EXPRESSIONS.INC, shift_term_value_left: and shift_term_value_right:

_________________
utf8everywhere.org
Post 04 Mar 2017, 16:01
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6876
Location: Kraków, Poland
bitRAKE wrote:
The FASMG source code has a routine to do multi-byte shift.

See EXPRESSIONS.INC, shift_term_value_left: and shift_term_value_right:
These routines are sub-optimal for larger inputs, since they shift just a single byte per loop iteration. But I preferred to keep them simple, as optimizing them would have little effect on the overall performance of the assembler. For longer inputs SHLD/SHRD are probably a good recommendation. And fasm 1 uses SHLD/SHRD in its SHL/SHR operators implementation.
Post 04 Mar 2017, 16:30
View user's profile Send private message Visit poster's website 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 © 2004-2018, Tomasz Grysztar.

Powered by rwasa.