Please: is there any chance to add commands to set, clear, test and change single bits on an integer?
Something to replace
Code: Select all
Procedure BitSet(A,N) ;Sets the N bit
ProcedureReturn A | 1 << N
EndProcedure
Procedure BitClr(A,N) ; Clears the N bit
ProcedureReturn BitSet(A ,N) ! BitSet(0,N)
EndProcedure
Procedure BitTst(A,N) ;Returns state of N bit
If A & BitClr(A,N)=A : ProcedureReturn #FALSE : EndIf
ProcedureReturn #TRUE
EndProcedure
Procedure BitChg(A,N) ;Change state of N bit
If A & BitClr(A,N)=A : ProcedureReturn A|1<<N: EndIf
ProcedureReturn BitSet(A,N) ! BitSet(0,N)
EndProcedure
;____________Test_____________________
A=BitSet(A,4) : Debug Bin(a)
A=BitSet(BitSet(A,5),6) : Debug Bin(A)
A=BitChg(A,5) : Debug Bin(A)
A=BitChg(A,5) : Debug Bin(A)
Debug BitTst(A,4)