64 비트 곱셈의 x86 어셈블리에서 구현과 관련하여 질문이 있습니다. 내가 이해할 수있는 한 코드를 게시했습니다. 나는 나머지가하는 일을 잃어 버렸다. (이미 내가 한 일에 실수를 범할 수도있다.) 어떤 방향으로도 감사하겠습니다.어셈블리 : 32 비트 레지스터로 64 비트 곱하기
dest at %ebp+8
x at %ebp+12
y at %ebp+16
movl 16(%ebp), %esi //Move y into %esi
movl 12(%ebp), %eax //Move x into %eax
movl %eax, %edx //Move x into %edx
sarl $31, %edx //Shift x right 31 bits (only sign bit remains)
movl 20(%ebp), %ecx //Move the low order bits of y into %ecx
imull %eax, %ecx //Multiply the contents of %ecx (low order bits of y) by x
movl %edx, %ebx //Copy sign bit of x to ebx
imull %esi, %ebx //Multiply sign bit of x in ebx by high order bits of y
addl %ebx, %ecx //Add the signed upper order bits of y to the lower order bits (What happens when this overflows?)
mull %esi //Multiply the contents of eax (x) by y
leal (%ecx,%edx), %edx
movl 8(%ebp), %ecx
movl %eax, (%ecx)
movl %edx, 4(%ecx)
정말 64 비트 곱셈으로 계산하지 않습니다이 32 비트 값을 곱. y가 64 비트 값이 아니라면 결과를 64 비트 위치로 가지지 않고 (dest는 32 비트 임) 20 비트 (% ebp)에서 long을 이동하면 y 비트가 이동합니다. ... –
부호있는 32 비트 정수와 부호있는 64 비트 정수를 곱하여 부호있는 64 비트 결과를 생성합니다. 기본 2^32의 용지에서 작업 해보십시오. –