Servus!
Folgende Funktion is beim WinAVR als Inline Assembler dabei.
Da ich ein Ende der Funkbrücke von Benedikt K. mit Assembler
programmieren möchte, muss ich auch die CRC vom WinAVR für Assembler
umschreiben.
Sie schaut so aus:
Dass das _tmp_reg_ gleich r0 is und worin die Parameter stehn is mir
schon klar, doch wo steht der Rückgabewert __ret dann drinnen? In
crc1:crc0?
MfG
Stefan
Ja, hat sich erledigt. Es ist so, dass das Ergebnis in crc1:crc0
steht...
Die Routine vom ELM-Chan unten, die ich zuerst verwendete liefert ein
andres Ergebnis und braucht mehr Takte, obwohl auch CCITT dabeisteht.
Vielleicht hab ich sie auch nur falsch angewendet, aber es passt jetzt.
1
;-----------------------------------------------;
2
; Generate/Check CRC(-CCITT)
3
;
4
; Register Variables
5
; Call: crc[1:0] = CRC working register
6
; src = Source data to be checked
7
; lc,tmp[1:0] = <don't care> (high register must be allocated)
8
;
9
; Result:crc[1:0] = Updated
10
; src = 0
11
; lc,tmp[1:0] = broken
12
;
13
; Size = 12 words
14
; Clock = 66..74 cycles (+ret)
15
; Stack = 0 byte
16
;
17
; To generate a CRC:
18
; 1. Clear CRC working register.
19
; 2. Process all data bytes in the block.
20
; 3. Process two bytes of zero.
21
; 4. The CRC will be found in the working register.
22
; 5. Append crc1 and crc0 to the block data.
23
;
24
; To check block:
25
; 1. Clear CRC working register.
26
; 2. Process all data bytes in the block and following CRCs.
27
; 3. The block is correct if the working register is zero.