Bitwise operations: Difference between revisions
Content added Content deleted
m (Should think twice before submitting ;) Added some tricks to PureBasic) |
|||
Line 885: | Line 885: | ||
Debug ~a ;Not |
Debug ~a ;Not |
||
Debug a << b ; shift left |
Debug a << b ; shift left |
||
Debug a >> b ;shift right |
Debug a >> b ; arithmetic shift right |
||
; Logical shift right and rotates are not available |
|||
⚫ | |||
⚫ | |||
; you can multiply or divide by powers of two, which is translated into arithmetic shifts in ASM. |
|||
Define Temp |
|||
; No native function for rotating |
|||
⚫ | |||
⚫ | |||
!mov edx, dword [p.v_a] |
|||
!mov ecx, dword [p.v_b] |
|||
!shr edx, cl |
|||
!mov dword [p.v_Temp], edx |
|||
Debug Temp |
|||
; rotate left |
|||
!mov edx, dword [p.v_a] |
|||
!mov ecx, dword [p.v_b] |
|||
!rol edx, cl |
|||
!mov dword [p.v_Temp], edx |
|||
Debug Temp |
|||
; rotate right |
|||
!mov edx, dword [p.v_a] |
|||
!mov ecx, dword [p.v_b] |
|||
!ror edx, cl |
|||
!mov dword [p.v_Temp], edx |
|||
Debug Temp |
|||
EndProcedure</lang> |
EndProcedure</lang> |
||