yep, you're right, the check __FB_64BIT__ is valid.
Thanks for the validity explanation about the REG e** stuff.
I've must have read some nonsense, about that, somewhere on the INET.
I'm also quite a bit "rusted in", on Assembly coding however, I still remember what the
Author of my *self education* Book on Assembly wrote: "I'm NOT teaching you, just to
code Assembly, I'm going to teach you, how to code FAST Assembly!" (a german guy)
Your code optimized for speed:
Code: Select all
#Macro mirror64(Variable)
If SizeOf(Variable) = 8 Then
#Ifdef __FB_64BIT__
Asm
mov rax, qword Ptr[Variable]
Xor rbx, rbx ' faster than: mov rbx, 0
mov rcx, 64
1:
rcr rax
rcl rbx
dec rcx
jnz 1b
mov qword Ptr[Variable], rbx
End Asm
#Else
Asm
mov eax, dword Ptr[Variable]
Xor ebx, ebx ' mov ebx, 0
mov ecx, 32
mov edx, ecx ' save it to unused reg (for next run)
1:
rcr eax
rcl ebx
dec ecx
jnz 1b
mov eax, dword Ptr[Variable + 4]
mov dword Ptr[Variable + 4], ebx
Xor ebx, ebx ' mov ebx, 0
mov ecx, edx ' restore '32'
2: ' <--- diff. label
rcr eax
rcl ebx
dec ecx
jnz 2b
mov dword Ptr[Variable], ebx
End Asm
#EndIf
EndIf
#EndMacro
Dim As ULongInt zahl = &h2233445566778899
Print Bin(zahl, 64), Hex(zahl, 16)
mirror64(zahl)
Print Bin(zahl, 64), Hex(zahl, 16)
mirror64(zahl)
Print Bin(zahl, 64), Hex(zahl, 16)
Sleep