CLS Def %CRC8POLY $18' 0X18 = X^8+X^5+X^4+X^0 Var CRC8_Sp% = 0' CRC8 memory proc CRC8_berechnen Parameters crc_data%' Übergabe data Var bit_counter% = 8' Schleifendurchlauf Var feedback_bit% = 0' bit Return while bit_counter% > 0' 8x Durchläufe feedback_bit% = Xor(CRC8_Sp%,crc_data%) & $01' XOR on 1 to check on if feedback_bit% = $01' if 1, then... CRC8_Sp% = Xor(CRC8_Sp%,%CRC8POLY)' XOR with Poly EndIf CRC8_Sp% = (CRC8_Sp% >> 1) & $7F' Invoice values right & 247 if feedback_bit% = $01' if 1, then... CRC8_Sp% = CRC8_Sp% | $80' ODER 128 EndIf crc_data% = crc_data% >> 1' data Invoice values right Dec bit_counter%' Schleifendurchlauf -1 EndWhile' end Endlosschleife endproc ' Test appeal CRC8_Sp% = 0' Reset CRC8 memory WhileLoop 0,255' Chr$(0) To Chr$(255) go through CRC8_berechnen(&Loop)' CRC to charge Print "Daten="+Str $(&Loop)+" CRC8="+Str $(CRC8_Sp%), CRC8_berechnen( val( "%"+right$("00000000"+be$(&Loop),8)+right$("00000000"+be$(CRC8_Sp%),8) ) ) Print tab(40);Str $(CRC8_Sp%) EndWhile waitinput
Session-Cookies