NBITS/de

From MCS Wiki AVR
< NBITS(Difference between revisions)
Jump to: navigation, search
(Example)
(Anmerkungen)
 
(3 intermediate revisions by one user not shown)
Line 1: Line 1:
== (**COPIED FROM ENGLISH PAGE**) === <span class="f_Header">Action</span> =
+
= <span class="f_Header">Funktion</span> =
  
Set all except the specified bits to 1.
+
Setzt alle Bits AUßER den angegebenen Bits auf 1.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 15: Line 15:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
= <span class="f_Header">Remarks</span> =
+
= <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" width="100%" style="width: 544px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 544px; border: 1px solid rgb(0, 0, 0);" |  
The BYTE/PORT variable that is assigned with the constant.
+
Die BYTE/PORT Variable die verändert werden soll.
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
Line 30: Line 30:
  
 
| valign="top" width="100%" style="width: 544px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 544px; border: 1px solid rgb(0, 0, 0);" |  
A list of bit numbers that NOT must be set to 1.
+
Liste der Bits die NICHT auf 1 gesetzt werden sollen.
  
 
|}
 
|}
Line 36: Line 36:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
While it is simple to assign a value to a byte, and there is special Boolean notation&nbsp;<span style="font-weight: bold;">&B</span>&nbsp;for assigning bits, the Bits() and NBits() function makes it simple to assign a few bits.
+
Man kann einer Variablen/einem Port einen Wert durch Zuweisung mit der Binärschreibweise &B zuweisen aber oftmals ist es besser lesbar wenn einzelne Bits mit Bits() bzw. NBits() gesetzt werden
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
B = &B01111101&nbsp;: how many zero’s are there?
+
B = &B01111101&nbsp; 'wieviele Nullen?
  
This would make it more readable: B = NBits(1, 7)
+
Dies wäre besser lesbar: B = NBits(1, 7)
  
You can read from the code that bit 1 and bit 7 are NOT set to 1.
+
Man sieht sofort, dass die Bits 1 und 7 NICHT auf 1 gesetzt werden.
  
It does not save code space as the effect is the same.
+
Es wird kein Programmspeicherplatz gespart weil der Effekt derselbe ist.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
The NBITS() function will set all bits to 1 except for the specified bits.
+
Die NBITS() Funktion setzt ALLE Bits auf 1 außer den angegebenen Bits.
  
It can only be used on bytes and port registers.
+
Kann nur für Byte-Variablen oder Port-Register verwendet werden.
  
Valid bits are in range from 0 to 7.
+
Gültige Bitnummern sind im Bereich 0 bis 7.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 60: Line 60:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
= <span class="f_Header">See Also</span> =
+
= <span class="f_Header">Siehe auch</span> =
  
 
[[BITS]]
 
[[BITS]]

Latest revision as of 01:17, 1 March 2013

Contents

Funktion

Setzt alle Bits AUßER den angegebenen Bits auf 1.

 

 

Syntax

Var = NBITS( b1 [,bn])

 

 

Anmerkungen

Var

Die BYTE/PORT Variable die verändert werden soll.

B1 , bn

Liste der Bits die NICHT auf 1 gesetzt werden sollen.

 

Man kann einer Variablen/einem Port einen Wert durch Zuweisung mit der Binärschreibweise &B zuweisen aber oftmals ist es besser lesbar wenn einzelne Bits mit Bits() bzw. NBits() gesetzt werden

 

B = &B01111101  'wieviele Nullen?

Dies wäre besser lesbar: B = NBits(1, 7)

Man sieht sofort, dass die Bits 1 und 7 NICHT auf 1 gesetzt werden.

Es wird kein Programmspeicherplatz gespart weil der Effekt derselbe ist.

 

Die NBITS() Funktion setzt ALLE Bits auf 1 außer den angegebenen Bits.

Kann nur für Byte-Variablen oder Port-Register verwendet werden.

Gültige Bitnummern sind im Bereich 0 bis 7.

 

 

Siehe auch

BITS

 

 

Beispiel


'--------------------------------------------------------------------------------
'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 ' Taktfrequenz
$baud = 19200 ' Baudrate
$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
 
'Man kann die &B Notation zum Setzen von Bits benutzen B = &B1000_0111
'Deutlicher ist es, die zu setzenden Bits mit der BITS() Funktion anzugeben:
B = Bits(0 , 1 , 2 , 7) 'setzt nur die Bits 0,1,2 und 7
Print B
 
'Während bits() alle genannten Bits auf 1 setzt gibt es auch Nbits()
'Das N steht für NOT. Nbits(1,2) bedeutet, dass alle Bits außer 1 und 2 gesetzt werden.
B = Nbits(7) 'Setze NICHT 7
Print B
End

Languages   English Deutsch  
Personal tools
Namespaces
Variants
Actions
Navigation
In other languages
Language