Author Topic: Shift BYTE and SHift DWORD Macros  (Read 2685 times)

0 Members and 1 Guest are viewing this topic.

Offline Theo Gottwald

  • Administrator
  • Hero Member
  • *****
  • Posts: 964
    • it-berater
Shift BYTE and SHift DWORD Macros
« on: December 21, 2009, 07:57:51 AM »
To get our collection of ASM GEM's forward, here are some SHIFTING Macros.

' #REGISTER:
' ESI - PB  Registervar 1
' EDI - PB Registervar  2

Code: [Select]
' Shift BYTE v by s to left

MACRO FUNCTION SHL_B(V, S)
    MACROTEMP V1
    DIM V1 AS BYTE
    ! pushad
    ! xor eax, eax
    ! xor ecx, ecx
    ! mov al, v
    ! mov cl, s
    ! shl eax, cl
    ! mov v1, al
    ! popad
END MACRO = V1

' Shift BYTE v by s to right

MACRO FUNCTION SHR_B(V, S)
    MACROTEMP V1
    DIM V1 AS BYTE
    ! pushad
    ! xor eax, eax
    ! xor ecx, ecx
    ! mov al, v
    ! mov cl, s
    ! shr eax, cl
    ! mov v1, al
    ! popad
END MACRO = V1

And here the Shift DWORD Macros.

Code: [Select]
' Shift DWORD v by s to left

MACRO FUNCTION SHL_D(V, S)
    MACROTEMP V1
    DIM V1 AS DWORD
    ! pushad
    ! mov eax, v
    ! mov ecx, s
    ! shl eax, cl
    ! mov v1, eax
    ! popad
END MACRO = V1

Code: [Select]
' Shift DWORD v by s to right
MACRO FUNCTION SHR_D(V, S)
    MACROTEMP V1
    DIM V1 AS DWORD
    ! pushad
    ! mov eax, v
    ! mov ecx, s
    ! shr eax, cl
    ! mov v1, eax
    ! popad
END MACRO = V1