**I don't understand the value in the register R10, in my code python I have 0xa0a00000 and in the device(stm32 I have 0xfd090000 the value of tmp2 after Montgomery reduction) can someone help me please**
the code arm
.syntax unified
.cpu cortex-m4
.thumb
.macro montgomery q, qinv, a, tmp
smulbt tmp, a, qinv
smlabb tmp, q, tmp, a
.endm
.global doublebasemul_asm
.type doublebasemul_asm, %function
.align 2
doublebasemul_asm:
push {r4-r11, lr}
rptr .req r0
aptr .req r1
bptr .req r2
zeta .req r3
poly0 .req r4
poly1 .req r6
poly2 .req r5
poly3 .req r7
q .req r8
qinv .req r8
tmp .req r9
tmp2 .req r10
tmp3 .req r11
movw q, #3329
movt qinv, #3327
ldrd poly0, poly2, [aptr], #8
ldrd poly1, poly3, [bptr], #8
//basemul(r->coeffs + 4 * i, a->coeffs + 4 * i, b->coeffs + 4 * i, zetas[64 + i]);
smultt tmp, poly0, poly1
//montgomery q, qinv, tmp, tmp2 for debug …
/.macro montgomery q, qinv, a, tmp
smulbt tmp, a, qinv
smlabb tmp, q, tmp, a
.endm/
smulbt tmp2, tmp, qinv
smlabb tmp2, q, tmp2, tmp
smultb tmp2, tmp2, zeta
smlabb tmp2, poly0, poly1, tmp2
montgomery q, qinv, tmp2, tmp
// r[0] in upper half of tmp
smuadx tmp2, poly0, poly1
montgomery q, qinv, tmp2, tmp3
// r[1] in upper half of tmp3
pkhtb tmp, tmp3, tmp, asr#16
str tmp, [rptr], #4
neg zeta, zeta
//basemul(r->coeffs + 4 * i + 2, a->coeffs + 4 * i + 2, b->coeffs + 4 * i + 2, – zetas[64 + i]);
smultt tmp, poly2, poly3
montgomery q, qinv, tmp, tmp2
smultb tmp2, tmp2, zeta
smlabb tmp2, poly2, poly3, tmp2
montgomery q, qinv, tmp2, tmp
// r[0] in upper half of tmp
smuadx tmp2, poly2, poly3
montgomery q, qinv, tmp2, tmp3
// r[1] in upper half of tmp3
pkhtb tmp, tmp3, tmp, asr#16
str tmp, [rptr], #4
pop {r4-r11, pc}
With input :
>poly0_r4 = 0x081E0189
>poly1_r6 = 0x07E90C5A
>poly2_r5 = 0x0C110BC5
>poly3_r7 = 0x04F10819
>hex_zeta = 0x000008b2
q = 3329, q_inv = 3327
First zeta = 2226
and I have
first s0 x u0 = [1002, -905]
second s0 x u0 = [926, -990]
I don't understand how these values are calculated ...
mbaye ngom is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.