• Welcome to Powerbasic Museum 2020-B.
 

News:

Forum in repository mode. No new members allowed.

Main Menu

Shift BYTE and SHift DWORD Macros

Started by Theo Gottwald, December 21, 2009, 07:57:51 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Theo Gottwald

To get our collection of ASM GEM's forward, here are some SHIFTING Macros.

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

' 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.

' 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


' 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