Hallo Mitch,

Zitat Zitat von Mitch64 Beitrag anzeigen
Code:
'  Lauffähiges Testprogramm für Simulator
'  zur Veranschaulichung des Problems

   $regfile = "m8def.dat"
   $hwstack = 30
   $Swstack = 30
   $framesize = 35
   $Crystal = 8000000
   $Baud = 19200

   $Sim


'  Allgemeine Deklarationen
   Const True = 1
   Const False = 0
   Const LowLevel = 0                                       ' Tastenpegel Low
   Const HighLevel = 1                                      ' Tastenpegel High

   dim Funktions_wert as byte

   Key_Taste Alias PinB.1                                   ' Abzufragende Taste/Pin
   Set Key_Taste                                            ' PullUp an

   Declare Function getKeyTaste(Byval Level as Byte) as Byte

   Do
      ' Irgendwo in der Hauptschleife
      ' Die Abfrage der Taste

      Funktions_wert = getKeyTaste(LowLevel)
      If Funktions_wert = True then                  ' Taste ist Low-Aktiv

'      If getKeyTaste(LowLevel) = True then                  ' Taste ist Low-Aktiv

         Print "gedrueckt"
      Else
         Print "nicht gedrückt"
      End If
   Loop

'  Die Function liefert immer True (taste gedrückt)
   Function getKeyTaste(Byval Level as Byte) as Byte
      getKeyTaste = False                                   ' Rückgabewert zunächst auf falsch (Taste nicht gedrückt)
      If Key_Taste = Level.0 then                           ' Pinpegel = Vorgabepegel?
         Waitms 30                                          ' Entprelldauer abwarten
         If Key_Taste = Level.0 then                        ' Pinpegel noch immer = Vorgabepegel?
            getKeyTaste = True                              ' Rückgabewert True (Taste aktiv gedrückt)
         End If
      End If
   End Function
Kann mir jemand sagen, ob das ein Bug ist?
Keine Ahnung ob man das als Bug bezeichnen kann. In der Bascom Hilfe zu Function wird drauf hingewiesen:

Zitat Zitat von Bascom Hilfe
If you execute other code after you assigned the function result, registers will be trashed. This is no problem if you assigned the function result to a variable. But when you use a function without assigning it to a variable, some temporarily registers are used which might be trashed.

Thus this special attention is only needed when you use the function like :
If Myfunc()=3 then 'myfunc is not assigned to a variable but the result is needed for the test

When you use :
myvar=Myfunc()
Then you will not trash the registers. So in such a case there is no problem to run code after the function assignment.
Mit Hinzufügen der grünen Zeilen und Entfernen der roten Zeilen funktionierts im Simulator. Bei $crystal fehlt glaub ich noch 'ne Null bei Dir?

Gruß
Searcher