; MP_BIT = 30
; MP_NAIL = 32 - MP_BIT
; MP_MASK = 3FFFFFFFh ;base 30bit 28~30
; mp_limb_t
; mpn_rshift (mp_ptr rp, mp_srcptr up, mp_size_t n, unsigned int cnt)
; assert (n >= 1);
; assert (cnt >= 1);
; assert (cnt < GMP_LIMB_BITS);
align 16
mpn_rshift:
label .cp dword at esp+4
label .ap dword at esp+8
label .n dword at esp+12
label .cnt dword at esp+16
label .tnc dword at esp-4
mov [esp-4 ],esi
mov [esp-8 ],edi
mov [esp-12],ebx
mov [esp-16],ebp
mov edi,[.cp]
mov esi,[.ap]
mov ebx,[.n]
mov ecx,[.cnt] ;4
mov [.tnc],MP_BIT ;30
sub [.tnc],ecx ;tnc=26
xor eax,eax
.loop:
mov ebp,[esi+ebx*4-4]
mov ecx,[.cnt]
mov edx,ebp
shr edx,cl
and edx,MP_MASK
or eax,edx
mov [edi+ebx*4-4],eax
mov eax,ebp
mov ecx,[.tnc]
shl eax,cl
and eax,MP_MASK
sub ebx,1
jnz .loop
shr eax,cl
mov esi,[esp-4 ]
mov edi,[esp-8 ]
mov ebx,[esp-12]
mov ebp,[esp-16]
ret 16
;---------------------------
; ==|== ==...== == == |====
; HSB LSB
;---------------------------
align 16
mpn_lshift:
label .cp dword at esp+4
label .ap dword at esp+8
label .n dword at esp+12
label .cnt dword at esp+16
label .tnc dword at esp-4
mov [esp-4 ],esi
mov [esp-8 ],edi
mov [esp-12],ebx
mov [esp-16],ebp
mov edi,[.cp]
mov esi,[.ap]
mov ebx,[.n]
mov ecx,[.cnt] ;4
mov [.tnc],MP_BIT ;30
sub [.tnc],ecx ;tnc=26
lea esi,[esi+ebx*4]
lea edi,[edi+ebx*4]
neg ebx
xor eax,eax
.loop:
mov ebp,[esi+ebx*4]
mov ecx,[.cnt] ;4
mov edx,ebp
shl edx,cl
or edx,eax
and edx,MP_MASK
mov eax,ebp
mov [edi+ebx*4],edx
mov ecx,[.tnc]
shr eax,cl
add ebx,1
jnz .loop
mov esi,[esp-4 ]
mov edi,[esp-8 ]
mov ebx,[esp-12]
mov ebp,[esp-16]
ret 16