Hallo ans Forum.
Da ich mir das auch selber immer wünsche hier der fertige und vor allem laufende Code mit Anmerkungen

Code:
$regfile = "m88def.dat"
$hwstack = 128
$framesize = 128
$swstack = 128

Config Timer1 = Timer , Prescale = 8
Config Timer0 = Timer , Prescale = 1024

'Die Sensoren sollen auf Masse-Kontakt auslösen
Config Int0 = Falling
Config Int1 = Falling

'Auf Sensoren anspringen
On Int0 Ges                                       'Geschwindigkeit
On Int1 Dre                                       'Drehzahl

'Auf Timer-Überläufe anspringen
On Timer1 Timer1_irq
On Timer0 Timer0_irq

'Den ganzen Kram anschalten
Enable Int0
Enable Int1
Enable Timer1
Enable Timer0
Enable Interrupts

'Ports configurieren
Config Sda = Portc.4
Config Scl = Portc.5
Config Portd.2 = Input
Config Portd.3 = Input
Config Portd.5 = Output
Config Portd.6 = Output
Config Portd.7 = Output
Config Portb = Output

Pind.2 = 1
Pind.3 = 1

'Variablen festlegen
Dim C1 As Byte
Dim C0 As Byte
Dim G_pre As Long
Dim G_set As Long
Dim G_out As Long
Dim G_out_2 As Long
Dim G_out_3 As Long
Dim G_out_calc As Single

Dim D_pre As Long
Dim D_set As Long
Dim D_out As Long
Dim D_out_2 As Long

Dim Zehner As Byte
Dim Einer As Byte


C1 = 0
C0 = 0
Do
      'Abwägung, wieviele LED's je nach Drehzahl leuchten sollen
      Select Case D_out_2
         Case Is < 146                            '>7000
              Portb = &B111111XX
              Portd.7 = 1
              Portd.6 = 1
              Portd.5 = 1

         Case Is < 170                            '>6000
              Portb = &B111111XX
              Portd.7 = 1
              Portd.6 = 1
              Portd.5 = 0

         Case Is < 205                            '>5000
              Portb = &B111111XX
              Portd.7 = 1
              Portd.6 = 0
              Portd.5 = 0

         Case Is < 255                            '>4000
              Portb = &B111111XX
              Portd.7 = 0
              Portd.6 = 0
              Portd.5 = 0

         Case Is < 340                            '>3000
              Portb = &B111110XX
              Portd.7 = 0
              Portd.6 = 0
              Portd.5 = 0

         Case Is < 510                            '>2000
              Portb = &B111100XX
              Portd.7 = 0
              Portd.6 = 0
              Portd.5 = 0

         Case Is < 1020                           '>1000
              Portb = &B111000XX
              Portd.7 = 0
              Portd.6 = 0
              Portd.5 = 0

         Case Is < 1360                           '>750
              Portb = &B110000XX
              Portd.7 = 0
              Portd.6 = 0
              Portd.5 = 0

         Case Is < 2030                           '>500
              Portb = &B100000XX
              Portd.7 = 0
              Portd.6 = 0
              Portd.5 = 0

         Case Else
              Portb = &B000000XX
              Portd.7 = 0
              Portd.6 = 0
              Portd.5 = 0

       End Select


      'Berechnungen der Geschwindigkeit und Ausgabe über I2C
      'an einen MAX6958.

      If G_out_2 < 1000000 Then
         G_out_calc = 1 / G_out_2
         G_out_calc = G_out_calc * 1473081
         G_out_3 = G_out_calc
      Else
          G_out_3 = 0
      End If

      Zehner = G_out_3 / 10
      Zehner = Zehner Mod 10
      Einer = G_out_3 Mod 10

      I2cstart
      I2cwbyte &B01110000                         'Chip-Adresse
      I2cwbyte &B00000001                         'Erste Adresse (Autoincr.)
      I2cwbyte &B00000011                         'decode
      I2cwbyte &B00001000                         'helligkeit
      I2cwbyte &B00000011                         'scan limit
      I2cwbyte &B00000001                         'nomal Operation
      I2cstop

      I2cstart
      I2cwbyte &B01110000
      I2cwbyte &B00100000                         'Adresse
      I2cwbyte Zehner                             'Zehner
      I2cwbyte Einer                              'Einer
      I2cstop

      'Um bei den langen Intervallen der Geschwindigkeitsmessung
      'auch geringe messen zu können, lass ich den 16bit Timer ziemlich
      'schnell durchlaufen und dafür mehrmals (100x) durchlaufen
      'und multipiziere mit C1.

      'Der 8bit Timer sorgt in regelmäßigen Abständen dafür, dass bei
      'Ergebnislosigkeit der Interupts die Zehler wieder als Ergebnis 0
      'anzeigen

      If C1 = 100 Then C1 = 0
      If C0 = 50 Then
         G_out_2 = 1000000
         D_out_2 = 2500
         C0 = 0
      End If

Loop

'Geschwindigkeit INT
Ges:
    G_out = G_set - G_pre
    G_pre = G_set
    G_set = C1 * 65535
    G_set = G_set + Timer1
    If G_out > 0 Then G_out_2 = G_out
Return

'Drehzahl INT
Dre:
    D_out = D_set - D_pre
    D_pre = D_set
    D_set = C1 * 65535
    D_set = D_set + Timer1
    If D_out > 0 Then D_out_2 = D_out
Return

'Überlauf 16bit Timer
Timer1_irq:
   C1 = C1 + 1
Return

'Überlauf 8bit Timer
Timer0_irq:
   C0 = C0 + 1
Return


End