我不理解“无痛指南”第9和10节中的一些细节。

发布于 2025-01-22 13:42:20 字数 791 浏览 2 评论 0 原文

标题中提到的指南(从)完全帮助我掌握了CRC算法的原理和手动实现。在第9和第10节中,我击中了可能是小障碍的东西。

我在 9节中不了解的细节。在此部分中,桌子驱动的实现,其中消息字节被转移到右侧的登记册中(强调报价是我的):

•寄存器的顶部字节现在无关紧要。无论在接下来的8次迭代中,多次多次和以什么偏移构成了poly被固定到前8位。

•剩下的位将移动一个位置,并且寄存器的大多数字节将在下一个字节中移动

我认为我认为“右侧”应该在第一个子弹中“左侧”观点?

10节中。一个略微处理的桌子驱动实现, 关于处理要检查的消息末尾的零字节问题的问题,我对以下内容感到困惑:

您知道的问题是,此循环在增强消息上运行,为了使用此代码,您必须将 w/8 零字节附加到消息的末尾,然后p at。

这很明确(多项式具有宽度32),但是在随后的代码中,在本节中,作者使用w/4:

(i = 0; i< i< w/4; i ++) r =(r<< 8) ^ t [(r>> 24)& 0xff];

我认为这也应该有w/8?

The guide mentioned in the title (downloaded from http://ross.net/crc/download/crc_v3.txt) has perfectly helped me grasp the principle, and the manual implementation, of a CRC algorithm. In sections 9 and 10 I hit what probably are minor snags.

The detail I do not understand in section 9. A Table-Driven Implementation, where message bytes are shifted into a register from the right, is in this part (emphasis in quotations is mine):

• The top byte of the register now doesn't matter. No matter how many times and at what offset the poly is XORed to the top 8 bits, they will all be shifted out the right hand side during the next 8 iterations anyway.

• The remaining bits will be shifted left one position and the rightmost byte of the register will be shifted in the next byte

I would think "right hand side" should be "left hand side" in the first bullet point?

In section 10. A Slightly Mangled Table-Driven Implementation,
about dealing with the issue of appending zero bytes to the end of the message to be checked, I am confused by the following:

The trouble, you see, is that this loop operates upon the AUGMENTED message and in order to use this code, you have to append W/8 zero bytes to the end of the message before pointing p at it.

That is perfectly clear (the polynomial has width 32), but in the code that follows, and further down in the section, the author uses W/4:

for (i=0; i<W/4; i++) r = (r << 8) ^ t[(r >> 24) & 0xFF];

I would think that this should also have W/8?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

宁愿没拥抱 2025-01-29 13:42:20

该文本文件中有错别字。顶部字节很重要,因为每个非零位导致多项式被XOR XOR到寄存器,并且该点的位正在向左移动。 w/4应该是w/8,但在以后的示例代码中不使用它,即XOR的数据带有寄存器的顶部字节来索引表,deptermess len 是字节和增量的计数 p 是指向字节的指针:

r=0; while (len--) r = (r<<8) ^ t[(r >> 24) ^ *p++];

There are typos in that text file. The top byte matters, since each non-zero bit results in the polynomial being xor'ed to the register, and the bits at that point are being shifted to the left. W/4 should be W/8, but it's not used in the later example code that xor's data with the top byte of the register to index the table, decrements len which is a count of bytes and increments p which is a pointer to a byte:

r=0; while (len--) r = (r<<8) ^ t[(r >> 24) ^ *p++];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文