Tel: (519) 746-7178
Email: info@lumousoft.com
Bit is the atomic data. Current high level languages like c do not allow directly operating on bit, usually using indirect way to operate on the bit such as byte bitwise operation. Lumousoft graphic language allows directly operating on bit.
lumousoft graphic language treats bit as one of data type like char, short etc. When we define a bit variable, we need to know which variable that contains this bit, we call the variable as the source variable of bit and where the bit locate in a bit source variable. We can define bit variable through variable dialog as shown in Fig.1. In variable manger dialog, select bit data type in data type dropdown list, then in the dropdown list of source to select source variable, in bit position dropdown list to select which bit of source variable. Since we select the source variable has data type of short, in other words it has 2 bytes, consists of 16 bits. The bit position dropdown-list lists all possible bit position. Bit variable range or scope type depends on that of source variable. For example if the source variable is local variable, the associated bit variable is local too. We can also set initial value by initial drop-down list. The bit initial value will affect the source variable, if we set the initial value of bit, the source initial value will change accordingly.
Fig.1 Variable mamgeer dialog
If we empty the source variable or we do not designate bit source variable, the system will assign a temporary variable for bit source.
We also can assign bit source and bit position in code, the format is:
Bit variable = & (bit source # bit position)
For example, bit0= &(a#2); where bit0 is bit variable, a is non-bit variable
The variable bit0 is the third bit of variable a (here we use zero-base bit position)
In code we can use the following format to represent bit
Bit source # bit position
For example, a#4=0; here a#4 means the fifth bit of variable a.
It must be notice that the bit position must be a constant value, in other words, the bit position value cannot be variable.
The bit value can be 0 or 1 like Boolean, when bit work with non-bit data type variable or in logical operation, the bit variable is treat as a Boolean variable, when the bit is set the Boolean value is 1 and the bit is reset, the Boolean value is 0. Therefore bit variable woke with other non-bit variable it works as Boolean similar to other language like c.
When bit variable works with other bit variable it will operate according to bit value. The bit operation can be: and (&), or(|), xor(^), not(~ or !), and assign(&=), or assign (|=), xor assign(^=).
Bit variable can be assigned by bit variable, non-bit variable or expression. When is assigned non-bit variable, the bit variable is set when the non-bit variable is non zero value, while the bit variable is reset when the non-bit variable is zero. When the bit variable is assigned by a bit variable, the bit value will be the same as the endowed bit variable.
When bit source variable consists of more than one byte, lumousoft graphic compiler will automatically to find the byte that bit stay and find out the correct bit position. For example a#15=1, where a is short data type and supposed the variable a is allocated by 2 bytes with the address of 0x20 and 0x21 respectively. The address of 0x20 is lower byte and 0x21 higher byte. The compiler will use the 7th bit of the byte with the address of 0x21 to replace a#15.
Fig 2 is graphic codes Fig3 is the assembly codes coming from graphic code compilation. The variable a is a short data type variable, the bit0, bit1 and bit3 represent first bit, second bit and fourth bit of variable a respectively. The variable x has a data type of char. The definition of these variables are shown in Fig.1.
Fig.2 Grahic codes
Fig.3 Assembly codes
Lumousoft graphic language offers convenient method to directly handle bit variable, as a result, user can easily handle microprocessor and reduce reductant code increasing performance.
©Lumousoft Inc. 2013 - 2018.
Links
Elektronik Forum EEWeb : EEWEb Germany is an online community for electronics and electrical engineers and hobbyist. It offers electrical engineering and electronics forum. It also has electrical and electronic design articles, and resources in the area of RF design, analog design, embedded design, PCB design, test and measure.
Power Electronics News: Power Electronics News offers electrical engineering news focused on Power and Power solutions. Up to date solutions and products featuring the latest innovations in power solutions.
PCBWeb : A free CAD application for designing and manufacturing electronics hardware.