Code: Select all
Debug "************* rol12 ************************"
Macro rol12(n,b)
!mov ecx,12
!xor edx,edx
!mov eax,dword[v_#b]
!div ecx
!mov ecx,edx
!mov ax,word[v_#n]
!mov bx,ax
!shl bx,4
!shld ax,bx,cl
!and ax,$0fff
!mov word[v_#n],ax
EndMacro
;Test it:
For r=0 To 25
c.w=$d05
rol12(c,r)
Debug RSet(Bin(c),12,"0")
Next
Debug "************* rol24 **************************"
Macro rol24(n,b)
!mov ecx,24
!xor edx,edx
!mov eax,dword[v_#b]
!div ecx
!mov ecx,edx
!mov eax,dword[v_#n]
!mov ebx,eax
!shl ebx,8
!shld eax,ebx,cl
!and eax,$00ffffff
!mov dword[v_#n],eax
EndMacro
;Test it:
For r=0 To 25
cl.l=$123d05
rol24(cl,r)
Debug RSet(Bin(cl),24,"0")
Next
Debug "************* ror12 **************************"
Macro ror12(n,b)
!mov ecx,12
!xor edx,edx
!mov eax,dword[v_#b]
!div ecx
!mov ecx,edx
!add ecx,4
!mov ax,word[v_#n]
!mov bx,ax
!shl ax,4
!shrd ax,bx,cl
!and ax,$0fff
!mov word[v_#n],ax
EndMacro
;Test it:
For r=0 To 25
c.w=$d06
ror12(c,r)
Debug RSet(Bin(c),12,"0")
Next
Debug "************* ror24 **************************"
Macro ror24(n,b)
!mov ecx,24
!xor edx,edx
!mov eax,dword[v_#b]
!div ecx
!mov ecx,edx
!add ecx,8
!mov eax,dword[v_#n]
!mov ebx,eax
!shl eax,8
!shrd eax,ebx,cl
!and eax,$00ffffff
!mov dword[v_#n],eax
EndMacro
;Test it:
For r=0 To 25
cl.l=$321d05
ror24(cl,r)
Debug RSet(Bin(cl),24,"0")
Next