zoukankan      html  css  js  c++  java
  • 4.0 Lab1-CRC Generation(1)

    Although I haven't finished the whole lab yet, I'm going to write something I've done till this moment.

    -------------------- Part of The Requirements of This Lab------------------------

    1. Load a 16-bit register with FFFF hex (all ‘1’s). Call this the CRC register.

    2. Exclusive OR the first 8-bit byte of the message with the low-order byte of the 16-bit CRC register, putting the result in the CRC register.

    3. Shift the CRC register one bit to the right (toward the LSb), zero-filling the MSb. Extract and examine the LSb.

    4. If the LSb is ‘0’, repeat Step 3 (another shift). Otherwise, if the LSB is ‘1’, Exclusive OR the CRC register with the polynomial value 0xA001 (1010 0000 0000 0001).

    5. Repeat steps 3 and 4 until eight shifts have been performed. When this is done, a complete 8-bit byte will have been processed.

    6. Repeat steps 2 through 5 for the next 8-bit byte of the message. Continue doing this until all bytes have been processed.

    7. The final content of the CRC register is the CRC value.

    8. When the CRC is placed into the message, its upper and lower bytes must be Swapped to let the High 8-bit first and followed by low 8-bit.

    ----------------------Part of My Codes----------------------

      

    //read message from test.txt file

      

    //read a byte of file once to message

      

    //use an array of byte CRCRegister to store 0xFFFF

      

    //shift 8 times once read a byte. EX or with 0xA001 if lsb is 1 while shifting

      

    //one byte has 8 bits, however, if the MSB of the byte is 0, it won't be shown. So I use switch statements to show these 0s.

      

    //combine 2 bytes of the CRCRegister together, and output the result

    -----------------------END & TO BE CONTINUED-------------------------

  • 相关阅读:
    Hibernate4究竟怎么玩目录
    Hibernate检索策略之5.2多对一单向关联检索策略——Hibernate4究竟怎么玩
    Struts2 OGNL表达式中调用java静态方法无效的解决办法
    JDBC API中的execute返回值问题
    Hibernate检索策略之5.1类级别检索策略——Hibernate4究竟怎么玩
    PowerDesigner逆向工程mysql
    三种批量增加的性能分析
    Apache FtpServer的使用
    杭电1013
    杭电1008
  • 原文地址:https://www.cnblogs.com/lyli/p/4396328.html
Copyright © 2011-2022 走看看