Restored from previous forum. Originally posted by Shagwana.
Hello,
Could someone please tell me if there is a binary not operator like the | and & operators?
If not, then how could I not to numbers together!
for example;
c=a|b ; or 2 numbers
c=a&b ; and 2 numbers
c=ab ;not 2 numers
http://www.sublimegames.com
Binary not
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Danilo.
Something like that ??
(untested)
cya,
...Danilo
Edited by - Danilo on 06 January 2002 18:56:33
Code: Select all
Procedure NOT(a,b)
MOV EAX,b
NOT EAX
AND a,EAX
ProcedureReturn a
EndProcedure
(untested)
cya,
...Danilo
Edited by - Danilo on 06 January 2002 18:56:33
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Pupil.
(not(b)) and (a)
A NOT operation only takes one argument, what your assembly code seems to do is this logical operation:Code: Select all
Procedure NOT(a,b) MOV EAX,b NOT EAX AND a,EAX ProcedureReturn a EndProcedure
(not(b)) and (a)
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Shagwana.
Well yes, its a 'not' 'and' i wana do - im trying to turn bits off
So does 'Not(b)' do part of hat i need?
http://www.sublimegames.com
Well yes, its a 'not' 'and' i wana do - im trying to turn bits off
So does 'Not(b)' do part of hat i need?
http://www.sublimegames.com
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Pupil.
There's probably an assembly operator that can do just that at least the Motorola 680xx family of processors have that, so most likely the intel x86 family of processors have that operator too. But i don't know what the operator is in x86 assembly. By using the small knowledge of x86 assembly i have i put together the following procedure that is able to turn off one bit in a bitfield:
Procedure.l ClearBit(Dest.l, Bit.l) ; 'Bit' is the bit to turn off i.e Bit=0=>clear bit 0, Bit=8=>clear bit 8.
Mask = 1
Mask = Mask << Bit ; Shift up bit one 'Bit' steps
MOV EAX, Mask
NOT EAX
AND Dest,EAX
ProcedureReturn Dest
EndProcedure
Ok.Well yes, its a 'not' 'and' i wana do - im trying to turn bits off
So does 'Not(b)' do part of hat i need?
http://www.sublimegames.com
There's probably an assembly operator that can do just that at least the Motorola 680xx family of processors have that, so most likely the intel x86 family of processors have that operator too. But i don't know what the operator is in x86 assembly. By using the small knowledge of x86 assembly i have i put together the following procedure that is able to turn off one bit in a bitfield:
Procedure.l ClearBit(Dest.l, Bit.l) ; 'Bit' is the bit to turn off i.e Bit=0=>clear bit 0, Bit=8=>clear bit 8.
Mask = 1
Mask = Mask << Bit ; Shift up bit one 'Bit' steps
MOV EAX, Mask
NOT EAX
AND Dest,EAX
ProcedureReturn Dest
EndProcedure