MAX/de

From MCS Wiki AVR
< MAX(Difference between revisions)
Jump to: navigation, search
(Created page with "= <span class="f_Header">Action</span> = Returns the maximum value of a byte or word array. <span style="font-family: Arial;"> </span> <span style="font-family: Arial;...")
 
(Anmerkungen)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== (**COPIED FROM ENGLISH PAGE**) === <span class="f_Header">Action</span> =
+
= <span class="f_Header">Funktion</span> =
  
Returns the maximum value of a byte or word array.
+
Gibt den Maximum-Wert eines Byte- oder Word-Arrays zurück.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 17: Line 17:
 
<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="597" cellspacing="0" cellpadding="1" border="1" style="border: 2px solid rgb(0, 0, 0); border-spacing: 0px; border-collapse: collapse;"
 
{| width="597" cellspacing="0" cellpadding="1" border="1" style="border: 2px solid rgb(0, 0, 0); border-spacing: 0px; border-collapse: collapse;"
Line 25: Line 25:
  
 
| valign="top" width="100%" style="width: 520px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 520px; border: 1px solid rgb(0, 0, 0);" |  
Variable that will be assigned with the maximum value.
+
Variable der der Maximum-Wert zugewiesen wird.
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
Line 32: Line 32:
  
 
| valign="top" width="100%" style="width: 520px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 520px; border: 1px solid rgb(0, 0, 0);" |  
The first address of the array.
+
Startadresse des Arrays.
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
Line 46: Line 46:
  
 
| valign="top" width="100%" style="width: 520px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 520px; border: 1px solid rgb(0, 0, 0);" |  
The MAX statement can return the index too
+
Der MAX-Befehl kann auch den Indes zurückgeben
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
 
| valign="top" width="12%" style="width: 68px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="12%" style="width: 68px; border: 1px solid rgb(0, 0, 0);" |  
Ar(1)
+
ar(1)
  
 
| valign="top" width="100%" style="width: 520px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 520px; border: 1px solid rgb(0, 0, 0);" |  
Starting element to get the maximum value and index of.
+
Startadresse des Arrays von dem das Maximum bestimmt werden soll.
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
 
| valign="top" width="12%" style="width: 68px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="12%" style="width: 68px; border: 1px solid rgb(0, 0, 0);" |  
M
+
m
  
 
| valign="top" width="100%" style="width: 520px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 520px; border: 1px solid rgb(0, 0, 0);" |  
Returns the maximum value of the array.
+
Gibt den Maximum-Wert des Arrays zurück.
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
 
| valign="top" width="12%" style="width: 68px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="12%" style="width: 68px; border: 1px solid rgb(0, 0, 0);" |  
Idx
+
idx
  
 
| valign="top" width="100%" style="width: 520px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 520px; border: 1px solid rgb(0, 0, 0);" |  
Return the index of the array that contains the maximum value. Returns 0 if there is no maximum value.
+
Gibt den Index des Arrayelementes mit dem größten Wert zurück. Gibt eine 0 zurück wenn es mein Maximum gibt.
  
 
|}
 
|}
Line 73: Line 73:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
The MIN() and MAX() functions work on BYTE and WORD arrays only.
+
Die MIN() und MAX() Funktionen funktionieren nur mit BYTE- und WORD-Arrays.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 79: Line 79:
 
<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> =
  
 
[[MIN]]
 
[[MIN]]
Line 87: Line 87:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
= <span class="f_Header">Example</span> =
+
= <span class="f_Header">Beispiel</span> =
  
 
<br/><source lang="bascomavr">
 
<br/><source lang="bascomavr">
Line 99: Line 99:
 
'-----------------------------------------------------------------------------------------
 
'-----------------------------------------------------------------------------------------
 
   
 
   
$regfile = "m48def.dat" ' specify the used micro
+
$regfile = "m48def.dat" ' Mikrocontroller
$crystal = 4000000 ' used crystal frequency
+
$crystal = 4000000 ' Taktfrequenz
$baud = 19200 ' use baud rate
+
$baud = 19200 ' Baudrate
 
$hwstack = 32 ' default use 32 for the hardware stack
 
$hwstack = 32 ' default use 32 for the hardware stack
 
$swstack = 10 ' default use 10 for the SW stack
 
$swstack = 10 ' default use 10 for the SW stack
Line 107: Line 107:
 
   
 
   
 
   
 
   
' These functions only works on BYTE and WORD arrays at the moment !!!!!
+
' Diese Funktionen arbeiten nur mit BYTE- und WORD-Arrays !!!!!
 
   
 
   
 
'Dim some variables
 
'Dim some variables
 
Dim Wb As Byte , B As Byte
 
Dim Wb As Byte , B As Byte
Dim W(10) As Word ' or use a BYTE array
+
Dim W(10) As Word ' oder benutzen Sie ein Byte-Array
 
   
 
   
'fill the word array with values from 1 to 10
+
'Füllen des Word-Arrays mit Werten von 1 bis 10
 
For B = 1 To 10
 
For B = 1 To 10
 
W(b) = B
 
W(b) = B

Latest revision as of 01:33, 10 March 2013

Contents

Funktion

Gibt den Maximum-Wert eines Byte- oder Word-Arrays zurück.

 

 

Syntax

var1 = MAX(var2)

MAX(ar(1), m ,idx)

 

 

Anmerkungen

var1

Variable der der Maximum-Wert zugewiesen wird.

var2

Startadresse des Arrays.

 

 

 

Der MAX-Befehl kann auch den Indes zurückgeben

ar(1)

Startadresse des Arrays von dem das Maximum bestimmt werden soll.

m

Gibt den Maximum-Wert des Arrays zurück.

idx

Gibt den Index des Arrayelementes mit dem größten Wert zurück. Gibt eine 0 zurück wenn es mein Maximum gibt.

 

Die MIN() und MAX() Funktionen funktionieren nur mit BYTE- und WORD-Arrays.

 

 

Siehe auch

MIN

 

 

Beispiel


'-----------------------------------------------------------------------------------------
'name : minmax.bas
'copyright : (c) 1995-2005, MCS Electronics
'purpose : show the MIN and MAX functions
'micro : Mega48
'suited for demo : yes
'commercial addon needed : no
'-----------------------------------------------------------------------------------------
 
$regfile = "m48def.dat" ' Mikrocontroller
$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
 
 
' Diese Funktionen arbeiten nur mit BYTE- und WORD-Arrays !!!!!
 
'Dim some variables
Dim Wb As Byte , B As Byte
Dim W(10) As Word ' oder benutzen Sie ein Byte-Array
 
'Füllen des Word-Arrays mit Werten von 1 bis 10
For B = 1 To 10
W(b) = B
Next
 
Print "Max number " ; Max(w(1))
Print "Min number " ; Min(w(1))
 
Dim Idx As Word , M1 As Word
Min(w(1) , M1 , Idx)
Print "Min number " ; M1 ; " index " ; Idx
 
Max(w(1) , M1 , Idx)
Print "Max number " ; M1 ; " index " ; Idx
End

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