BITS/de
(Difference between revisions)
(→(**COPIED FROM ENGLISH PAGE**) =) |
(→Remarks) |
||
Line 15: | Line 15: | ||
<span style="font-family: Arial;"> </span> | <span style="font-family: Arial;"> </span> | ||
− | = <span class="f_Header"> | + | = <span class="f_Header">Anmerkungen</span> = |
<div style="padding: 0px; margin: 0px 0px 0px 4px;"> | <div style="padding: 0px; margin: 0px 0px 0px 4px;"> | ||
{| width="631" cellspacing="0" cellpadding="1" border="1" style="border: 2px solid rgb(0, 0, 0); border-spacing: 0px; border-collapse: collapse;" | {| width="631" cellspacing="0" cellpadding="1" border="1" style="border: 2px solid rgb(0, 0, 0); border-spacing: 0px; border-collapse: collapse;" | ||
Line 23: | Line 23: | ||
| valign="top" style="border: 1px solid rgb(0, 0, 0);" | | | valign="top" style="border: 1px solid rgb(0, 0, 0);" | | ||
− | + | Die BYTE/PORT Variable die verändert werden soll. | |
|- style="vertical-align: top;" | |- style="vertical-align: top;" | ||
Line 30: | Line 30: | ||
| valign="top" style="border: 1px solid rgb(0, 0, 0);" | | | valign="top" style="border: 1px solid rgb(0, 0, 0);" | | ||
− | + | Eine Liste mit Bitnummern die auf 1 gesetzt werden soll. | |
|} | |} | ||
Line 38: | Line 38: | ||
<span style="font-family: Arial;"> </span> | <span style="font-family: Arial;"> </span> | ||
− | + | Während es möglich ist, einer Byte/Port-Variablen einen Wert zuzuweisen und es auch spezielle Binärnotation mit &B gibt um die Bits zuzuweisen ermöglicht die Bits() Funktion das einfache Zuweisen einzelner Bits. | |
<span style="font-family: Arial;"> </span> | <span style="font-family: Arial;"> </span> | ||
− | B = &B1000001 : | + | B = &B1000001 : Wieviele Nullen sind das? |
<span style="font-family: Arial;"> </span> | <span style="font-family: Arial;"> </span> | ||
− | + | Dies ist besser lesbar: B = Bits(0, 6) | |
<span style="font-family: Arial;"> </span> | <span style="font-family: Arial;"> </span> | ||
− | + | Man sieht sofort, dass Bit 0 und Bit 6 auf 1 gesetzt werden. | |
− | + | Es wird kein Programmspeicher gespart weil der Effekt derselbe ist | |
− | + | Kann nur für Byte-Variable und Ports verwendet werden. | |
<span style="font-family: Arial;"> </span> | <span style="font-family: Arial;"> </span> | ||
− | + | Gültige Bitnummern sind im Bereich von 0 bis 7. | |
<span style="font-family: Arial;"> </span> | <span style="font-family: Arial;"> </span> |
Revision as of 00:59, 1 March 2013
Contents |
Funktion
Setzt alle angegebenen Bits auf 1.
Syntax
Var = Bits( b1 [,bn])
Anmerkungen
Var |
Die BYTE/PORT Variable die verändert werden soll. |
B1 , bn |
Eine Liste mit Bitnummern die auf 1 gesetzt werden soll. |
Während es möglich ist, einer Byte/Port-Variablen einen Wert zuzuweisen und es auch spezielle Binärnotation mit &B gibt um die Bits zuzuweisen ermöglicht die Bits() Funktion das einfache Zuweisen einzelner Bits.
B = &B1000001 : Wieviele Nullen sind das?
Dies ist besser lesbar: B = Bits(0, 6)
Man sieht sofort, dass Bit 0 und Bit 6 auf 1 gesetzt werden.
Es wird kein Programmspeicher gespart weil der Effekt derselbe ist
Kann nur für Byte-Variable und Ports verwendet werden.
Gültige Bitnummern sind im Bereich von 0 bis 7.
See Also
Example
'-------------------------------------------------------------------------------- 'name : bits-nbits.bas 'copyright : (c) 1995-2005, MCS Electronics 'purpose : demo for Bits() AND Nbits() 'micro : Mega48 '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 B As Byte 'while you can use &B notation for setting bits, like B = &B1000_0111 'there is also an alternative by specifying the bits to set B = Bits(0 , 1 , 2 , 7) 'set only bit 0,1,2 and 7 Print B 'and while bits() will set all bits specified to 1, there is also Nbits() 'the N is for NOT. Nbits(1,2) means, set all bits except 1 and 2 B = Nbits(7) 'do not set bit 7 Print B End
Languages | English • Deutsch |
---|