BITS/de

(Difference between revisions)
Jump to: navigation, search
((**COPIED FROM ENGLISH PAGE**) =)
(Remarks)
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" style="border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" style="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" style="border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" style="border: 1px solid rgb(0, 0, 0);" |  
A list of bit numbers that must be set to 1.
+
Eine Liste mit Bitnummern die auf 1 gesetzt werden soll.
  
 
|}
 
|}
Line 38: Line 38:
 
<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 &B for assigning bits, the Bits() function makes it simple to assign a few bits.
+
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;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
B = &B1000001&nbsp;: how many zero’s are there?
+
B = &B1000001&nbsp;: Wieviele Nullen sind das?
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
This would make it more readable&nbsp;: B = Bits(0, 6)
+
Dies ist besser lesbar: B = Bits(0, 6)
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
You can read from the code that bit 0 and bit 6 are set to 1.
+
Man sieht sofort, dass Bit 0 und Bit 6 auf 1 gesetzt werden.
  
It does not save code space as the effect is the same.
+
Es wird kein Programmspeicher gespart weil der Effekt derselbe ist
  
It can only be used on bytes and port registers.
+
Kann nur für Byte-Variable und Ports verwendet werden.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
Valid bits are in range from 0 to 7.
+
Gültige Bitnummern sind im Bereich von 0 bis 7.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</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

NBITS

 

 

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  
Personal tools
Namespaces
Variants
Actions
Navigation
In other languages
Language