Hallo, ich versuche das Igorplug Ethernet Modul zu modifizieren. Dabei will ich die Berechnung der CRC32-Prüfsumme, die bisher als Makro im Assembler abläuft, nun im Betrieb durchführen. Es geht um dieses Segment: .set CRC32init= 0xFFFFFFFF ; .set CRC32polyInv= 0xEDB88320 ;CRC32 polynom (0x04C11DB7) in inverted bits order .set CRC32 = CRC32init ;initialisation of CRC32 .set Message= MACDestAddr5 ;load message byte ;bit0 of message calculation .if ((CRC32^(Message))&1) ;if xor of CRC32[MSB] and Message[LSB] is one (note: CRC32 has now inverted bit order) .set CRC32=((CRC32>>1)^CRC32polyInv);shift the CRC and make xor with polynom .else ;if not .set CRC32= (CRC32>>1) ;only shift the CRC .endif .set Message=(Message>>1) ;go to next bit in Message ;bit1 of message calculation .if ((CRC32^(Message))&1) ;if xor of CRC32[MSB] and Message[LSB] is one (note: CRC32 has now inverted bit order) .set CRC32=((CRC32>>1)^CRC32polyInv) ;shift the CRC and make xor with polynom .else ;if not .set CRC32= (CRC32>>1) ;only shift the CRC .endif .set Message=(Message>>1) ;go to next bit in Message ;bit2 of message calculation .if ((CRC32^(Message))&1) ;if xor of CRC32[MSB] and Message[LSB] is one (note: CRC32 has now inverted bit order) .set CRC32=((CRC32>>1)^CRC32polyInv) ;shift the CRC and make xor with polynom .else ;if not .set CRC32= (CRC32>>1) ;only shift the CRC .endif .set Message=(Message>>1) ;go to next bit in Message ;bit3 of message calculation .if ((CRC32^(Message))&1) ;if xor of CRC32[MSB] and Message[LSB] is one (note: CRC32 has now inverted bit order) .set CRC32=((CRC32>>1)^CRC32polyInv) ;shift the CRC and make xor with polynom .else ;if not .set CRC32= (CRC32>>1) ;only shift the CRC .endif .set Message=(Message>>1) ;go to next bit in Message ;bit4 of message calculation .if ((CRC32^(Message))&1) ;if xor of CRC32[MSB] and Message[LSB] is one (note: CRC32 has now inverted bit order) .set CRC32=((CRC32>>1)^CRC32polyInv) ;shift the CRC and make xor with polynom .else ;if not .set CRC32= (CRC32>>1) ;only shift the CRC .endif .set Message=(Message>>1) ;go to next bit in Message ;bit5 of message calculation .if ((CRC32^(Message))&1) ;if xor of CRC32[MSB] and Message[LSB] is one (note: CRC32 has now inverted bit order) .set CRC32=((CRC32>>1)^CRC32polyInv) ;shift the CRC and make xor with polynom .else ;if not .set CRC32= (CRC32>>1) ;only shift the CRC .endif .set Message=(Message>>1) ;go to next bit in Message ;bit6 of message calculation .if ((CRC32^(Message))&1) ;if xor of CRC32[MSB] and Message[LSB] is one (note: CRC32 has now inverted bit order) .set CRC32=((CRC32>>1)^CRC32polyInv) ;shift the CRC and make xor with polynom .else ;if not .set CRC32= (CRC32>>1) ;only shift the CRC .endif .set Message=(Message>>1) ;go to next bit in Message ;bit7 of message calculation .if ((CRC32^(Message))&1) ;if xor of CRC32[MSB] and Message[LSB] is one (note: CRC32 has now inverted bit order) .set CRC32=((CRC32>>1)^CRC32polyInv) ;shift the CRC and make xor with polynom .else ;if not .set CRC32= (CRC32>>1) ;only shift the CRC .endif .set Message=(Message>>1) ;go to next bit in Message ;end of one byte CRC processing Ich habe das so übersetzt: ;.set CRC32init= 0xFFFFFFFF ; ;.set CRC32polyInv= 0xEDB88320 ;CRC32 polynom (0x04C11DB7) in inverted bits order ;.set CRC32 = CRC32init ;initialisation of CRC32 ;crc32x schiebt ein Byte durch den CRC ;r17 = Byte Message ;r18 = benutzt ;r16 = benutzt crc32x: ldi r18,8 crc32x2: mov r16,crc324 eor r16,r17 ; CRC32^Message lsr crc321 ; CRC32>>1 ror crc322 ror crc323 ror crc324 ; .if ((CRC32^(Message))&1) andi r16,1 breq crc32x1 ; .set CRC32=((CRC32>>1)^CRC32polyInv) eor crc321,poly1 eor crc322,poly2 eor crc323,poly3 eor crc324,poly4 crc32x1: ; .else ; .set CRC32= (CRC32>>1) ; .endif ; .set Message=(Message>>1) lsr r17 dec r18 ;dec bit counter brne crc32x2 ret crc32asm: ldi crc321, 0xff ldi crc322, 0xff ldi crc323, 0xff ldi crc324, 0xff ldi poly1,0xED ldi poly2,0xB8 ldi poly3,0x83 ldi poly4,0x20 ldi r17,MACDestAddr5 rcall crc32x ... Es kommt aber nur Käse dabei raus. Ich sehe den Wald vor lauter Bäumen nicht. Kann jemand helfen?
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.