asic_SoC_designer
Newbie level 1
- Joined
- Feb 16, 2015
- Messages
- 1
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 14
Hi
I have a question about the assembly code generated by this small patch of C code that I wrote. The code patch is shown below, basically what I am doing is reading floating point values in from a hardware updated register and performing the arctan2f function on those values.
OK so the code is not working and I have no idea why. I took a look at the disassemble list and I found something which looks very strange to me. The compiler places the two floating point variables x and y in floating point registers $f12, and $f13 and then calls the atan2f function as shown below.
Now here is the weird part, when I look through the atan2f code I see ABSOLUTELY NO mention of floating point register $f13. Am I missing something here??? I do see a reference for a mfc1 for floating point register $f14 but no mention of register $f13 which is the register which holds the x operand for the atan2f(y,x) function. I can attached the entire dissemble list for you to have a look for yourself.
Here are my command line and options.
mips-sde-elf-gcc -Os -msingle-float -fsingle-precision-constant -g -mno-memcpy -mno-branch-likely -mno-check-zero-division -mabi=32 -mfp32 -mno-paired-single -mips32r2 -mno-fp-exceptions -mtune=r3k -T elf32btsmip.xc startup.o atan2_test.cpp -o uPC0_Spr6.elf -lc -lm
Thanks in advance for your help!
I have a question about the assembly code generated by this small patch of C code that I wrote. The code patch is shown below, basically what I am doing is reading floating point values in from a hardware updated register and performing the arctan2f function on those values.
Code:
#include "stdlib.h"
#include "math.h"
#include <stdarg.h>
#include "GLOBAL.H"
//Volatile Variables accessing hardware registers!!!
#define rs232_uart2_fp (*((volatile float *) 0x8C080000))
#define quik_silva_reg_fp (*((volatile float *) 0x8C040000))
int main (void)
{
float temp;
float ax, ay;
quik_silva_reg = 0;
while ( 1 ) {
ax = rs232_uart2_fp;
ay = rs232_uart2_fp;
quik_silva_reg = 0;
quik_silva_reg_fp = atan2f(ay, ax);
}
return 0;
}
OK so the code is not working and I have no idea why. I took a look at the disassemble list and I found something which looks very strange to me. The compiler places the two floating point variables x and y in floating point registers $f12, and $f13 and then calls the atan2f function as shown below.
Code:
while ( 1 ) {
ax = rs232_uart2_fp;
24c: c62d0002 lwc1 $f13,0(s1)
Trig_Tests/atan2_test.cpp:28
ay = rs232_uart2_fp;
250: c62c0002 lwc1 $f12,0(s1)
Trig_Tests/atan2_test.cpp:29
quik_silva_reg = 0;
254: ae000000 sw zero,0(s0)
Trig_Tests/atan2_test.cpp:30
quik_silva_reg_fp = atan2f(ay, ax);
258: 0c00009b jal 26c <atan2f>
25c: 00000000 nop
260: e6000000 swc1 $f0,0(s0)
264: 08000093 j 24c <main+0x20>
268: 00000000 nop
Now here is the weird part, when I look through the atan2f code I see ABSOLUTELY NO mention of floating point register $f13. Am I missing something here??? I do see a reference for a mfc1 for floating point register $f14 but no mention of register $f13 which is the register which holds the x operand for the atan2f(y,x) function. I can attached the entire dissemble list for you to have a look for yourself.
Here are my command line and options.
mips-sde-elf-gcc -Os -msingle-float -fsingle-precision-constant -g -mno-memcpy -mno-branch-likely -mno-check-zero-division -mabi=32 -mfp32 -mno-paired-single -mips32r2 -mno-fp-exceptions -mtune=r3k -T elf32btsmip.xc startup.o atan2_test.cpp -o uPC0_Spr6.elf -lc -lm
Thanks in advance for your help!