Skip to content

关于蒙哥马利简约实现 #3

Answered by emmansun
kingstenzzz asked this question in Q&A
Discussion options

You must be logged in to vote

我从第三个问题开始回答:

三,首先这个除R的约简是通过不断加上tmp2数组最右(低)字(word)乘P来达成的,一次循环乘两次,虽然都是乘P,但是top half乘的是29 28 29 28 ... 这样位宽表示的P {0x1fffffff, 0xfffffff, 0x7f, 0xffffc00, 0x1fffffff, 0xfffffff, 0x1fffffff, 0xeffffff, 0xfffffff},而bottom half是乘的28 29 28 29... 这样位宽表示的P {0xfffffff, 0x1fffffff, 0x7f, 0x1ffff800, 0xfffffff, 0x1fffffff, 0xfffffff, 0x1dffffff, 0xfffffff},之所以这样是为了和tmp2中的每个word的位宽保持一致,这样方便把乘法表示成加减和位移运算。

二, 就是x 要乘以 0x1ffff800,而0x1ffff800表示成2^29 - 2^11,这是bottom half中乘以P的第四个word。

一,这里的position是指的bit表示的起始位置,参考方法开始部分的注释。

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by emmansun
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1 on September 18, 2021 01:41.