flat assembler
Message board for the users of flat assembler.

Index > Main > rol64 with 32bit register pair??

Author
Thread Post new topic Reply to topic
Genix



Joined: 23 Jan 2006
Posts: 3
Location: Ostrava, Czech Republic
Genix 23 Jan 2006, 11:04
Can anyone help me with my problem? I need to left rotate 64bit value stored in register pair (ex. EDX:EAX). I am just beginner in asm so this is out of my knowledge. Thanks.
Post 23 Jan 2006, 11:04
View user's profile Send private message ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 23 Jan 2006, 11:18
If you need to rotate just by 1 bit, you can do it through carry:
Code:
bt eax,31 ; CF := the highest bit of EAX
rcl edx,1
rcl eax,1    

To rotate by larger amount you'd have to use some intermediating register, perhaps with help of SHLD instruction.
Post 23 Jan 2006, 11:18
View user's profile Send private message Visit poster's website Reply with quote
Genix



Joined: 23 Jan 2006
Posts: 3
Location: Ostrava, Czech Republic
Genix 23 Jan 2006, 13:07
So if i need to rotate by N bit, can i use cycle with rotation by 1 bit or can i rotate it at once?
Post 23 Jan 2006, 13:07
View user's profile Send private message ICQ Number Reply with quote
Genix



Joined: 23 Jan 2006
Posts: 3
Location: Ostrava, Czech Republic
Genix 23 Jan 2006, 16:55
Tomasz Grysztar wrote:
If you need to rotate just by 1 bit, you can do it through carry:
Code:
bt eax,31 ; CF := the highest bit of EAX
rcl edx,1
rcl eax,1    

To rotate by larger amount you'd have to use some intermediating register, perhaps with help of SHLD instruction.



Is it right?

rol64start:
mov ecx, 15 ; 15xrepeat


bt eax, 31
cycle_start:
rcl edx, 1

rcl eax, 1

loop cycle_start
Post 23 Jan 2006, 16:55
View user's profile Send private message ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 23 Jan 2006, 17:24
No, you are duplicating one bit this way - you would have to put the BT instruction also inside the loop.

Also, assuming you've got the shift count in CL, you can it without loop using SHLD, something like:
Code:
shld ebx,edx,cl
shld edx,eax,cl
ror ebx,cl
shld eax,ebx,cl    

with EBX as a temporary storage.
Post 23 Jan 2006, 17:24
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 © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.