Action
Set a bit to the value one.
Syntax
SET bit
SET var.x
Remarks
Bit |
Bitvariable. |
Var |
A byte, integer, word or long variable. |
X |
Bit of variable (0-7) to set. (0-15 for Integer/Word) and (0-31) for Long |
See also
Example
'--------------------------------------------------------------------------------
'name : boolean.bas
'copyright : (c) 1995-2005, MCS Electronics
'purpose : demo: AND, OR, XOR, NOT, BIT and MOD
'suited for demo : yes
'commercial addon needed : no
'use in simulator : possible
'--------------------------------------------------------------------------------
$regfile = "m48def.dat" ' specify the used micro
$crystal = 4000000 ' used crystal frequency
$baud = 19200 ' use baud rate
$hwstack = 32 ' default use 32 for the hardware stack
$swstack = 10 ' default use 10 for the SW stack
$framesize = 40 ' default use 40 for the frame space
Dim A As Byte , B1 As Byte , C As Byte
Dim Aa As Bit , I As Integer
A = 5 : B1 = 3 ' assign values
C = A And B1 ' and a with b
Print "a AND c = " ; C ' print result
C = A Or B1 'also for or
Print "a OR b1 = " ; C
C = A Xor B1 ' and for xor
Print "a XOR b1 = " ; C
A = 1
C = Not A 'not
Print "c = NOT a " ; C
C = C Mod 10
Print "c MOD 10 = " ; C
If Portb.1 = 1 Then
Print "Bit set"
Else
Print "Bit not set"
End If
Aa = 1 'use this or ..
Set Aa 'use the set statement
If Aa = 1 Then
Print "Bit set (aa=1)"
Else
Print "Bit not set(aa=0)"
End If
Aa = 0 'now try 0
Reset Aa 'or use reset
If Aa = 1 Then
Print "Bit set (aa=1)"
Else
Print "Bit not set(aa=0)"
End If
B1 = 255 'assign variable
Reset B1.0 'reset bit 0 of a byte variable
Print B1 'print it
Set B1.0 'set it
Print B1 'print it
End