flat assembler
Message board for the users of flat assembler.

 Index > Main > rol64 with 32bit register pair??
Author
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.
23 Jan 2006, 11:04
Tomasz Grysztar

Joined: 16 Jun 2003
Posts: 8105
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.
23 Jan 2006, 11:18
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?
23 Jan 2006, 13:07
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
23 Jan 2006, 16:55
Tomasz Grysztar

Joined: 16 Jun 2003
Posts: 8105
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.
23 Jan 2006, 17:24
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

 Jump to: Select a forum Official----------------AssemblyPeripheria General----------------MainTutorials and ExamplesDOSWindowsLinuxUnixMenuetOS Specific----------------MacroinstructionsOS ConstructionIDE DevelopmentProjects and IdeasNon-x86 architecturesHigh Level LanguagesProgramming Language DesignCompiler Internals Other----------------FeedbackHeapTest Area

Forum Rules:
 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum