나는 미쳐 가고있는 것처럼 느낍니다. ARM 어셈블리에서 하드웨어 부동 소수점 추가를 시뮬레이트하는 함수를 작성하려고합니다. 현재 단지 임의의 두 수레와 내 ARM 함수를 호출하고, 소수의 결과 및 바이너리 출력 (간체)(ARM 어셈블리) 레지스터를 오른쪽으로 이동하면 1이 모든 비트를 0으로 설정합니다.
.global simulated_fp_add
.type simulated_fp_add, %function
simulated_fp_add:
push {r3, r4, r5, r6, lr}
mov r0, r0, lsr #1
pop {r3, r4, r5, r6, pc}
내 주요 파일 :
#include <stdio.h>
float simulated_fp_add(float, float);
void prt_bin(unsigned int, unsigned int);
int main() {
float x,y,z;
unsigned int a,b,c;
union
{
float f;
unsigned int i;
} u;
x = 125;
y = 0.5;
u.f = x;
a = u.i;
u.f = y;
b = u.i;
c = simulated_fp_add(a, b);
u.f = c;
printf("simulated_fp_add(%d, %d) = %f\n", a, b, u.f);
printf("result in binary: ");
prt_bin(c, 32);
putchar('\n');
return 0;
}
void prt_bin(unsigned int value, unsigned int length) {
int i;
for (i=(length-1); i>=0; i--) {
if ((value >> i) & 1)
putchar('1');
else
putchar('0');
}
}
을 나는 현재 다음과 같습니다 기능 float simulate_fp_add(float, float)
이 시프트 라인 출력을 제거 :
simulated_fp_add(1123680256, 1056964608) = 125.000000
result in binary: 01000010111110100000000000000000
변속 출력하여 다음
,simulated_fp_add(1123680256, 1056964608) = 0.000000
result in binary: 00000000000000000000000000000000
내 simulated_fp_add 함수는 float를 r0 오른쪽 1로 이동하지만 결과는 0입니까? 내가 놓친 게 있니?