I am newbie to Assembly coding.
I have the below C code
<code>#define X 8380417
#define INV 0x3802001
int32_t reduce(int64_t a) {
int32_t t;
t = (int64_t)(int32_t)a*INV;
t = (a - (int64_t)t*X) >> 32;
return t;
</code>
<code>#define X 8380417
#define INV 0x3802001
int32_t reduce(int64_t a) {
int32_t t;
t = (int64_t)(int32_t)a*INV;
t = (a - (int64_t)t*X) >> 32;
return t;
</code>
#define X 8380417
#define INV 0x3802001
int32_t reduce(int64_t a) {
int32_t t;
t = (int64_t)(int32_t)a*INV;
t = (a - (int64_t)t*X) >> 32;
return t;
}
The assembly generated for the same looks as below for ppc
<code>lis 9,0xff80
ori 8,8,8193
ori 9,9,8191
mullw 8,8,4
mulhw 10,8,9
mullw 11,8,9
addc 4,4,11
adde 3,3,10
blr
</code>
<code>lis 9,0xff80
ori 8,8,8193
ori 9,9,8191
mullw 8,8,4
mulhw 10,8,9
mullw 11,8,9
addc 4,4,11
adde 3,3,10
blr
</code>
lis 9,0xff80
ori 8,8,8193
ori 9,9,8191
mullw 8,8,4
mulhw 10,8,9
mullw 11,8,9
addc 4,4,11
adde 3,3,10
blr
I understand [lis 8,0×380 + ori 8,8,8193] = placing QINV in R8
mullw 8,8,4 = multiply last 32 bits of QINV by a -> higher bits of R8 after this still holds 0x380 ?
But how is Q = 8380417 = ff801fff in R9 and then the rest of steps done like adding instead of subtraction?
New contributor
Gappu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.