Viel Spaß!
Modul:
Code: Alles auswählen
;By Mijikai
DeclareModule BIT
Declare.i Set(Target.i,Bit.i)
Declare.i Get(Target.i,Bit.i)
Declare.i Reset(Target.i,Bit.i)
Declare.i Toggle(Target.i,Bit.i)
Declare.i SetLowNibble(Target.i,Nibble.i)
Declare.i SetHighNibble(Target.i,Nibble.i)
Declare.i GetLowNibble(Target.i)
Declare.i GetHighNibble(Target.i)
EndDeclareModule
Module BIT
Procedure.i Set(Target.i,Bit.i)
!mov rcx,[p.v_Target]
!mov rdx,[p.v_Bit]
!xor rax,rax
!bts [rcx],rdx
!setc al
ProcedureReturn
EndProcedure
Procedure.i Get(Target.i,Bit.i)
!mov rcx,[p.v_Target]
!mov rdx,[p.v_Bit]
!xor rax,rax
!bt [rcx],rdx
!setc al
ProcedureReturn
EndProcedure
Procedure.i Reset(Target.i,Bit.i)
!mov rcx,[p.v_Target]
!mov rdx,[p.v_Bit]
!xor rax,rax
!btr [rcx],rdx
!setc al
ProcedureReturn
EndProcedure
Procedure.i Toggle(Target.i,Bit.i)
!mov rcx,[p.v_Target]
!mov rdx,[p.v_Bit]
!xor rax,rax
!btc [rcx],rdx
!setc al
ProcedureReturn
EndProcedure
Procedure.i SetLowNibble(Target.i,Nibble.i)
!mov rcx,[p.v_Target]
!mov rax,[rcx]
!and rax,0F0h
!or rax,[p.v_Nibble]
!mov [rcx],rax
EndProcedure
Procedure.i SetHighNibble(Target.i,Nibble.i)
!mov rcx,[p.v_Target]
!mov rax,[rcx]
!mov rdx,[p.v_Nibble]
!and rdx,0Fh
!shl rdx,04h
!or rax,rdx
!mov [rcx],rax
EndProcedure
Procedure.i GetLowNibble(Target.i)
!mov rcx,[p.v_Target]
!mov rcx,[rcx]
!movzx rax,cl
!and rax,0Fh
ProcedureReturn
EndProcedure
Procedure.i GetHighNibble(Target.i)
!mov rcx,[p.v_Target]
!mov rcx,[rcx]
!movzx rax,cl
!sar rax,4h
ProcedureReturn
EndProcedure
EndModule
Code: Alles auswählen
sample.a = 0
BIT::Set(@sample,4)
Debug BIT::Get(@sample,4)
BIT::Toggle(@sample,4)
Debug BIT::Get(@sample,4)
BIT::SetLowNibble(@sample,$A)
BIT::SetHighNibble(@sample,$F)
Debug Hex(sample,#PB_Ascii)
BIT::Reset(@sample,4)
Debug Hex(BIT::GetLowNibble(@sample),#PB_Ascii)
Debug Hex(BIT::GetHighNibble(@sample),#PB_Ascii)