- 12V Akku mit 280 Ah bauen         
Ergebnis 1 bis 10 von 27

Thema: Einfache Schreibweise einer 5-Bit Wahrheitstabelle

Baum-Darstellung

Vorheriger Beitrag Vorheriger Beitrag   Nächster Beitrag Nächster Beitrag
  1. #3
    Erfahrener Benutzer Robotik Einstein Avatar von Searcher
    Registriert seit
    07.06.2009
    Ort
    NRW
    Beiträge
    1.715
    Blog-Einträge
    133
    Zitat Zitat von stardust19322 Beitrag anzeigen
    Gibt es in Bascom eine (einfache) Möglichkeit, massiv Code einzusparen?
    Ich glaub ich würd es so machen:
    Code:
    $regfile = "ATtiny44.DAT"
    $hwstack = 32
    $swstack = 32
    $framesize = 32
    $crystal = 8000000
    
    Dim Bit1 As Bit
    Dim Bit2 As Bit
    Dim Bit3 As Bit
    Dim Bit4 As Bit
    Dim Bit5 As Bit
    
    Dim Bit_pattern As Byte
    Dim Programmwahl As Byte
    
    Bit_pattern = 0
    Bit_pattern.0 = Bit1
    Bit_pattern.1 = Bit2
    Bit_pattern.2 = Bit3
    Bit_pattern.3 = Bit4
    Bit_pattern.4 = Bit5
    
    Select Case Bit_pattern
      Case &B00001 : Programmwahl = 1                           '  00001
      Case &B00010 : Programmwahl = 2                           '  00010
      Case &B00011 : Programmwahl = 3                           '  00011
      Case &B00100 : Programmwahl = 4                           '  00100
      Case &B00101 : Programmwahl = 5                           '  00101
      Case &B00110 : Programmwahl = 6                           '  00110
      Case &B00111 : Programmwahl = 7                           '  00111
      Case &B01000 : Programmwahl = 8                           '  01000
      Case &B01001 : Programmwahl = 9                           '  01001
      Case &B01010 : Programmwahl = 10                          '  01010
      Case &B01011 : Programmwahl = 11                          '  01011
      Case &B01100 : Programmwahl = 12                          '  01100
      Case &B01101 : Programmwahl = 13                          '  01101
      Case &B01110 : Programmwahl = 14                          '  01110
      Case &B01111 : Programmwahl = 15                          '  01111
      Case &B10000 : Programmwahl = 16                          '  10000
      Case &B10001 : Programmwahl = 17                          '  10001
      Case &B10010 : Programmwahl = 18                          '  10010
      Case &B10011 : Programmwahl = 19                          '  10011
      Case &B10100 : Programmwahl = 20                          '  10100
      Case &B10101 : Programmwahl = 21                          '  10101
      Case &B10110 : Programmwahl = 22                          '  10110
      Case &B10111 : Programmwahl = 23                          '  10111
      Case &B11000 : Programmwahl = 24                          '  11000
      Case &B11001 : Programmwahl = 25                          '  11001
      Case &B11010 : Programmwahl = 26                          '  11010
      Case &B11011 : Programmwahl = 27                          '  11011
      Case &B11100 : Programmwahl = 28                          '  11100
      Case &B11101 : Programmwahl = 29                          '  11101
      Case &B11110 : Programmwahl = 30                          '  11110
    End Select
    
    End                                                         'end program
    Spart etwa 2kB und mehr im Romimage.

    [Edit] Oder wenn die Bitx in Bitpattern sind, dann nur "Programmwahl = Bit_pattern" (wahrscheinlich das, was Malty meint).[/Edit]

    Gruß
    Searcher
    Geändert von Searcher (13.12.2014 um 12:24 Uhr)
    Hoffentlich liegt das Ziel auch am Weg
    ..................................................................Der Weg zu einigen meiner Konstruktionen

Ähnliche Themen

  1. Kurze Schreibweise bei If- Bedingung in Bascom?
    Von rylix im Forum Basic-Programmierung (Bascom-Compiler)
    Antworten: 6
    Letzter Beitrag: 17.06.2011, 16:58
  2. Ersten 8 bit einer 32 bit Zahl auslesen
    Von C_Classic im Forum C - Programmierung (GCC u.a.)
    Antworten: 15
    Letzter Beitrag: 23.05.2010, 00:06
  3. TTL Logik Wahrheitstabelle
    Von Micha.Berlin im Forum Elektronik
    Antworten: 5
    Letzter Beitrag: 26.05.2008, 22:32
  4. Ein bestimmtes Bit einer Variable überschreiben
    Von Dane im Forum Basic-Programmierung (Bascom-Compiler)
    Antworten: 3
    Letzter Beitrag: 15.04.2006, 14:00
  5. Antworten: 5
    Letzter Beitrag: 30.06.2005, 16:51

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •  

LiFePO4 Speicher Test