
Zitat von
stardust19322
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
Lesezeichen