MIN/de
From MCS Wiki AVR
< MIN
Revision as of 01:15, 10 March 2013 by Stefanhamburg (Talk | contribs)
Contents |
Funktion
Gibt den Minimum-Wert eines Byte- oder Word-Arrays zurück.
Syntax
var1 = MIN(var2)
MIN(ar(1), m , idx)
Anmerkungen
var1 |
Variable, der der Minimum-Wert zugewiesen wird. |
var2 |
Startadresse des Arrays. |
|
|
|
Der MIN-Befehl kann auch den Index zurückgeben |
ar(1) |
Startadresse des Arrays aus den das Minimum gesucht werden soll. |
m |
Returns the minimum value of the array |
idx |
Gibt den Index des Array-Elementes mit dem Minimum-Wert zurück. Gibt 0 zurück wenn es kein Minumum gibt. |
Die MIN() und MAX() Funktionen arbeiten nur mit BYTE- und WORD-Arrays.
Siehe auch
Example
'----------------------------------------------------------------------------------------- '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" ' 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 ' These functions only works on BYTE and WORD arrays at the moment !!!!! 'Dim some variables Dim Wb As Byte , B As Byte Dim W(10) As Word ' or use a BYTE array 'fill the word array with values from 1 to 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 |
---|