It is currently Sun May 19, 2019 10:18 pm

All times are UTC

Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: xmodem CRC checksum
PostPosted: Thu Apr 16, 2009 5:29 pm 

Joined: Wed Apr 01, 2009 5:09 pm
Posts: 18
Location: Calvary, Georgia
I am using hyper terminal to up load 68000 source code to th simulator vlumes and I can't get the CRC to match theri CRC. Do you have a CRC calculation program in 68000 assembler code?

 Post subject:
PostPosted: Fri Aug 13, 2010 4:45 pm 

Joined: Mon Jul 26, 2010 11:43 pm
Posts: 198
Location: Aurora, IL
Admittedly an old thread, but was tinkering with X-MODEM recently. This is a serial (bit wise) implementation. Typically I'd use a parallel table driven CRC method for speed but it has a bigger footprint.

start      moveq       #0,D0           ; Zero initial CRC for XMODEM
           lea         test,A0         ; Pointer to string
           move.w      #9,D1           ; Length of string
           bsr         CrcBlock        ; Compute CRC for block


test       DC.B "123456789" ; X-Modem CRC should be 0x31C3

; C Implementation of simple serial implementation
;  int i;
;  while(Size--) // Byte Loop
;  {
;    Crc ^= (WORD)*Buffer++ << 8;
;    for(i=0; i<8; i++) // Bit Loop
;      if (Crc & 0x8000) // Check for rollover
;        Crc = (Crc << 1) ^ 0x1021; // Apply feedback Polynomial
;      else
;        Crc = (Crc << 1);
;  }
;  return(Crc); // Return new CRC

; Reasonably efficient 68K implementation

; Input  D0 = Crc, D1 = Size, A0 = Buffer
; Uses   D1, D2, A0
; Return D0 = Crc
           or.w        D1,D1           ; Test for zero size
           beq         CrcBlock_40
           subq.w      #1,D1           ; Predecrement size for DBRA
           move.b      (A0)+,D2        ; Get next byte
           asl.w       #8,D2           ; move to high order byte within word
           eor.w       D2,D0           ; xor data into current CRC
           moveq       #7,D2           ; 8 bits in byte - 1 for DBRA
           asl.w       #1,D0           ; Shift CRC register
           bcc         CrcBlock_30     ; Check for high order bit rolling into carry
           eori.w      #$1021,D0       ; Apply feedback polynomial
           dbra        D2,CrcBlock_20  ; Bit loop
           dbra        D1,CrcBlock_10  ; Byte loop
           rts                         ; Return new CRC in D0

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC

Who is online

Users browsing this forum: No registered users and 4 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group