FLIP

From MCS Wiki AVR
(Difference between revisions)
Jump to: navigation, search
(Created page with "<div id="idcontent" class="nonscroll" style="height: 751px;"><div id="innerdiv"> = <span class="f_Header">Action</span> = Flips the bits in a byte. <span style="font-family:...")
 
 
Line 1: Line 1:
<div id="idcontent" class="nonscroll" style="height: 751px;"><div id="innerdiv">
 
 
= <span class="f_Header">Action</span> =
 
= <span class="f_Header">Action</span> =
  
Line 55: Line 54:
 
= <span class="f_Header">Example</span> =
 
= <span class="f_Header">Example</span> =
  
<span style="font-size: 11pt; font-family: 'Consolas'; color: #000080;">$regfile</span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">=</span><span style="font-size: 11pt; font-family: 'Consolas'; color: #008080;">"m88def.dat"</span><br/><span style="font-size: 11pt; font-family: 'Consolas'; color: #000080;">$crystal</span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">=</span><span style="font-size: 11pt; font-family: 'Consolas';">8000000</span><br/><span style="font-size: 11pt; font-family: 'Consolas'; color: #000080;">$baud</span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">=</span><span style="font-size: 11pt; font-family: 'Consolas';">19200</span><br/><span style="font-size: 11pt; font-family: 'Consolas'; color: #000080;">$hwstack</span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">=</span><span style="font-size: 11pt; font-family: 'Consolas';">32</span><br/><span style="font-size: 11pt; font-family: 'Consolas'; color: #000080;">$swstack</span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">=</span><span style="font-size: 11pt; font-family: 'Consolas';">16</span><br/><span style="font-size: 11pt; font-family: 'Consolas'; color: #000080;">$framesize</span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">=</span><span style="font-size: 11pt; font-family: 'Consolas';">24</span><br/><span style="font-size: 11pt; font-family: 'Consolas';">&nbsp;</span><br/><span style="font-size: 11pt; font-family: 'Consolas'; color: #000080;">Dim</span><span style="font-size: 11pt; font-family: 'Consolas';">B </span><span style="font-size: 11pt; font-family: 'Consolas'; color: #000080;">As</span><span style="font-size: 11pt; font-family: 'Consolas'; color: #000080;">Byte</span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">,</span><span style="font-size: 11pt; font-family: 'Consolas';">V </span><span style="font-size: 11pt; font-family: 'Consolas'; color: #000080;">As</span><span style="font-size: 11pt; font-family: 'Consolas'; color: #000080;">Byte</span><br/><span style="font-size: 11pt; font-family: 'Consolas';">&nbsp;</span><br/><span style="font-size: 11pt; font-family: 'Consolas'; color: #000080;">For</span><span style="font-size: 11pt; font-family: 'Consolas';">B </span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">=</span><span style="font-size: 11pt; font-family: 'Consolas';">1 </span><span style="font-size: 11pt; font-family: 'Consolas'; color: #000080;">To</span><span style="font-size: 11pt; font-family: 'Consolas';">20</span><br/><span style="font-size: 11pt; font-family: 'Consolas';">&nbsp; &nbsp;V </span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">=</span><span style="font-size: 11pt; font-family: 'Consolas';">Flip</span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">(</span><span style="font-size: 11pt; font-family: 'Consolas';">b</span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">)</span><br/><span style="font-size: 11pt; font-family: 'Consolas';">&nbsp; </span><span style="font-size: 11pt; font-family: 'Consolas'; color: #000080;">Print</span><span style="font-size: 11pt; font-family: 'Consolas';">B </span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">;</span><span style="font-size: 11pt; font-family: 'Consolas'; color: #008080;">" "</span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">;</span><span style="font-size: 11pt; font-family: 'Consolas'; color: #000080;">Bin</span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">(</span><span style="font-size: 11pt; font-family: 'Consolas';">b</span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">)</span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">;</span><span style="font-size: 11pt; font-family: 'Consolas'; color: #008080;">" "</span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">;</span><span style="font-size: 11pt; font-family: 'Consolas'; color: #000080;">Bin</span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">(</span><span style="font-size: 11pt; font-family: 'Consolas';">v</span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">)</span><br/><span style="font-size: 11pt; font-family: 'Consolas'; color: #000080;">Next</span><br/><span style="font-size: 11pt; font-family: 'Consolas';">&nbsp;</span><br/><span style="font-size: 11pt; font-family: 'Consolas'; color: #000080;">End</span>
+
<source lang="bascomavr">
 +
$regfile = "m88def.dat"
 +
$crystal = 8000000
 +
$baud = 19200
 +
$hwstack=32
 +
$swstack = 16
 +
$framesize=24
 +
 +
Dim B As Byte , V As Byte
 +
 +
For B = 1 To 20
 +
V = Flip(b)
 +
Print B ; " " ; Bin(b) ; " " ; Bin(v)
 +
Next
 +
 +
End
 +
</source>
  
<span style="font-family: 'Courier New'; font-weight: bold; color: #000080;">&nbsp;</span>
+
= <span style="font-size: 14pt; font-weight: bold;">OUTPUT</span> =
  
= <span class="f_Header">OUTPUT</span> =
+
<source lang="bascomavr">
 +
1 00000001 10000000
 +
2 00000010 01000000
 +
3 00000011 11000000
 +
4 00000100 00100000
 +
5 00000101 10100000
 +
6 00000110 01100000
 +
7 00000111 11100000
 +
8 00001000 00010000
 +
9 00001001 10010000
 +
10 00001010 01010000
 +
11 00001011 11010000
 +
12 00001100 00110000
 +
13 00001101 10110000
 +
14 00001110 01110000
 +
15 00001111 11110000
 +
16 00010000 00001000
 +
17 00010001 10001000
 +
18 00010010 01001000
 +
19 00010011 11001000
 +
20 00010100 00101000
 +
</source>
  
<span style="font-family: 'Courier New'; font-weight: bold; color: #000080;">1 00000001 10000000</span>
+
{{Languages}}
 
+
<span style="font-family: 'Courier New'; font-weight: bold; color: #000080;">2 00000010 01000000</span>
+
 
+
<span style="font-family: 'Courier New'; font-weight: bold; color: #000080;">3 00000011 11000000</span>
+
 
+
<span style="font-family: 'Courier New'; font-weight: bold; color: #000080;">4 00000100 00100000</span>
+
 
+
<span style="font-family: 'Courier New'; font-weight: bold; color: #000080;">5 00000101 10100000</span>
+
 
+
<span style="font-family: 'Courier New'; font-weight: bold; color: #000080;">6 00000110 01100000</span>
+
 
+
<span style="font-family: 'Courier New'; font-weight: bold; color: #000080;">7 00000111 11100000</span>
+
 
+
<span style="font-family: 'Courier New'; font-weight: bold; color: #000080;">8 00001000 00010000</span>
+
 
+
<span style="font-family: 'Courier New'; font-weight: bold; color: #000080;">9 00001001 10010000</span>
+
 
+
<span style="font-family: 'Courier New'; font-weight: bold; color: #000080;">10 00001010 01010000</span>
+
 
+
<span style="font-family: 'Courier New'; font-weight: bold; color: #000080;">11 00001011 11010000</span>
+
 
+
<span style="font-family: 'Courier New'; font-weight: bold; color: #000080;">12 00001100 00110000</span>
+
 
+
<span style="font-family: 'Courier New'; font-weight: bold; color: #000080;">13 00001101 10110000</span>
+
 
+
<span style="font-family: 'Courier New'; font-weight: bold; color: #000080;">14 00001110 01110000</span>
+
 
+
<span style="font-family: 'Courier New'; font-weight: bold; color: #000080;">15 00001111 11110000</span>
+
 
+
<span style="font-family: 'Courier New'; font-weight: bold; color: #000080;">16 00010000 00001000</span>
+
 
+
<span style="font-family: 'Courier New'; font-weight: bold; color: #000080;">17 00010001 10001000</span>
+
 
+
<span style="font-family: 'Courier New'; font-weight: bold; color: #000080;">18 00010010 01001000</span>
+
 
+
<span style="font-family: 'Courier New'; font-weight: bold; color: #000080;">19 00010011 11001000</span>
+
 
+
<span style="font-family: 'Courier New'; font-weight: bold; color: #000080;">20 00010100 00101000</span>
+
</div></div>
+
 
+
 
+
<br/>{{Languages}}
+
  
 
[[Category:BASCOM Language Reference]]
 
[[Category:BASCOM Language Reference]]

Latest revision as of 22:19, 17 January 2017

Contents

Action

Flips the bits in a byte.

 

 

Syntax

var = FLIP( s )

 

 

Remarks

Var

The variable that is assigned with the flipped byte S.

S

The source variable to flip.

 

The FLIP function can be useful in cases where you have reversed the data lines d0-d7.

It will reverse or mirror the bits

 

 

See also

NONE

 

 

Example

$regfile = "m88def.dat"
$crystal = 8000000
$baud = 19200
$hwstack=32
$swstack = 16
$framesize=24
 
Dim B As Byte , V As Byte
 
For B = 1 To 20
 V = Flip(b)
 Print B ; " " ; Bin(b) ; " " ; Bin(v)
Next
 
End

OUTPUT

1 00000001 10000000
2 00000010 01000000
3 00000011 11000000
4 00000100 00100000
5 00000101 10100000
6 00000110 01100000
7 00000111 11100000
8 00001000 00010000
9 00001001 10010000
10 00001010 01010000
11 00001011 11010000
12 00001100 00110000
13 00001101 10110000
14 00001110 01110000
15 00001111 11110000
16 00010000 00001000
17 00010001 10001000
18 00010010 01001000
19 00010011 11001000
20 00010100 00101000
Languages   English  
Personal tools
Namespaces
Variants
Actions
Navigation
Language